777 views
1 votes
1 votes

Consider below two question :-

https://gateoverflow.in/39675/gate-2016-1-19

https://gateoverflow.in/8365/gate2015-1_55

Q1 >> Consider the following code segment.

x = u - t;
y = x * v; 
x = y + w;
y = t - z; 
y = x * y;

The minimum number of total variables required to convert the above code segment to static single assignment form is __________.

Here answer is 10.

Solution is 

x(temp3) = u(temp1) - t(temp2);
y(temp5) = x * v(temp4); 
x(temp7) = y + w(temp6);
y(temp9) = t - z(temp8); 
y(temp10) = x * y;

so ans should be.10

Q2> The least number of temporary variables required to create a three-address code in static single assignment form for the expression q  + r / 3 + s - t * 5 + u * v/w is__________________.

here answer is 8.

Solution:- 

t1 = r/3; 
t2 = t*5; 
t3 = u*v; 
t4 = t3/w; 
t5 = q + t1; 
t6 = t5 + s; 
t7 = t6 - t2; 
t8 = t7 + t4

In Q1 we are allocating a new variable to each variable, but in the second we are not so, like we are not allocating temp variable to "r", whereas in Solution 1 we have allocated temp variable to u and t both. Even both are using static single assignment?

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
2
minal asked Jan 22, 2019
898 views
# of temporary variable required to create 3 address code in static single assignment form for the expression P+Q*R-S/(Q*R).