 CARM User's Guide Discontinued |
|
| OPTIMIZE Compiler Directive| Abbreviation | | OT | | Arguments | | A decimal number between 0 and 8 enclosed in parentheses optionally followed by SIZE or SPEED to specify code size or execution speed emphasis. | | Default | | OPTIMIZE (6, SPEED) | | µVision | | Options — CA — Code Optimization. | | Description | | The OPTIMIZE directive sets the optimization level and emphasis. | Level | Description |
|---|
| 0 | Constant Folding: The compiler performs calculations that reduce expressions to numeric constants, where possible. This includes calculations of run-time addresses.
Jump Optimizing: The compiler always extends jumps to the final target. Jumps to jumps are eliminated. | | 1 | Dead Code Elimination: Unused code fragments and artifacts are eliminated.
Jump Negation: Conditional jumps are closely examined to see if they can be streamlined or eliminated by the inversion of the test logic. | | 2 | Unreachable Code Analysis: Code that cannot be reached because of constant conditional expressions or unreferenced labels is removed.
Register Variables: Automatic variables and function arguments are located in registers when possible. Reservation of data memory for these variables is omitted. | | 3 | Local Common Subexpression Elimination: If the same calculations are performed repetitively in an expression, the result of the first calculation is saved and reused when possible. Superfluous calculations are eliminated from the code.
Global Common Subexpression Elimination: Identical subexpressions within a function are calculated only once when possible. The intermediate result is stored in a register and reused.
Case/Switch Optimizing: Code involving switch and case statements is optimized using jump tables or jump strings. | | 4 | Life Variable Analysis: Redundant store operations are replaced with the use of automatic variables. | | 5 | Constant Propagation: The values of expressions are tracked and, when possible, constant values are inserted instead of variable accesses. | | 6 | Common Tail Merging: When there are multiple calls to a single function, some of the setup code can be reused, thereby reducing program size. | | 7 | Strength Reduction: Array accesses are replaced by pointer operations to speed-up loops.
Invariant Code Motion: Invariant code is moved into the setup portion of a loop which causes the loop to execute faster. | | 8 | Static Access Optimization: Re-uses the base address of prior load and store operations and uses an offset to this base address. |
Note | | Example | |
CA SAMPLE.C OPTIMIZE (8)
CA SAMPLE.C OPTIMIZE (0)
#pragma ot(6, SIZE)
#pragma ot(size)
|
|
|