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
Each higher optimization level contains all of the
characteristics of the preceding lower optimization level. For
example, OPTIMIZE level 7 includes all optimizations of
levels 0 to 6.
You may change the optimizer level on a function-by-function
basis as needed. For example:
This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.
ARM websites use two types of cookie: (1) those that enable the site to function and perform as required; and (2) analytical cookies which anonymously track visitors only while using the site. If you are not happy with this use of these cookies please review our Privacy Policy to learn how they can be disabled. By disabling cookies some features of the site will not work.