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)?
- A. the block starting at statement 7
- B. the block starting at statement 1
- C. the block starting at statement 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
- The statement r = ((x y) + (y x)) ((x y) − z) + (z − x y) is turned into a DAG (+ and commutative, − not), and code is generated with one…
- For the grammar S → a A | A b; A → c | ε, what is FOLLOW(A)?
- For S′ → S; S → A A A; A → a A | b, how many states of the canonical LR(1) automaton contain the complete item A → b · ?
- int f(int k) { if (k <= 0) return 0; return g(k - 1) + 1; } int g(int k) { if (k <= 1) return 1; return f(k - 2) + f(k - 1); } During the…
- After applying left factoring repeatedly (each time extracting the longest common prefix of alternatives that share a first symbol…
- A DAG is built for r = (p − q) (p − q) + (q − p) (p − q) − (p − q), with commutative and − not commutative. How many interior (operator)…