GATE Computer ScienceVery hardGATE CS (PYQ pattern)
Minimal SSA form (φ-functions placed at the iterated dominance frontier of each variable's definition blocks, without liveness pruning, and counting variables defined in at least one block) is built for the code 1: x = 0; 2: y = 1; 3: L1: if x > n goto L4; 4: if y > m goto L2; 5: y = y + x; 6: goto L3; 7: L2: x = x + 2; 8: L3: x = x + 1; 9: goto L1; 10: L4: return y. How many φ-functions are inserted in total?
- A. 5
- B. 3
- C. 4
- D. 6
Correct answer: C. 4
Blocks and dominance frontiers give φ placements x at blocks starting at statements 3,8, y at blocks starting at statements 3,8: 4 φ-functions. Pruning by liveness would leave 4.
More Compiler Design questions
- Which of the following about run-time environments is/are true? I. An access (static) link points to the frame of the lexically enclosing…
- For S′ → S; S → S ( S ) | ε, LALR(1) merges canonical LR(1) states with equal cores. The LALR state whose only item is S → S ( S ) · is…
- In 1: i = 0; 2: L1: if i >= n goto L3; 3: i = i + 1; 4: if i > k goto L1; 5: j = j + i; 6: goto L1; 7: L3: return j, how many back edges…
- An SLR(1) shift-reduce parser for E → T E'; E' → + T E' | ε; T → F T'; T' → F T' | ε; F → ( E ) | id parses "id + id id". Each shift and…
- Backpatching scheme (each relation gives 'if r goto ' and 'goto ', no fall-through optimisation, instruction numbers from 100). How many…
- A basic block compiles to six three-address statements: t1 = a + b; t2 = c d; t3 = a + b; t4 = t1 t2; t5 = t3 − t4; x = t5. Value…