Questions: Value Numbering and Redundancy Elimination

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A basic block contains: `t1 = a + b`, then `a = 5`, then `t2 = a + b`. Will local value numbering mark t2 as redundant and replace it with a copy of t1?

AYes — t2 and t1 both compute a + b, so they receive the same value number and t2 is eliminated.
BNo — the assignment `a = 5` gives `a` a new value number, so the (operator, VN(a), VN(b)) key for t2 differs from t1's key, and t2 is not redundant.
CYes — but only after a dataflow analysis pass confirms that `a` holds the same value at both points.
DNo — value numbering only works for multiplications and divisions, not additions.
Question 2 Multiple Choice

Which of the following optimizations is performed automatically by value numbering without requiring a separate analysis pass?

ALoop unrolling — value numbering detects loop bounds and duplicates loop bodies.
BDead code elimination — value numbering marks unreachable instructions as unused.
CConstant folding — expressions like `3 + 4` receive the value number for the constant 7, and future uses are replaced by 7.
DRegister allocation — value numbering assigns registers based on value lifetimes.
Question 3 True / False

Local value numbering can detect that `t3 = a + b` is redundant — even though it uses different variable names from an earlier `t1 = a + b` — as long as `a` and `b` have not been reassigned in between.

TTrue
FFalse
Question 4 True / False

Value numbering identifies redundant computations by comparing the text of instructions — two computations with different variable names but equal results are seldom detected as equivalent.

TTrue
FFalse
Question 5 Short Answer

Explain how value numbering's hash table approach lets a compiler detect that an expression is redundant in a single forward pass, without re-examining prior instructions.

Think about your answer, then reveal below.