IT lexicon › Programming › Redundant load elimination

Redundant load elimination

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

The optimization that replaces a memory read with a value the compiler already holds in a register, once it can prove the memory hasn't changed since.

If code reads p->x twice with a write to q->y in between, the second read is redundant — provided q->y can't be the same memory. Alias analysis answers that question, and the optimization lives or dies by its answer. The same reasoning covers a read right after a write to the same address: the stored value can be forwarded without the round trip through memory.

It is the mirror image of dead store elimination, which removes writes nobody reads. In LLVM the work falls mostly to the GVN pass, backed by MemorySSA. A call to an unknown function is the usual roadblock, since in the worst case it writes everywhere — which is why mod/ref information about functions is worth so much.

← Back to the lexicon