Consider the following intermediate program in three address code p = a - b q = p * c p = u * v q = p + q Which one of the following corresponds to a static single assignment form of the above code?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2017 Set 1 · Q12
Time
Select one answerSingle correct
Solution
Official answer: B) p3 = a - b q4 = p3 * c p4 = u * v q5 = p4 + q4
Intermediate Code GenerationIn Static Single Assignment (SSA) form, each variable is defined (assigned) exactly once, and every use of a variable refers to a unique reaching definition [INDEX_0]. Subscripts are typically introduced to distinguish different definitions of the same original variable [INDEX_0].
Let us trace the original program step-by-step:
: A new definition for . Introduce a unique variable name, say .
: A new definition for , and it uses the value of defined in step 1 (). Introduce a unique name for , say .
: A new definition for . It must receive a fresh subscript distinct from previous definitions, say .
: A new definition for . It must receive a fresh subscript, say . It uses the most recent definition of (from step 3, ) and the most recent definition of (from step 2, ).
Combining these gives the SSA form:
This matches option (B).
### Why other options are incorrect:
(A) violates the single assignment rule because and are assigned multiple times.
(C) uses undefined variable versions ( in line 2, and in line 4).
(D) fails to rename variables at their uses in lines 2 and 4.
Try the question first, then check your work.
Examiner trap
In Static Single Assignment (SSA) form, each variable must be assigned exactly once, and every use must refer to the latest definition of that variable.
This Intermediate Code Generation previous year question is Q12 of the GATE CSE 2017 Set 1 paper. Find more GATE CSE PYQs on Intermediate Code Generation in Compiler Design, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Intermediate Code Generation PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Intermediate Code Generation has 14 GATE CSE PYQs across 12 papers from 2011 to 2025. 5 of them are 1-mark MCQs like this one, and GATE CSE 2017 Set 1 has 3.
How GATE tests Intermediate Code GenerationIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.