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 B and B?
Note: All the variables are integers.
View worked solution
Answer: D
An expression is a redundant (common) subexpression at a basic block if it is guaranteed to be previously computed along all paths leading to that block, and none of its operand variables have been modified since their last computation (i.e., the expression is available).
Analyzing the control flow graph:
- At Basic Block B4: The expression is computed in and its operands and are not modified along any path leading to . Thus, is redundant. However, is not redundant because is modified in block along the path , killing the expression.
- At Basic Block B5: The expression is not redundant because is modified in block along the path , killing the expression. Thus, the set of redundant expressions at is empty, i.e., .
Therefore, the correct option is D.
Free practice · Your answers on this page are not saved.
