GATE / CS ARCHIVE

GATE CSE 2016 SET 1 / QUESTION 19

GATE CSE 2016 Set 1 Q19

Compiler Design · Intermediate Code · Full GATE CSE 2016 Set 1 paper

GATE 2016 Set 1, Q19 1 mark · NAT
Report issue

Intermediate Code

Question 19, GATE 2016: Find the minimum total number of variable names in static single-assignment form for this straight-line code, including incoming variables:
x=u−t;
y=x*v;
x=y+w;
y=t−z;
y=x*y;
Tap to enlarge
Answer & solution

Official answer: 10.0 : 10.0

Our answer: 10

The five incoming values u, t, v, w, z each need one name. The two definitions of x and three of y need five distinct SSA names: x1=u−t; y1=x1*v; x2=y1+w; y2=t−z; y3=x2*y2. Total 5+5=10 variables, counting incoming values as requested.

In SSA, each name has exactly one definition, but it can be read many times. Hence the two reads of t share one incoming name, while the successive writes to y cannot share a name. When renaming, every use must refer to its most recent preceding definition: the final product uses x2 and y2, not the original names. There are no branches here, so no φ-functions are necessary. Five new defined names plus five distinct incoming names is the requested total.

Original paper, page 9 · Answer key