Optimization Dataflow Detailed
Optimization Dataflow Detailed
These optimizations preserve the semantics of the program but improve performance.
Local Optimizations:
a) Constant Folding:
- Example: x = 2 + 3 x = 5
b) Strength Reduction:
- Example: x = y * 2 x = y + y
c) Algebraic Simplifications:
- Example: x = x + 0 x
- Example:
t1 = a + b
e) Copy Propagation:
- Example:
x=y
z=x z=y
Loop Optimizations:
- Example:
b) Loop Unrolling:
- Example:
PRE eliminates expressions that are redundant on some but not all paths.
Example:
if (cond)
t1 = a + b;
...
t2 = a + b;
PRE inserts the computation before the conditional to make it fully redundant:
t0 = a + b;
if (cond)
t1 = t0;
...
t2 = t0;
3. Constant Propagation
Example:
x = 5;
y = x + 3; y = 5 + 3 y = 8
Data-flow analysis gathers information about the possible set of values calculated at various points.
Notations:
Applications:
- Reaching definitions
- Available expressions
- Strength reduction
- Loop unrolling