Skip to content
Official PYQ · 2026

GATE CS 2026 Set 2 Q35 — Local Optimization

Explain with AI

Consider the control flow graph given below.

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

Choose one option
View worked solution

Answer: A

Live variable analysis is a backward data-flow analysis. A variable is said to be live at a given point if there is a path from that point to a use of the variable along which the variable is not redefined.

The data-flow equations for any basic block BB are:

out[B]=⋃S∈succ(B)in[S]\text{out}[B] = \bigcup_{S \in \text{succ}(B)} \text{in}[S]in[B]=use[B]∪(out[B]∖def[B])\text{in}[B] = \text{use}[B] \cup (\text{out}[B] \setminus \text{def}[B])

Applying these equations backward from the exit block:

  • Block B4: Since B4 is the exit block of the program, no variables are live at its exit. Thus, out[B4]=∅\text{out}[\mathrm{B4}] = \varnothing.
  • Block B2: The variables dd and ee are propagated from its successors, giving out[B2]={d,e}\text{out}[\mathrm{B2}] = \{\mathrm{d}, \mathrm{e}\}.
  • Block B3: Due to the loop back to the preceding blocks where bb is used before being redefined, the variable bb remains live at the exit of B3 along with c,e,fc, e, f. Thus, out[B3]={b,c,e,f}\text{out}[\mathrm{B3}] = \{\mathrm{b}, \mathrm{c}, \mathrm{e}, \mathrm{f}\}.
  • Block B1: The union of the live-in variables of its successors B2 and B3 gives out[B1]={a,b,c,e,f}\text{out}[\mathrm{B1}] = \{\mathrm{a}, \mathrm{b}, \mathrm{c}, \mathrm{e}, \mathrm{f}\}.

This matches the sets given in Option A.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Local Optimization questions