GATE Computer ScienceHardGATE CS · ISRO
After local common-subexpression elimination, algebraic simplification (x + 0, x * 1), copy propagation and dead-code elimination, how many instructions remain in: t1 = a + b; t2 = a + b; t3 = t1 * t2; t4 = t3 + 0; t5 = t4 * 1; t6 = c * 2; x = t5 (only x is live at the end)?
- A. 3
- B. 4
- C. 2
- D. 5
Correct answer: C. 2
t2 is the same as t1, so t3 = t1 * t1; t4 and t5 equal t3, so x = t3; t6 is dead. What remains is t1 = a + b and x = t1 * t1: 2 instructions.
More Compiler Design questions
- Left factoring is applied to A → a b c | a b d | a e | f, and the shared prefixes are factored as far as possible, with new non-terminals…
- How many cells of the LL(1) parsing table of E → T E′; E′ → + T E′ | ε; T → F T′; T′ → F T′ | ε; F → ( E ) | id contain a production?…
- How many states does the canonical LR(0) collection of the augmented grammar S′ → S; S → a S b | a b have, and how many of them have a…
- For E → E + T | T; T → T F | F; F → ( E ) | id, how many LR(0) states have a conflict that is resolved by the SLR(1) FOLLOW-set check…
- How many distinct strings of length at most 6 (including the empty string) are generated by the grammar S → ( S ) | S S | ε?
- For the ambiguous grammar S → S S | a, how many distinct parse trees does the string aaaaaa (six a's) have?