in Compiler Design
315 views
2 votes
2 votes
x = 7
if b {
   x = 8
}
print(x)

Convert the following code in Static single assignment form.

in Compiler Design
315 views

1 comment

I think we just need to replace the second $x$ with $x_1 $. rest everything stays the same. I referred this nptel handout. http://nptel.ac.in/courses/106108052/module13/ssa-1.pdf

they are using a flow diagram representation for SSA. since the printed $x$ can be different depending on whether or not the if is taken, they are using a $ϕ$ function termed as special merge operator. it will take the appropriate value depending on the path of execution the program takes.so we will have to add a new line before the $print(x)$ as $x_2$=$ϕ(x,x_1)$ and we print $x_2$. this is what I understood. 

2
2

Please log in or register to answer this question.

Related questions