1 votes 1 votes 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______ Compiler Design compiler-design static-single-assignment intermediate-code + – Sambhrant Maurya asked Oct 31, 2018 Sambhrant Maurya 3.0k views answer comment Share Follow See all 11 Comments See all 11 11 Comments reply Shubhgupta commented Aug 16, 2018 reply Follow Share refer this- https://gateoverflow.in/227604/static-single-variable 0 votes 0 votes minal commented Sep 6, 2018 reply Follow Share 7 is correct only 0 votes 0 votes `JEET commented Oct 31, 2018 i edited by `JEET Nov 15, 2018 reply Follow Share 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) Therefore answer is 5. 0 votes 0 votes adarsh_1997 commented Oct 31, 2018 reply Follow Share 7? 0 votes 0 votes Sambhrant Maurya commented Nov 1, 2018 reply Follow Share Sorry. The answer is given as 6. 0 votes 0 votes Sambhrant Maurya commented Nov 1, 2018 reply Follow Share 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. 2 votes 2 votes srestha commented Nov 1, 2018 reply Follow Share I got 5 0 votes 0 votes Sambhrant Maurya commented Nov 1, 2018 reply Follow Share @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 votes 0 votes srestha commented Nov 1, 2018 reply Follow Share 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 votes 0 votes sripo commented Nov 2, 2018 reply Follow Share Is this still part of the syllabus after 2016 updation? 0 votes 0 votes Shaik Masthan commented Nov 3, 2018 reply Follow Share it should be 7, and it is duplicate of https://gateoverflow.in/228305/compiler-single-static-assignment#c260022 0 votes 0 votes Please log in or register to add a comment.
5 votes 5 votes 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 adarsh_1997 answered Oct 31, 2018 adarsh_1997 comment Share Follow See all 9 Comments See all 9 9 Comments reply Show 6 previous comments himgta commented Nov 4, 2018 reply Follow Share @Shaik Masthan....brother This is the comment before I saw your solution to that question...now I got that! 0 votes 0 votes Shaik Masthan commented Nov 4, 2018 reply Follow Share @himgta THEN SORRY ! it is recent question and you recently commented on this question... that's why i commented like that. 0 votes 0 votes himgta commented Nov 4, 2018 reply Follow Share @Shaik Masthan sir...you are a true star,always ready for help! 0 votes 0 votes Please log in or register to add a comment.
2 votes 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 zerocod3r answered Aug 18, 2018 zerocod3r comment Share Follow See all 3 Comments See all 3 3 Comments reply sandygate commented Oct 9, 2018 reply Follow Share shouldn't the answer be 5 as the b+c,a1+x is repeated 0 votes 0 votes zerocod3r commented Oct 17, 2018 reply Follow Share No, if variable is repeated on LHS then it is replaced with new variable. 0 votes 0 votes Shivam Kasat commented Nov 3, 2018 reply Follow Share according to ME solution the answer is 6, the are using DAG as there solution. 0 votes 0 votes Please log in or register to add a comment.
2 votes 2 votes In $SSA$ when we assign the values, the variable to which the values is being assigned should be unique. RHS of the operation can use the previously used variables, but the LHS in SSA must always be unique. $R1=b+c;$ $R2=R1+x;$ $R3=R1;$ $R4=R2;$ So total variables =$7$ Gupta731 answered Dec 10, 2018 Gupta731 comment Share Follow See all 3 Comments See all 3 3 Comments reply sim1234 commented Dec 10, 2018 reply Follow Share But answer according to made easy solution is 6. 0 votes 0 votes Mk Utkarsh commented Dec 10, 2018 reply Follow Share sim1234 comment ME solution 0 votes 0 votes Gupta731 commented Dec 11, 2018 reply Follow Share Yes I attempted that test, their answer is wrong . They did a mistake /misprint in the last step. 0 votes 0 votes Please log in or register to add a comment.
0 votes 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. Shubhgupta answered Jul 22, 2018 Shubhgupta comment Share Follow See all 3 Comments See all 3 3 Comments reply MiNiPanda commented Aug 16, 2018 reply Follow Share temp5 and temp7 are same. Do they need separate register allocation? 0 votes 0 votes Shubhgupta commented Aug 17, 2018 reply Follow Share @MiNiPanda,Shouldn't be assignment of each variable unique? In SSA every definition gets its own version. 0 votes 0 votes Vaibhav Rai commented Aug 17, 2018 reply Follow Share but answer given is 6 0 votes 0 votes Please log in or register to add a comment.