GATE Computer ScienceHardGATE CS (PYQ pattern)
A basic block is converted to a DAG using value numbering, treating + and * as commutative, reusing an existing node when the same operator is applied to the same operand nodes, and making a new leaf for each variable's initial value. How many nodes (leaves plus interior nodes) does the DAG of this block have? p = a + b; q = p - c; r = q + p; p = r * r; s = q + p; c = a + b; t = c - q; u = b + a
- A. 10
- B. 8
- C. 11
- D. 9
Correct answer: D. 9
There are 3 leaf nodes (initial values) and 6 interior nodes; a reassigned variable (like a or p) makes later uses refer to a new node, so same-looking expressions after the kill do not share.
More Compiler Design questions
- A web of a variable is a maximal union of def-use chains that share a definition or a use; a register allocator gives each web its own…
- In 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…
- Using the standard backpatching scheme (each relational test yields 'if a<b goto ' followed by 'goto ', with no fall-through optimisation…
- For S → a A | A b; A → c | ε (augmented), how many non-blank ACTION entries does the initial state I0 have in the SLR(1) table, and in the…
- For S → a S | a S b S | c (augmented), how many states does the canonical LR(1) automaton have, and how many ACTION cells of the canonical…
- For G: S → A | B; A → a A b | ε; B → a B b b | ε, which of these statements are true? I. Exactly two cells of the LL(1) table, M[S, a] and…