Instead of copying a value around, use the first computed expression (basically removing the use of redundant variables). Copy propagation is an optimization but also has an analysis of the same name.

Following Common Subexpression Elimination, when we perform CP we just use the canonical variables that hold our subexpressions.

s=x+y
t=k+n
a=s+t
u=s
v=t
b=s*t //(Copy in here)

Copy Propagation Analysis

  • In: set of copies available at beginning
  • Out: set of copies available at end
  • Gen: set of copies created in statement
  • Kill: set of copies killed by assignments in stmt