Using the C Compiler Optimizer
3.1
Using the C Compiler Optimizer
Figure 3−1. Compiling a C Program With the Optimizer
3-2
The optimizer runs as a separate pass between the parser and the code
generator. Figure 3−1 illustrates the execution flow of the compiler with stand-
alone optimization.
C source
Parser
file (.c)
.if file
The easiest way to invoke the optimizer is to use the dspcl shell program, spec-
ifying the −on option on the dspcl command line. The n denotes the level of
optimization (0, 1, 2, and 3), which controls the type and degree of optimiza-
tion:
−o0
-
Performs control-flow-graph simplification
J
Allocates variables to registers
J
Performs loop rotation
J
Eliminates unused code
J
Simplifies expressions and statements
J
Expands calls to functions declared inline
J
−o1
-
Performs all −o0 optimizations, plus:
Performs local copy/constant propagation
J
Removes unused assignments
J
Eliminates local common expressions
J
−o2
-
Performs all −o1 optimizations, plus:
Performs loop optimizations
J
Eliminates global common subexpressions
J
Eliminates global unused assignments
J
Converts array references in loops to incremented pointer form
J
Performs loop unrolling
J
The optimizer uses −o2 as the default if you use −o without an optimization
level.
Optimizer
generator
.opt file
Code
.asm file
Need help?
Do you have a question about the TMS320C2x and is the answer not in the manual?