I am implementing SSA construction for a compiler I'm writing. There is something I don't understand in the SSA algorithms (using the Cytron paper and the book Modern Compiler Implementation in Java, second edition by A.W. Appel). What if a variable y
is defined for the first time (and used) in one straight control flow path but never defined in another parallel path. Do I have to insert a PHI-function at the join point (the dominance frontier of the block defining y
)?
x = 1; // A
if (P) // A
y = x + 1; // B
y = y + 1; // B
x = x + 1; // C
return; // C
For example, in block B there is the first definition of y
. Do I have to insert a PHI instruction at the start of block C, with two operands (one for each incoming control flow path)? Then on SSA renaming: how would I name the operand coming from the path A -> C
(not through B) where y
is never defined?
Entry --- A --------- C --- Exit
\ /
\-- B --/