PMP has a code optimizer with pretty good performances. However, it may be disabled for debug purposes.
Since V1.3 PMP does expression and sub-expressions optimizations before generating code so it produces good code regardless of the complexity or inefficiency of expressions.
But unused code and data was not detected and managed.
Since V2.0 PMP has Dead Code Removal algorithms (DCR). These algorithms ensure recursively that a never called procedure or function does not generate code, and that data used by these procedures and functions will not consume RAM.
Well, in the current real world there are some compromises that may affect the final result, so a minimum help from the programmer is still needed.
General simple rules:
PMP goes ahead and the future implementations will be more optimized. This is the most difficult goal in writing a compiler…