GATE Computer ScienceHardGATE CSE · UGC NET

A basic block is: t1 = a + b; t2 = a − b; t3 = t1 * t2; t4 = a + b; t5 = t4 * t2; t6 = t3 + t5; y = t6 / t3. How many nodes (leaves included) does its DAG have?

  1. A. 6
  2. B. 7
  3. C. 8
  4. D. 9

Correct answer: B. 7

Leaves a and b (2); a+b (shared by t1 and t4), a−b, (a+b)*(a−b) (shared by t3 and t5), t3 + t3 and the final division: 5 operator nodes, total 7.

More Compiler Design questions

Exams that ask this topic