Skip to main content

GATE CSE 2026Compiler Design › Code Optimization & Register AllocationVerified

GATE CSE 2026 PYQ: Consider the control flow graph given below. Which one of the following options is the set of live variables…

Consider the control flow graph given below.

GATE CSE 2026 Code Optimization & Register Allocation diagram: Consider the control flow graph given below. Which one of th

Which one of the following options is the set of live variables at the exit point of each basic block?

  1. A
    B1:{a,b,c,e,f},B2:{d,e},B3:{b,c,e,f},B4:∅\mathrm{B} 1:\{\mathrm{a}, \mathrm{b}, \mathrm{c}, \mathrm{e}, \mathrm{f}\}, \mathrm{B} 2:\{\mathrm{d}, \mathrm{e}\}, \mathrm{B} 3:\{\mathrm{b}, \mathrm{c}, \mathrm{e}, \mathrm{f}\}, \mathrm{B} 4: \varnothing
    Correct answer
  2. B
    B1\mathrm{B} 1: ∅\varnothing, B2\mathrm{B} 2: {\{ d, e }\}, B3\mathrm{B} 3: {\{ a, c, f }\}, B4\mathrm{B} 4: ∅\varnothing
  3. C
    B1:{a,b,c,e,f},B2:{d,e},B3:{c,e,f},B4:∅\mathrm{B} 1:\{\mathrm{a}, \mathrm{b}, \mathrm{c}, \mathrm{e}, \mathrm{f}\}, \mathrm{B} 2:\{\mathrm{d}, \mathrm{e}\}, \mathrm{B} 3:\{\mathrm{c}, \mathrm{e}, \mathrm{f}\}, \mathrm{B} 4: \varnothing
  4. D
    B1:∅,B2:{d,e,f},B3:{a,b,c,e,f},B4:∅\mathrm{B} 1: \varnothing, \mathrm{B} 2:\{\mathrm{d}, \mathrm{e}, \mathrm{f}\}, \mathrm{B} 3:\{\mathrm{a}, \mathrm{b}, \mathrm{c}, \mathrm{e}, \mathrm{f}\}, \mathrm{B} 4: \varnothing

Answer

(A) B 1 : { a , b , c , e , f } , B 2 : { d , e } , B 3 : { b , c , e , f } , B 4 : ∅ \mathrm{B} 1:\{\mathrm{a}, \mathrm{b}, \mathrm{c}, \mathrm{e}, \mathrm{f}\}, \mathrm{B} 2:\{\mathrm{d}, \mathrm{e}\}, \mathrm{B} 3:\{\mathrm{b}, \mathrm{c}, \mathrm{e}, \mathrm{f}\}, \mathrm{B} 4: \varnothing B 1 : { a , b , c , e , f } , B 2 : { d , e } , B 3 : { b , c , e , f } , B 4 : ∅

Approach

Perform live variable analysis, a backward data-flow analysis. For each basic block n, compute OUT[n] = union of IN[succ(n)] and IN[n] = USE[n] ∪ (OUT[n] − DEF[n]). Iterate to a fixed point because of the cycle between B1 and B3. A variable is live at a basic block exit if there exists a path from that exit to a use of the variable before any redefinition.

The live variable analysis yields the sets B1:{a,b,c,e,f}, B2:{d,e}, B3:{b,c,e,f}, B4:∅, which exactly matches option A.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.