GateAI
Intermediate Code Generation

GATE CSE 2016 Set 1 · Q19

NAT1 markMedium

Time

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 _________ .

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 10

Intermediate Code Generation

In Static Single Assignment (SSA) form, each variable must be assigned exactly once, and every variable used must be defined before use.

  1. Initial (input) variables used without prior definition in the block:

    • u,t,v,w,zu, t, v, w, z (Total = 5 variables)

  2. Converting the statements by creating a new unique variable version at each definition:

    • Line 1: x1=u−tx_1 = u - t

    • Line 2: y1=x1∗vy_1 = x_1 * v

    • Line 3: x2=y1+wx_2 = y_1 + w

    • Line 4: y2=t−zy_2 = t - z

    • Line 5: y3=x2∗y2y_3 = x_2 * y_2

    This introduces 5 newly defined distinct variables: x1,y1,x2,y2,y3x_1, y_1, x_2, y_2, y_3.

  3. Total number of variables in the SSA code:

    Total variables={u,t,v,w,z}∪{x1,y1,x2,y2,y3}\text{Total variables} = \{u, t, v, w, z\} \cup \{x_1, y_1, x_2, y_2, y_3\}
    Total count=5+5=10\text{Total count} = 5 + 5 = 10

Thus, the minimum number of total variables required is 10.

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 Q19 of the GATE CSE 2016 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. This is the only 1-mark NAT question among them, and it is the only one in GATE CSE 2016 Set 1.

How GATE tests Intermediate Code Generation

More from GATE CSE 2016 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2016 Set 1 · Q19 · NAT

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 …

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.