Skip to content
Related Articles

Related Articles

Improve Article

GATE | GATE-CS-2016 (Set 1) | Question 29

  • Last Updated : 16 Sep, 2021
Geek Week

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

Note : This question was asked as Numerical Answer Type.
(A) 6
(B) 8
(C) 9
(D) 10

Answer: (D)

Explanation: Static Single Assignment is used for intermediate code in compiler design. In Static Single Assignment form(SSA) each assignment to a variable should be specified with distinct names. We use subscripts to distinguish each definition of variables.

In the given code segment, there are two assignments of the variable x

x = u - t;
x = y + w;

and three assignments of the variable y.

y = x * v;
y = t - z;
y = x * y 

So we use two variables x1, x2 for specifying distinct assignments of x and y1, y2 and y3 each assignment of y. So, total number of variables is 10 (x1, x2, y1, y2, y3, t, u, v, w, z).
Static Single Assignment form(SSA) of the given code segment is:

x1 = u - t;
y1 = x1 * v;
x2 = y1 + w;
y2 = t - z;
y3 = x2 * y2;

Please refer below link for details

Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :