OPTIMIZE

Abbreviation

OT

Arguments

A decimal number between 0 and 6 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.

Default

OPTIMIZE (6,SPEED)

Description

The OPTIMIZE directive sets the optimization level and emphasis. Note:  Each higher optimization level contains all of the characteristics of the preceding lower optimization level.

Level

Description

*0

Constant Folding: The compiler performs calculations that reduce expressions to numeric constants, where possible. This includes calculations of runtime addresses.

Simple Access Optimizing: The compiler optimizes access of internal data and bit addresses in the 8051 system.

*

Jump Optimizing: The compiler always extends jumps to the final target. Jumps to jumps are deleted.

*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

Data Overlaying: Data and bit segments suitable for static overlay are identified and internally marked. The L51 Linker/Locator has the capability, through global data flow analysis, of selecting segments which can then be overlaid.

*3

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 execution time can be saved.

*4

Register Variables: Automatic variables and function arguments are located in registers 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 Common Subexpression Elimination: If the same calculations are performed repetitively in an expression, the result of the first calculation is saved and used further whenever possible. Superfluous calculations are eliminated from the code.

*

Case/Switch Optimizing: Code involving switch and case statements is optimized as jump tables or jump strings.

*5

Global Common Subexpression Elimination: Identical sub expressions within a function are calculated only once when possible. The intermediate result is stored in a register and used instead of a new calculation.

Simple Loop Optimizing: Program loops that fill a memory range with a constant are converted and optimized.

6

Loop Rotation: Program loops are rotated, if the resulting program code is faster and more efficient.

The OPTIMIZE level 6 includes all optimizations of levels 0 to 5.

Example


#pragma ot(6, SIZE)

#pragma ot(size)