GateAI
Intermediate Code Generation

GATE CSE 2017 Set 1 · Q12

MCQ1 markEasy

Time

Consider the following intermediate program in three address code p=a−bp = a - b q=p∗cq = p * c p=u∗vp = u * v q=p+qq = p + q Which one of the following corresponds to a static single assignment form of the above code?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B) p3 = a - b q4 = p3 * c p4 = u * v q5 = p4 + q4

Intermediate Code Generation

In 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:

  1. p=a−bp = a - b: A new definition for pp. Introduce a unique variable name, say p3p_3.

      ⟹  p3=a−b\implies p_3 = a - b
  2. q=p∗cq = p * c: A new definition for qq, and it uses the value of pp defined in step 1 (p3p_3). Introduce a unique name for qq, say q4q_4.

      ⟹  q4=p3∗c\implies q_4 = p_3 * c
  3. p=u∗vp = u * v: A new definition for pp. It must receive a fresh subscript distinct from previous definitions, say p4p_4.

      ⟹  p4=u∗v\implies p_4 = u * v
  4. q=p+qq = p + q: A new definition for qq. It must receive a fresh subscript, say q5q_5. It uses the most recent definition of pp (from step 3, p4p_4) and the most recent definition of qq (from step 2, q4q_4).

      ⟹  q5=p4+q4\implies q_5 = p_4 + q_4

Combining these gives the SSA form:

p3=a−bp_3 = a - b
q4=p3∗cq_4 = p_3 * c
p4=u∗vp_4 = u * v
q5=p4+q4q_5 = p_4 + q_4

This matches option (B).

### Why other options are incorrect:

  • (A) violates the single assignment rule because p1p_1 and q1q_1 are assigned multiple times.

  • (C) uses undefined variable versions (p2p_2 in line 2, and p4,q3p_4, q_3 in line 4).

  • (D) fails to rename variables at their uses in lines 2 and 4.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

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

Where do you stand for GATE?

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.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Intermediate Code Generation in GATE CSE

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 Generation

More from GATE CSE 2017 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2017 Set 1 · Q12 · MCQ

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

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.