The least number of temporary variables required to create a three-address code in static single assignment form for the expression q + r / 3 + s - t * 5 + u * v / w is …
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2015 Set 1 · Q55
Time
Your answerNumerical answer
Solution
Official answer: 8
Intermediate Code GenerationIn Static Single Assignment (SSA) form, every variable must be assigned exactly once. Therefore, each intermediate operation generates a new, distinct temporary variable.
The given expression is:
Following standard operator precedence (multiplication and division have higher precedence than addition and subtraction, with left-to-right associativity), the expression is evaluated as:
The three-address code in SSA form can be written as:
Since there are binary operations and each definition must be assigned to a unique temporary variable in SSA form, a minimum of 8 temporary variables are required.
Try the question first, then check your work.
Examiner trap
In Static Single Assignment (SSA) form, each variable is assigned exactly once, so each binary operation requires a new temporary variable.
This Intermediate Code Generation previous year question is Q55 of the GATE CSE 2015 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. 3 of them are 2-mark NAT questions like this one, and it is the only one in GATE CSE 2015 Set 1.
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.