Compiler Design
Code Generation & Optimization
GATE 2016
Hard
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 ____.
10
Explanation
u,t,v,w,z are never reassigned — 5 variables. x is assigned twice (x1=u−t, x2=y1+w) — 2 versions. y is assigned three times (y1=x1*v, y2=t−z, y3=x2*y2) — 3 versions. Total = 5+2+3 = 10.
Source: GATE CS 2016 (Session 1 / Set A) (2016)
This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.