IT lexicon › Programming › Dead code elimination

Dead code elimination

Programming På svenska → Updated: 2026-11-05

The optimization that deletes computations nobody uses and code nothing can reach.

Two things usually share the name. Unreachable code has no path to it in the control-flow graph; dead code runs, but nobody reads its result, which liveness analysis reveals. Programmers rarely write either on purpose. It appears when constant folding, inlining and friends turn a branch permanently false or a value redundant, so the pass is mostly cleaning up after the others.

The aggressive variant flips the question: everything is presumed dead until it turns out to affect something observable, such as a memory store or I/O. It is also the optimization most likely to ruin a microbenchmark. A loop computing something nobody uses can vanish entirely, and the measurement proudly reports zero nanoseconds.

← Back to the lexicon