Skip to main content

GATE CSE 2023Compiler Design › Code Optimization & Register AllocationVerified

GATE CSE 2023 PYQ: Consider the control flow graph shown. Which one of the following choices correctly lists the set of live…

Consider the control flow graph shown.

GATE CSE 2023 Code Optimization & Register Allocation diagram: Consider the control flow graph shown. Which one of the foll

Which one of the following choices correctly lists the set of live variables at the exit point of each basic block?

  1. A
    B1:  , B2: a, B3: a, B4: a\text{B1: { }, B2: {a}, B3: {a}, B4: {a}}
  2. B
    B1: i, j, B2: a, B3: a, B4: i\text{B1: {i, j}, B2: {a}, B3: {a}, B4: {i}}
  3. C
    B1: a, i, j, B2: a, i, j, B3: a, i, B4: a\text{B1: {a, i, j}, B2: {a, i, j}, B3: {a, i}, B4: {a}}
  4. D
    B1: a, i, j, B2: a, j, B3: a, j, B4: a, i, j\text{B1: {a, i, j}, B2: {a, j}, B3: {a, j}, B4: {a, i, j}}
    Correct answer

Answer

(D) B1: a, i, j, B2: a, j, B3: a, j, B4: a, i, j \text{B1: {a, i, j}, B2: {a, j}, B3: {a, j}, B4: {a, i, j}} B1: a, i, j , B2: a, j , B3: a, j , B4: a, i, j

Approach

Compute live-variable sets using standard backward data-flow equations. At each block, OUT is the union of IN sets of successor blocks; IN is USE ∪ (OUT − DEF). Iterate until the OUT sets stabilize. The question asks for OUT[B] at each basic block.

The standard liveness analysis reaches a fixed point after three passes. The final OUT sets are B1:{a,i,j}, B2:{a,j}, B3:{a,j}, B4:{a,i,j}. Therefore option D is correct.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.