GATE Computer ScienceVery hardGATE CS (PYQ pattern)

SSA form is built for 1: i = 0; 2: L1: if i >= n goto L4; 3: if i > k goto L2; 4: x = i * 2; 5: goto L3; 6: L2: x = i + 1; 7: y = x; 8: L3: i = i + 1; 9: goto L1; 10: L4: return x. How many φ-functions does minimal SSA without pruning place, and how many does pruned SSA place (a φ only where the variable is live on entry to the block)?

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

Correct answer: B. 5 unpruned, 3 pruned

Blocks: {1}, {2}, {3}, {4, 5}, {6, 7}, {8, 9}, {10}. x and y are defined in the two arms, whose dominance frontier is L3 {8, 9}; L3's frontier is the header L1 {2}. i is defined in the entry and in L3, so its φ goes at L1. Unpruned: x at L3 and L1, y at L3 and L1, i at L1 = 5. y is never used, so it is not live anywhere: drop its 2 φ's; x is live at L3 and at L1 (return x after the loop): pruned = 3.

More Compiler Design questions

Exams that ask this topic