Questions: Common Subexpression Elimination (CSE)

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Two control flow paths converge at point P. On path A, the expression 'a + b' is computed and neither operand is modified before reaching P. On path B, 'a' is reassigned before P, and 'a + b' is not recomputed after the assignment. Can CSE safely reuse the result of 'a + b' at point P?

AYes — 'a + b' was computed on at least one incoming path, so it is available
BNo — available expressions analysis requires the expression to be computed on ALL incoming paths with operands unchanged since their last computation
CYes — the compiler can substitute the known new value of 'a' to compute a corrected result
DIt depends on which path the program takes at runtime, so the compiler must insert a runtime check
Question 2 Multiple Choice

A compiler performs available expressions analysis at a join point where 'x * y' is available on one incoming control flow edge but not the other. What does the analysis conclude?

A'x * y' is available — availability on any path is sufficient to justify reuse
B'x * y' is not available — intersection requires availability on ALL paths before reuse is safe
C'x * y' may be available depending on the loop iteration count
D'x * y' is available only if 'x' and 'y' are loop-invariant variables
Question 3 True / False

Local CSE and global CSE differ primarily in scale — both rely on the same underlying dataflow analysis, applied to a larger or smaller region of code.

TTrue
FFalse
Question 4 True / False

The kill set for available expressions analysis at a statement that assigns to variable 'x' includes all expressions in the program that contain 'x' as an operand.

TTrue
FFalse
Question 5 Short Answer

Why does global CSE use intersection (not union) at join points in the available expressions dataflow analysis? What would go wrong if union were used?

Think about your answer, then reveal below.