GATE CS 2026 Set 1 | Question 42

Compiler Design › Intermediate Code & Code Optimization · MCQ · 2 marks · Answer: D

  1. Question 42Compiler Designmcq2 marks
    Consider the control flow graph shown in the figure. 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.
    GATE CS 2026 Set 1 Question 42 figure
    • A.
      B4: B5:
    • B.
      B4: B5:
    • C.
      B4: B5:
    • D.
      B4: B5:
      ✓

    Answer: D

    Solution

    Answer: (D) An expression is redundant at a point only if it is available on every path reaching that point: computed earlier, with no operand redefined since.
    Expression  | Path via B2                        | Path via B3                    | Redundant?
    ------------+------------------------------------+--------------------------------+-----------
    g * k at B4 | computed (a = g*k), g, k unchanged | computed (t = g*k)             | Yes
    b + i at B4 | available from B1                  | B3 redefines b, which kills it | No
    c + m at B5 | never computed on this path        | computed in B3                 | No
    So B4 has {g*k} and B5 has none. The traps are , killed by in B3, and , which is computed on only one path.

More GATE PYQ on Intermediate Code & Code Optimization

All GATE CS Compiler Design PYQ →

Attempt GATE CS 2026 Set 1 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →