EasyManua.ls Logo

Intel i960 - Constants and Expression Evaluation

Intel i960
347 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Optimization
11-3
11
Constants and Expression Evaluation
The compiler can simplify some arithmetic and boolean calculations
involving repeating expressions, constants, or operational identities.
Optimizations involving such simplifications are:
common sub-expression elimination
constant expression evaluation
constant propagation
identity collapsing
Each is explained in one of the following sections.
NOTE. The following source examples are for illustration only. The
compiler performs its transformations on an internal representation, not
at the source level.
Common Sub-expression Elimination
Common sub-expression elimination detects and combines redundant
computations within an expression. For example, this line of source text
contains the sub-expression
x[a] * y[b][c] three times:
i = (x[a] * y[b][c]) + (x[a] * y[b][c]) + (x[a] * y[b][c]);
Instead of calculating x[a] * y[b][c] three different times, the compiler
rewrites the expression to perform the calculation once and store the result
for reuse:
temp = x[a] * y[b][c];
i = (temp) + (temp) + (temp);
The compiler eliminates common sub-expressions on the results of
floating-point operations and on integer operations. In some cases the
compiler can perform this optimization for common sub-expressions
separated by branch instructions.
This optimization is performed by the
O (Optimize) compiler option at
level
1 (O1) and higher.

Table of Contents

Related product manuals