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?

  1. A. {a+b}
  2. B. {a+b, c+d}
  3. C. {c+d, a*b}
  4. 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

Exams that ask this topic