Module 14: Approaches to Control Flow Analysis
  Lecture 28: Structural Analysis
 

ud(I,d2) = d1
ud(J,d4) = d2d4d5
ud(J,d5) = d4
ud(I,B5) = d3

Constant Folding

While changes occur do
for all the stmts S of the program do
for each operand B of S do
if there is a unique definition of B
that reaches S and is a constant C
then replace B by C in S;
if all the operands of S are constant
then replace rhs by eval(rhs);
endfor
endfor
endwhile

Example