GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Minimal SSA form is built for 1: if p > 0 goto L2; 2: L1: x = x + 1; 3: if x > n goto L3; 4: L2: y = y + x; 5: if y < m goto L1; 6: L3: return y (blocks B0 = {1}, B1 = {2, 3}, B2 = {4, 5}, B3 = {6}). How many φ-functions are placed by the unpruned (iterated dominance frontier) algorithm, and how many remain in pruned SSA (a φ only where the variable is live on entry)?
- A. 6 unpruned, 5 pruned
- B. 4 unpruned, 4 pruned
- C. 6 unpruned, 4 pruned
- D. 2 unpruned, 2 pruned
Correct answer: A. 6 unpruned, 5 pruned
B1 and B2 are both entered from B0, so idom(B1) = idom(B2) = idom(B3) = B0, and DF(B1) = {B2, B3}, DF(B2) = {B1, B3}. x is defined in B1: φ at B2 and B3, then from DF(B2) at B1 — 3 φ's; y is defined in B2: likewise B1, B3, B2 — 3 φ's. Total 6. At B3 only y is live (return y), so the φ for x there is pruned: 5.
More Compiler Design questions
- L is the set of strings over {a, b} that contain abab as a substring but do not end with abab. How many states does the minimal complete…
- An LR parser for E → T E′; E′ → + T E′ | ε; T → F T′; T′ → F T′ | ε; F → ( E ) | id parses "id + id id". How many reductions does it make…
- For each choice of terminals x, y ∈ {a, b, c} consider G(x, y): S → A x B; A → a A | ε; B → b B | y. Of the nine grammars, how many are…
- The grammar S → a S | S a | b is ambiguous. How many distinct parse trees does the string "a a a b a a" have?
- For S → b A d | c A e | b B e; A → x; B → x (augmented), how many ACTION cells of the SLR(1) table are multiply defined, and how many…
- Procedures are nested as follows: main contains P (nesting depth 2); P contains Q (depth 3) and S (depth 3); Q contains R (depth 4)…