Compilers
What does dead-code elimination remove?
- AThe code for the most frequently executed, most important part of the program
- BCode that is never executed and computations whose results are never used
- COutput instructions that display results on the screen
Show answer and explanation
Answer: B. Code that is never executed and computations whose results are never used
Dead-code elimination removes code such as the body of a branch whose condition is always false and assignments whose results are never used. Constant propagation and folding leave many such unused assignments behind, so these optimizations are used together. Frequently executed code is precisely what should be made fast, not deleted. Instructions with externally visible effects, such as screen output, are part of the program's result and are kept.
- A. Frequently executed code must not be deleted.
- B. Correct. It removes unexecuted code and unused computations.
- C. Instructions with visible effects are not removed.