![Texas Instruments TMS320C2x User Manual Download Page 87](http://html1.mh-extra.com/html/texas-instruments/tms320c2x/tms320c2x_user-manual_1097073087.webp)
What Kind of Optimization Is Being Performed?
3-18
3.8.5 Algebraic Reordering / Symbolic Simplification / Constant Folding
For optimal evaluation, the compiler simplifies expressions into equivalent
forms requiring fewer instructions or registers. For example, the expression (a
+ b)
−
(c + d) takes six instructions to evaluate; it can be optimized to ((a + b)
−
c)
−
d, which takes only four instructions. Operations between constants are
folded into single constants. For example, a = (b + 4)
−
(c + 1) becomes a = b
−
3.8.6 Alias Disambiguation
Programs written in the C language generally use many pointer variables.
Frequently, compilers are unable to determine whether or not two or more I
(lowercase L) values (symbols, pointer references, or structure references)
refer to the same memory location. This
aliasing
of memory locations often
prevents the compiler from retaining values in registers because it cannot be
sure that the register and memory continue to hold the same values over time.
Alias disambiguation is a technique that determines when two pointer expres-
sions cannot point to the same location, allowing the compiler to freely opti-
mize such expressions.
3.8.7 Data-Flow Optimizations
Collectively, the following three data-flow optimizations replace expressions
with less costly ones, detect and remove unnecessary assignments, and avoid
operations that produce values already computed. The optimizer performs
these data-flow optimizations both locally (within basic blocks) and globally
(across entire functions). See Example 3
-
Copy propagation
Following an assignment to a variable, the compiler replaces references to
the variable with its value. The value could be another variable, a constant,
or a common subexpression. This may result in increased opportunities
for constant folding, common subexpression elimination, or even total
elimination of the variable. See Example 3
-
Common subexpression elimination
When the same value is produced by two or more expressions, the com-
piler computes the value once, saves it, and reuses it. See Example 3
-
Redundant assignment elimination
Often, copy propagation and common subexpression elimination opti-
mizations result in unnecessary assignments to variables (variables with
no subsequent reference before another assignment or before the end of
the function). The optimizer removes these dead assignments. See
Example 3
Summary of Contents for TMS320C2x
Page 8: ...viii...
Page 69: ...2 47 C Compiler Description...
Page 159: ...6 36...
Page 226: ...8 6...