← 🚀 Code Optimisation & Data-Flow
Subtopic 2 of 7

9.2Common subexpression elimination

If an expression was already computed and its operands have not changed, reuse the earlier value. Detected by the DAG or by available expressions analysis.

  • t1 = a + b computed
  • c = t1 * 2
  • t2 = a + b SAME expression, a and b unchanged
  • d = t2 - c

4 instructions.

Previous year questions: Code Optimisation & Data-Flow (3)

PYQs are grouped by topic, so this is the full set for Code Optimisation & Data-Flow; try the ones that match this subtopic. Open all 3 on the topic page.