Code Optimization
Code Optimization
X=3;
Y=7;
Constant propagation
Common sub expression elimination
Compiler writers distinguish two kinds of CSE:
local common sub expression
elimination works within a single basic block
global common sub expression
elimination works on an entire procedure
Def:
CSE is a compiler optimization that searches for
instances of identical expressions (i.e., they all
evaluate to the same value), and analyzes
whether it is worthwhile replacing them with a
single variable holding the computed value.
Common sub expression elimination
In the following code:
a = b * c + g;
d = b * c * e;