+1 vote
382 views
Consider the following code generation:

a=b+c;

c=a+x;

d=b+c;

b=a+x;

The minimum no. of total variables required to convert the above code to static single assignment form is______
| 382 views
0
The use of SSA in compiler design is mainly for the intermediate code. In SSA, assignment to a variable should be mentioned with different names.

We generally use, subscript to differentiate each equation of variables.

In the above question, minimum no. of variables will be (a, b, c, d, x)

0
7?
0
Sorry. The answer is given as 6.
+2
I got 7 too, but the answer is given as 6.

t1=b+c;

t2=t1+x;

t3=b+t2;

t2=t1+x;

The confusion arises because there is repetition of b = a+x in the question.
0
I got 5
0
@srestha The answer is given as 6.

t1=b+c;

t2=t1+x;

t3=b+t2;

t2=t1+x;

The confusion arises because there is repetition of b = a+x in the question.
0
See here a,b,c,d require 1 temp variable and x is another variable which never used in storing result

So, total 5
0
Is this still part of the syllabus after 2016 updation?
0

IN SSA RHS OF THE OPERATION CAN USE THE PREVIOUSLY USED VARIABLE ,BUT LHS IN SSA MUST BE UNIQUE.

SOLVING

a1=b1+c1;

c2=a1+x1;

d1=b1+c2;

b2=a1+x1;

the variable are a1,b1,c1,d1,x1,b2,c2 answer 7
by Active (3.8k points)
0
why you used two variables for b...b1 and b2?
+1
@HIMGTA

b has been used two times in RHS first(named it b1)  and third time it will be used in LHS, so it must be unique(according to definiton of SSA thats'y it is used with new variable.
0
can u suggest a resource to read this topic?
0
@himgta i didnt knew this topic earlier..i came across about thatin GO pdf previous year gate question.

just go to those questions follow the answers given by mentors ,you will be going to solve almost every questions after that..
0
I got 7 too, but the answer is given as 6.

t1=b+c;

t2=t1+x;

t3=b+t2;

t2=t1+x;

The confusion arises because there is repetition of b = a+x in the question.
0

@himgta

i don't know why you are confusing?

it is duplicate of https://gateoverflow.in/228305/   isn't it?

0

@Shaik Masthan....brother This is the comment before I saw your solution to that question...now I got that!

0

@himgta

THEN SORRY !

it is recent question and you recently commented on this question... that's why i commented like that.

0

@Shaik Masthan sir...you are a true star,always ready for help!