GATE Computer ScienceHardGATE CS (PYQ pattern)
Minimal SSA form without liveness pruning (φ-functions at the iterated dominance frontier of every block that assigns the variable) is built for the swap loop 1: a = 1; 2: b = 2; 3: L1: if a > n goto L2; 4: t = a; 5: a = b; 6: b = t; 7: goto L1; 8: L2: return a. How many φ-functions are placed?
- A. 2
- B. 4
- C. 1
- D. 3
Correct answer: D. 3
Blocks: {1, 2}, {3} (header L1), {4–7}, {8}. The loop body assigns a, b and t, and its dominance frontier is the header L1, so each of the three variables gets a φ there: 3. Only a and b are live at L1; pruned SSA would drop t's φ and keep 2.
More Compiler Design questions
- 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 · ?
- 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…