GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Minimal SSA form (φ-functions at the iterated dominance frontier of each variable's defining blocks, no pruning) is built for 1: x = 1; 2: y = 0; 3: L1: if y > n goto L3; 4: if x > 5 goto L2; 5: x = x * 2; 6: L2: y = y + x; 7: x = y - 1; 8: if y < m goto L1; 9: x = 0; 10: L3: return x. How many φ-functions are placed for x, and how many for y?

  1. A. 2 for x, 2 for y
  2. B. 3 for x, 1 for y
  3. C. 3 for x, 2 for y
  4. D. 4 for x, 2 for y

Correct answer: C. 3 for x, 2 for y

Blocks: {1,2}, {3} (L1), {4}, {5}, {6,7,8} (L2), {9}, {10} (L3). DF({5}) = {L2}; DF(L2) = {L1, L3}; DF({9}) = {L3}. x is assigned in {1,2}, {5}, L2 and {9}: φ at L2, then L1 and L3 — 3. y is assigned in {1,2} and L2: φ at L1 and L3 — 2.

More Compiler Design questions

Exams that ask this topic