Loading the code workspace…
Implement dead code elimination on the AST.
Detect and remove unreachable code:
Detect and remove dead stores:
Remove empty statements:
{}Handle control flow:
if (false) A else B → Bif (true) A else B → Awhile (false) {...} → remove entirelyPreserve code with side effects:
DCE is why tree-shaking works in webpack and Rollup, shrinking JavaScript bundles by megabytes, and why LLVM can delete entire branches guarded by constant conditions. It is also famously dangerous: compilers eliminating 'dead' memset calls that cleared passwords caused real CVEs and led to explicit_bzero.