GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Minimal SSA form is built for 1: if p > 0 goto L2; 2: L1: x = x + 1; 3: if x > n goto L3; 4: L2: y = y + x; 5: if y < m goto L1; 6: L3: return y (blocks B0 = {1}, B1 = {2, 3}, B2 = {4, 5}, B3 = {6}). How many φ-functions are placed by the unpruned (iterated dominance frontier) algorithm, and how many remain in pruned SSA (a φ only where the variable is live on entry)?

  1. A. 6 unpruned, 5 pruned
  2. B. 4 unpruned, 4 pruned
  3. C. 6 unpruned, 4 pruned
  4. D. 2 unpruned, 2 pruned

Correct answer: A. 6 unpruned, 5 pruned

B1 and B2 are both entered from B0, so idom(B1) = idom(B2) = idom(B3) = B0, and DF(B1) = {B2, B3}, DF(B2) = {B1, B3}. x is defined in B1: φ at B2 and B3, then from DF(B2) at B1 — 3 φ's; y is defined in B2: likewise B1, B3, B2 — 3 φ's. Total 6. At B3 only y is live (return y), so the φ for x there is pruned: 5.

More Compiler Design questions

Exams that ask this topic