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

tree-optimization/129064 - value-number PHIs of a block in parallel

Improves value-numbering termination for complex PHI cycles in GCC's SSA form.

This commit fixes a non-termination issue in GCC’s SSA value-numbering pass when encountering PHI cycles. Previously, PHIs were processed sequentially, allowing one cycle to advance ahead of an equivalent one, leading to oscillations and failure to converge. The fix modifies the process to value-number all PHIs in a block based on their prior values, committing the results only after all PHIs are visited. This change aligns with the parallel execution semantics of PHIs and ensures correct termination.

In Details

The process_bb function in tree-ssa-sccvn.cc previously iterated and committed value-numbering results for PHIs sequentially within a basic block. This approach could lead to non-termination for PHI cycles, especially when multiple equivalent cycles existed. A PHI argument coming from a backedge, if it was the result of a PHI already processed in the same block, would see an updated value, while a later PHI might see an old value. This commit changes process_bb to value-number all PHIs in a block based on the previous values of their arguments, and then commit the new values collectivel…

For Context
PHI node
In Static Single Assignment (SSA) form, a PHI node is an instruction that denotes the selection of one of several values based on the control flow path taken to reach the instruction. It's used to merge values from different preceding basic blocks.
value-numbering
An optimization technique that assigns unique numbers to equivalent expressions or values within a program's intermediate representation, allowing the compiler to identify and eliminate redundant computations.
SSA form
Static Single Assignment form. An intermediate representation where every variable is assigned exactly once. PHI nodes are used to handle control flow merging.
basic block
A sequence of instructions with a single entry point and a single exit point, where control flow does not branch except at the very end.
CSE
Common Subexpression Elimination. An optimization that identifies and removes redundant occurrences of the same expression in code.
Filed Under: optimizationssatree-optimizationcompiler-bug