# GATE | Sudo GATE 2020 Mock II (10 January 2019) | Question 14

Consider the following code segment.

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

The minimum number of total variables required to convert the above code segment to static single assignment form is
(A) 6
(B) 8
(C) 9
(D) 10

Explanation: Static Single Assignment (SSA) 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;

So we use two variables x1, x2 for specifying distinct assignments of x and y1, y2 each assignment of y. So, total number of variables is 9 (x1, x2, y1, y2, 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; ;

https://www.cs.cmu.edu/~fp/courses/15411-f08/lectures/09-ssa.pdf

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.