Docsity

Static Single Assignment (SSA) - Representation, Construction, and Conversion, Slides of Compilers

Partial preview of the text

Download Static Single Assignment (SSA) - Representation, Construction, and Conversion and more Slides Compilers in PDF only on Docsity!

SSA

Overview

  • SSA Representation
  • SSA Construction
  • Converting out of SSA

Example: CFG

a =

= a+

a =

= a+

a =

= a+

Multiple reaching definitions

Example: SSA Form

a 1 =

= a 1 +

a 2 =

= a 2 +

a 3 =

a 4 = Ф(a 1 ,a 3 )

= a 4 +

Single reaching definition

SSA Conditions

  1. If two nonnull paths X →+^ Z and Y →+^ Z converge at node Z, and nodes X and Y contains (V =..), then V = Ф(V, .., V) has been inserted at Z.
  2. Each mention of V has been replaced by a mention of V (^) i
  3. V and the corresponding V (^) i have the same value.

Overview

  • SSA Representation
  • SSA Construction
    • Step 1: Place Ф statements
    • Step 2: Rename all variables
  • Converting out of SSA

Renaming

a 1 =

a 1 +

a 4 =

a 4 +

a 2 =

a 3 = Ф(a 1 ,a 2 )

a 3 +

SSA Construction (I)

  • Step 1: Place Ф statements by computing iterated dominance frontier

Dominator Relation

  • If X appears on every path from START to Y, then X dominates Y.
  • Domination is both reflexive and transitive.
  • idom(Y): immediate dominator of Y
  • Dominator Tree
    • START is the root
    • Any node Y other than START has idom(Y) as its parent
    • Parent, child, ancestor, descendant

Dominator Tree Example

START

a

b c

d

END

START

CFG DT

Dominator Tree Example

START

a

b c

d

END

START

a

b (^) c

CFG DT

Dominator Tree Example

START

a

b c

d

END

START

a

b (^) c d

CFG DT

Dominance Frontier

  • Dominance Frontier DF(X) for node X
    • Set of nodes Y
    • X dominates a predecessor of Y
    • X does not strictly dominate Y

DF Example

START

a

b c

d

END

START

a

d

END

b (^) c

CFG

DT

DF(c) =? DF(a) =?