Skip to main content

GATE CSE 2026Compiler Design › Code Optimization & Register AllocationVerified

GATE CSE 2026 PYQ: Consider the control flow graph shown in the figure. Which one of the following options correctly lists the…

Consider the control flow graph shown in the figure.
 

GATE CSE 2026 Code Optimization & Register Allocation diagram: Consider the control flow graph shown in the figure. Which o

Which one of the following options correctly lists the set of redundant expressions (common subexpressions) in the basic blocks B4 and B5?

Note: All the variables are integers.

  1. A
    B4: {b+i}\{b+i\}               B5: {c+m}\{c+m\}
  2. B
    B4: {g∗k}\{g * k\}             B5: {c+m}\{c+m\}
  3. C
    B4: {g∗k,b+i}\{g * k, b+i\}      B5:{\{ }\}
  4. D
    B4: {g∗k}\{g * k\}             B5:{\{ }\}
    Correct answer

Answer

(D) B4: { g ∗ k } \{g * k\} { g ∗ k } B5: { \{ { } \} }

Approach

Use available-expression (redundant-expression) analysis. An expression is redundant at a block if it has already been computed on every path reaching that block and none of its operands have been redefined along those paths. Then check each candidate expression in B4 and B5 against the control-flow paths.

Available-expression analysis shows g*k is evaluated on both paths reaching B4 with unchanged operands, so it is the only redundant expression in B4. b+i and c+m fail because an operand is modified or the expression is not computed on all paths. Hence Option D is correct.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.