Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

GATE | GATE-CS-2015 (Set 1) | Question 64

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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
(A) 4
(B) 8
(C) 7
(D) 9


Answer: (B)

Explanation:

The correct answer is 8. This question was asked as a fill in the blank type question in the exam.

 

Three address code is an intermediate code generated by compilers while optimizing the code. Each three address code instruction can have atmost three operands (constants and variables) combined with an assignment and a binary operator. The point to be noted in three address code is that the variables used on the left hand side (LHS) of the assignment cannot be repeated again in the LHS side. Static single assignment (SSA) is nothing but a refinement of the three address code.

So, in this question, we have

t1 = r / 3;

t2 = t * 5;

t3 = u * v;

t4 = t3 / w;

t5 = q + t1;

t6 = t5 + s;

t7 = t6 - t2; 

t8 = t7 + t4;

Therefore, we require 8 temporary variables (t1 to t8) to create the three address code in static single assignment form.



Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 17 Sep, 2021
Like Article
Save Article
Similar Reads