GateAI
Local Optimisation

GATE CSE 2025 Set 1 · Q52

NAT2 marksEasy

Time

Refer to the given 3-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is ________. (Answer in integer)1001: i = 1 1002: j = 1 1003: t1 = 10*i 1004: t2 = t1+j 1005: t3 = 8*t2 1006: t4 = t3-88 1007: a[t4] = 0.0 1008: j = j+1 1009: if j <= 10 goto 1003 1010: i = i+1 1011: if i <= 10 goto 1002 1012: i = 1 1013: t5 = i-1 1014: t6 = 88*t5 1015: a[t6] = 1.0 1016: i = i+1 1017: if i <= 10 goto 1013

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 6

Local Optimisation

To determine the number of basic blocks, we identify the leaders using the standard rules:

  1. Rule 1 (First instruction): The first three-address instruction is a leader.

    • 1001

  2. Rule 2 (Target of a jump): Any instruction that is the target of a conditional or unconditional jump is a leader.

    • Instruction 1009 jumps to 1003.

    • Instruction 1011 jumps to 1002.

    • Instruction 1017 jumps to 1013.

  3. Rule 3 (Follows a jump): Any instruction that immediately follows a conditional or unconditional jump is a leader.

    • Instruction immediately following 1009 is 1010.

    • Instruction immediately following 1011 is 1012.

Thus, the set of leader instructions is:

{1001,1002,1003,1010,1012,1013}\{1001, 1002, 1003, 1010, 1012, 1013\}

Each leader begins a new basic block extending up to (but not including) the next leader or the end of the code:

  • Block 1 (B1B_1):1001

  • Block 2 (B2B_2):1002

  • Block 3 (B3B_3):1003 to 1009

  • Block 4 (B4B_4):1010 to 1011

  • Block 5 (B5B_5):1012

  • Block 6 (B6B_6):1013 to 1017

Therefore, the total number of basic blocks is 6.

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 Local Optimisation previous year question is Q52 of the GATE CSE 2025 Set 1 paper. Find more GATE CSE PYQs on Local Optimisation 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 4 related Local Optimisation 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.

Local Optimisation in GATE CSE

Local Optimisation has 4 GATE CSE PYQs across 4 papers from 2013 to 2025. This is the only 2-mark NAT question among them, and it is the only one in GATE CSE 2025 Set 1.

How GATE tests Local Optimisation

More from GATE CSE 2025 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2025 Set 1 · Q52 · NAT

Refer to the given 3-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is … (Answer in integer) 1001: i = 1 1002: j = 1 1003: t1 = 10*i 1004: t2 = t1+j 1005: t3 = 8*t2 1006: t4 = t3-88 1007: a[t4] = 0.0 1008: j = j+1 1009: if j

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.