GATE Computer ScienceHardGATE CS (PYQ pattern)
Expressions are compared textually and an assignment to an operand kills the expressions that use it. Which expressions are available on entry to statement 2 (L1) of 1: t = a + b; 2: L1: if t > n goto L2; 3: u = a + b; 4: a = u - 1; 5: v = a + b; 6: t = v; 7: goto L1; 8: L2: return t?
- A. ∅
- B. {a + b, u − 1}
- C. {u − 1}
- D. {a + b}
Correct answer: D. {a + b}
From the entry, a + b is computed at 1. Around the loop, a = u − 1 at 4 kills a + b, but statement 5 recomputes it after the kill, and nothing later changes a or b. u − 1 is computed only inside the loop, never on the entry path, so the intersection is {a + b}; hence u = a + b at 3 is redundant.
More Compiler Design questions
- A scanner (longest match, ties to the earlier rule) has rules: COMMENT = //[^newline]; STR = "[^"]"; DIV = /; EQ = ==; ASSIGN = =; ID =…
- SDD for S → ( S1 S2 ) | a: the inherited attribute S.n is 1 at the root, and for S → ( S1 S2 ) the rules are S1.n = 2 × S.n and S2.n = 2 ×…
- Minimal SSA form (φ-functions placed at the iterated dominance frontier of each variable's definition blocks, without liveness pruning…
- 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…