GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Minimal SSA form (φ-functions at the iterated dominance frontier of each variable's defining blocks, no pruning) is built for 1: x = 1; 2: y = 0; 3: L1: if y > n goto L3; 4: if x > 5 goto L2; 5: x = x * 2; 6: L2: y = y + x; 7: x = y - 1; 8: if y < m goto L1; 9: x = 0; 10: L3: return x. How many φ-functions are placed for x, and how many for y?
- A. 2 for x, 2 for y
- B. 3 for x, 1 for y
- C. 3 for x, 2 for y
- D. 4 for x, 2 for y
Correct answer: C. 3 for x, 2 for y
Blocks: {1,2}, {3} (L1), {4}, {5}, {6,7,8} (L2), {9}, {10} (L3). DF({5}) = {L2}; DF(L2) = {L1, L3}; DF({9}) = {L3}. x is assigned in {1,2}, {5}, L2 and {9}: φ at L2, then L1 and L3 — 3. y is assigned in {1,2} and L2: φ at L1 and L3 — 2.
More Compiler Design questions
- 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…
- Minimal SSA form without liveness pruning (φ-functions at the iterated dominance frontier of every block that assigns the variable) is…
- 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…
- 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 · ?