GATE Computer ScienceVery hardGATE CS
An expression is very busy at a point if, along every path from that point, it is evaluated before any of its operands is redefined. Blocks (the targets t1...t10, m, n, p are fresh variables unless they appear as operands): B1: empty; B2: t1 = a+b; t2 = c+d; a = m; B3: t3 = c+d; t4 = a*b; t5 = a+b; B4: t6 = a+b; c = n; B5: t7 = a*b; t8 = a-c; a = p; B6: t9 = c+d; t10 = a+b. Edges: B1→B2, B1→B3, B2→B4, B3→B4, B3→B5, B4→B6, B5→B6; B6 is the exit. Which expressions are very busy on entry to B1?
- A. {a+b}
- B. {a+b, c+d}
- C. {c+d, a*b}
- D. {a+b, a*b, c+d}
Correct answer: B. {a+b, c+d}
Backward must-analysis: IN[B6] = {a+b, c+d}; IN[B4] = {a+b} (c is redefined after a+b, killing c+d); IN[B5] = {a*b, a-c, c+d}; IN[B2] = {a+b, c+d}; IN[B3] = {c+d, a*b, a+b} (OUT[B3] = IN[B4] ∩ IN[B5] = ∅). IN[B1] = IN[B2] ∩ IN[B3] = {a+b, c+d}.
More Compiler Design questions
- A heap holds objects A to J. Roots point to A and E. Pointers: A→B, B→C, B→D, C→B, D→F, E→F, E→I, G→H, H→G, H→J. The root pointer to A is…
- The live ranges (inclusive of both end points, in instruction numbers) of ten variables are [1,8], [2,5], [3,9], [4,6], [7,12], [10,14]…
- Linear-scan register allocation processes the same ten live ranges [1,8], [2,5], [3,9], [4,6], [7,12], [10,14], [11,13], [6,10], [9,15]…
- A syntax-directed translation scheme prints as it reduces: E → T + E { print('+') } | T; T → F T { print('') } | F; F → id {…
- A lexical rule recognises the language (ab | abc | c)(bc | a) over {a, b, c}. How many states does the minimal complete DFA (dead state…
- For the statement a = b (−c) + b (−c), common subexpressions are shared (so −c and b (−c) are each computed once) and the code is stored…