GATE Computer ScienceModerateGATE CS (PYQ pattern)

In 1: a = 1; 2: b = 2; 3: if p > 0 goto L1; 4: a = a + 1; 5: goto L2; 6: L1: b = b + 1; 7: L2: c = a + b; 8: if c > q goto L3; 9: a = c; 10: goto L2; 11: L3: return a, which block is the immediate dominator of the block L3 (statement 11, return a)?

  1. A. the block starting at statement 7
  2. B. the block starting at statement 1
  3. C. the block starting at statement 4
  4. D. the block starting at statement 9

Correct answer: A. the block starting at statement 7

L3 is only reached from the test 'if c > q' that ends the L2 block, so that block is the closest dominator.

More Compiler Design questions

Exams that ask this topic