IT lexicon › Programming › Dead store elimination (DSE)

Dead store elimination (DSE)

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

The optimization that deletes writes to memory when the value is overwritten, or never read, before it goes away.

Two stores to the same address with no load in between mean the first one was pointless. So is a store to a local or a heap object that's about to be freed anyway. The hard part is proving that no other pointer reads the memory in the meantime, so the pass lives and dies by alias analysis. Unlike ordinary dead code elimination, it's about memory, not registers and SSA values.

Its famous side effect lands on security code. Zeroing a password with memset just before free is, as far as the language standard is concerned, a dead store, and the compiler removes it with a clear conscience. That's why explicit_bzero, memset_s and Windows' SecureZeroMemory exist — functions whose entire job is to not get optimized away.

← Back to the lexicon