search
Log In
1 vote
186 views

in Compiler Design 186 views
0
7 is correct only

2 Answers

2 votes

Ans is 7

This can be converted to SSA as

a1 = b + c

c1 = a1 + x

d1 = b + c1

b1 = a1 + x

so total count of variables is 7

0
shouldn't the answer be 5 as the b+c,a1+x is repeated
0
No, if variable is repeated on LHS then it is replaced with new variable.
0
according to ME solution the answer is 6, the are using DAG as there solution.
0 votes
Static single assignment means assignment to register can be done only one time-

a(temp3) = b(temp1) + c(temp2);

c(temp5) = a + x(temp4);

d(temp6) = b + c;

b(temp7) = a + x;

total 7 variables are required.
0
temp5 and temp7 are same. Do they need separate register allocation?
0
@MiNiPanda,Shouldn't be assignment of each variable unique? In SSA every definition gets its own version.
0
but answer given is 6

Related questions

0 votes
1 answer
1
254 views
# of temporary variable required to create 3 address code in static single assignment form for the expression P+Q*R-S/(Q*R).
asked Jan 22, 2019 in Compiler Design minal 254 views
3 votes
0 answers
4
588 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 single assignment form is ________. Doubt : Are we allowed to do minimizations in SSA? if YES then is it always the case, if NO when do we have to do it. Please clarify.
asked Dec 26, 2018 in Compiler Design shreyansh jain 588 views
...