edited by
2,058 views
9 votes
9 votes
$x=5$

$x=x-3$

$\textbf{if } x<3$

$\quad y=x*2$

$\quad w=y$

$\textbf{else}$

$\quad y=x-3$

$w=x-y$

$z=x+y$

Give Equivalent SSA.
edited by

1 Answer

Best answer
7 votes
7 votes

SSA requires that each variable is assigned exactly once,i.e, the variable cannot be repeated on the LHS of assignment.

For the above Code Snippet, Equivalent SSA is

R1 = 5
R2 = R1 - 3

/* In the Below lines Y may have either R3 or R5 depending on which block executes,
But just that there blocks are different and at a time only one Block executes does not mean,
that they have a same value R3 in both the blocks */

if (R2 < 3)               // This is not LHS of assignment, hence same LHS
{
    R3 = R2 * 2        // Here, Y same but due to SSA, LHS must be different
    R4 = R3
}
else
{
    R5 = R2 - 3        //Here, Y same but due to SSA, LHS must be different
}

/* In the Below lines Y may have either R3 or R5 depending on which block executes */

R6 = (R3,R5) 
R7 = R2 - R6           
R8 = R2 + R7         
selected by

Related questions

431
views
1 answers
0 votes
rexritz asked Oct 22, 2023
431 views
Consider the intermediate code given below:$a=c+d$$b=a+e$$b=f*g$$h=b*a$$T=u+h$If the code is converted into a static single assignment form then the minimum number of tot...
988
views
1 answers
0 votes
minal asked Jan 22, 2019
988 views
# of temporary variable required to create 3 address code in static single assignment form for the expression P+Q*R-S/(Q*R).
1.3k
views
0 answers
3 votes
shreyansh jain asked Dec 26, 2018
1,272 views
Consider the following code segment:$c=b+a$$e=c-a$$f=c*e$$h=c+a$$i=h+f$The minimum number of temporary variable required to convert the above code segment to static singl...
839
views
1 answers
1 votes
jatin khachane 1 asked Nov 23, 2018
839 views
X = A / bY = C + DY = Y - XX = D + YZ = F + YZ = Z + AMInimum number of total variables needed to convert above TAC to Static Single AssignmentAnswer given ==>11My appora...