|ARM Technical Support Knowledge Articles|
Applies to: C251 C Compiler
Information in this article applies to:
How do I change optimization levels ?
The OPTIMIZE directive set the optimization level and emphasis.
Arguments: A decimal number between 0 and 7 enclosed in parentheses. In addition, OPTIMIZE (SIZE) or OPTIMIZE (SPEED) may be used to select whether the optimization emphasis should be placed on code size or on execution speed.
Each higher optimization level contains all of the characteristics of the preceding lower optimization level.
Constant Folding: The compiler performs calculations that reduce expressions to numeric constants, where possible. This includes calculations of run-time addresses.
Simple Access Optimizing: The compiler optimizes access of internal data and bit addresses in the 251 system.
Jump Optimizing: The compiler always extends jumps to the final target. jumps to jumps are deleted.
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.
Data Overlaying: Data and bit segments suitable for static overlay are indentifed and internally marked. The L251 linker/locator has the capability, through global data flow analysis, of selecting the segments which can then be overlaid.
Peephole Optimizing: Redundant MOV instructions are removed. This include unnecessary loading of objects from the memory as well as load operations with constants. Complex operations are replaced by simple operations when memory space or execution time can be saved.
Register Variables: Automatic variables and functions are calculated only once when possible. Reservation of data memory for these variables is omitted.
Extended Access Optimizing: Variables from the IDATA, XDATA, PDATA, and CODE areas are directly included in operations. The use of intermediate registers is not necessary most of the time.
Local and Global Common Subexpression Elimination: Identical sub expressions within a a function are calculated only one when possible. The intermediate result is stored in a register and used instead of a new calculation.
Case/Switch Optimizing: Code involving switch and case statements is optimized as jump tables or jump strings.
Life Variable Analysis: Removes redundant and dead store operations to automatic variables.
Constant Propagation: The values of expressions are tracked and when possible constant values are inserted instead of variable accesses.
Peephole Optimizing: Redundant MOV instructions are removed. This includes unnecessary loading of objects from the memory as well as load operations with constants. Complex operations are replaced by simple operations when memory space or execustion time can be saved.
Common Tail Merging and Instruction Simplification: The compiler analyzes the generated code function by function and tries to find common heads and tails. If the compiler detects common code sequences, it will replace one code sequence by a jump instruction to the other equivalent code sequence. This situation arises many times with switch/case statements, for example. While analyzing the code, the compiler also tries to replace instruction sequences with cheaper instructions.
C251 SAMPLE.C OPTIMIZE (size) C251 SAMPLE.C OPTIMIZE (6, speed) #pragma ot(4) #pragma ot(size)
Article last edited on: 2005-07-18 09:47:00
Did you find this article helpful? Yes No
How can we improve this article?