GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Minimal SSA form (φ-functions placed at the iterated dominance frontier of each variable's definition blocks, without liveness pruning, and counting variables defined in at least one block) is built for the code 1: x = 0; 2: y = 1; 3: L1: if x > n goto L4; 4: if y > m goto L2; 5: y = y + x; 6: goto L3; 7: L2: x = x + 2; 8: L3: x = x + 1; 9: goto L1; 10: L4: return y. How many φ-functions are inserted in total?

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

Correct answer: C. 4

Blocks and dominance frontiers give φ placements x at blocks starting at statements 3,8, y at blocks starting at statements 3,8: 4 φ-functions. Pruning by liveness would leave 4.

More Compiler Design questions

Exams that ask this topic