Consider the following code segment. x = u - t; y = x * v; x = y + w; y = t -…

2016

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 __________ .

Attempted by 71 students.

Show answer & explanation

Correct answer: 10

Key idea: in static single assignment (SSA) form every assignment to a variable creates a new version of that variable; variables that are never assigned keep a single version.

  • x1 = u - t

  • y1 = x1 * v

  • x2 = y1 + w

  • y2 = t - z

  • y3 = x2 * y2

Count the distinct names after versioning: x1, x2, y1, y2, y3, u, t, v, w, z — total 10 variables.

Answer: 10

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir