Using the C Compiler Optimizer
3-2
3.1 Using the C Compiler Optimizer
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.
Figure 3
−
1. Compiling a C Program With the Optimizer
C source
file (.c)
Code
generator
Parser
Optimizer
.if file
.asm file
.opt file
The easiest way to invoke the optimizer is to use the dspcl shell program, spec-
ifying the
−
o
n
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
J
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
-
−
o1
Performs all
−
o0 optimizations, plus:
J
Performs local copy/constant propagation
J
Removes unused assignments
J
Eliminates local common expressions
-
−
o2
Performs all
−
o1 optimizations, plus:
J
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
The optimizer uses
−
o2 as the default if you use
−
o without an optimization
level.
Summary of Contents for TMS320C2x
Page 8: ...viii...
Page 69: ...2 47 C Compiler Description...
Page 159: ...6 36...
Page 226: ...8 6...