GATE Computer ScienceHardGATE CS (PYQ pattern)

Minimal SSA form without liveness pruning (φ-functions at the iterated dominance frontier of every block that assigns the variable) is built for the swap loop 1: a = 1; 2: b = 2; 3: L1: if a > n goto L2; 4: t = a; 5: a = b; 6: b = t; 7: goto L1; 8: L2: return a. How many φ-functions are placed?

  1. A. 2
  2. B. 4
  3. C. 1
  4. D. 3

Correct answer: D. 3

Blocks: {1, 2}, {3} (header L1), {4–7}, {8}. The loop body assigns a, b and t, and its dominance frontier is the header L1, so each of the three variables gets a φ there: 3. Only a and b are live at L1; pruned SSA would drop t's φ and keep 2.

More Compiler Design questions

Exams that ask this topic