GATE Computer ScienceHardGATE CS

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 in indirect-triples form: a triple table plus an instruction list of pointers into it. Counting every row of both tables, how many entries are stored?

  1. A. 8
  2. B. 10
  3. C. 12
  4. D. 6

Correct answer: A. 8

With sharing the operations are (0) uminus c, (1) * b, (0), (2) + (1), (1), and (3) = a, (2): 4 triples. The instruction list holds one pointer per triple, 4 more: 4 + 4 = 8. Without sharing there would be 6 triples and 6 pointers, 12 rows.

More Compiler Design questions

Exams that ask this topic