GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
tree-optimization

tree-optimization: Do not propagate zero to abnormal edges in simple-dce

Fixes dead code elimination to correctly handle PHI nodes on abnormal control flow edges.

This commit corrects a flaw in the simple dead code elimination (DCE) pass that incorrectly propagated zero values to uses of PHI node operands entering from abnormal control flow edges. Such propagation can lead to incorrect optimization results. The fix ensures that PHI definitions on abnormal edges are preserved, preventing faulty dead code elimination and maintaining program correctness.

In Details

The simple_dce_from_worklist function in tree-ssa-dce.cc has been updated to prevent propagation of zero constants to PHI node arguments that originate from abnormal control flow edges. This addresses a bug where DCE would incorrectly simplify code by replacing such defs with constants, potentially altering program semantics. The change ensures PHI defs on abnormal edges are correctly handled, aligning with SSA invariants.

For Context
simple-dce
A component of GCC's dead code elimination (DCE) pass that operates on the Static Single Assignment (SSA) form of the code. It identifies and removes code that has no effect on the program's output.
PHI node
In Static Single Assignment (SSA) form, a PHI node is a special instruction that merges values from different control flow paths. It takes multiple arguments, each corresponding to a different predecessor block, and produces a single result. PHI(arg1, arg2, ...) selects argN if control flow comes from the Nth predecessor block.
abnormal edge
In control flow graphs, an abnormal edge typically refers to a control flow transfer that is not part of the standard sequential execution or typical conditional branching. Examples include exceptions, long jumps, or non-local exits.
SSA
Static Single Assignment form is an intermediate representation used in compilers where every variable is assigned a value exactly once. This simplifies many optimization passes, including dead code elimination, by making data flow explicit.
Filed Under: tree-optimizationgccdcessa