GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
tree-optimization Performance Win

FRE optimization improved by avoiding duplicate PHI argument processing

Fixes a bug in FRE optimization where duplicate PHI arguments caused redundant work and potential failures in alias analysis.

This commit is part of a fix for missed FRE optimizations in loops (PR127693). It addresses an issue where get_continuation_for_phi was called with duplicate PHI arguments when walking a backedge with a translated reference. By sorting PHI arguments and processing only unique ones, this patch avoids redundant work and prevents the abort_on_visited flag from tripping incorrectly, thereby enabling more FRE optimizations.

In Details

This commit, related to PR127693, refines the get_continuation_for_phi function in tree-ssa-alias.cc. When processing PHI arguments, especially in the context of walking a backedge with a translated reference (where abort_on_visited is true), duplicate arguments could lead to unnecessary re-computation or premature aborts. The fix introduces sorting of PHI arguments and processing unique pairs, using a new cmp_intpair helper, to prevent redundant work and ensure correctness.

For Context
FRE
Frequently Re-computed Expression, an optimization pass that identifies and hoists expressions computed multiple times within a loop to be computed only once outside the loop.
PHI node
In SSA form, a special node that represents the merging of values from different control flow paths. It takes multiple arguments, each corresponding to a predecessor block.
SSA (Static Single Assignment)
An intermediate representation form used by compilers where each variable is assigned a value exactly once. This simplifies many data-flow analyses and optimizations.
tree-ssa-alias.cc
The GCC source file implementing alias analysis on the SSA intermediate representation.
get_continuation_for_phi
A function within GCC's alias analysis that determines the correct value for a variable at a PHI node, considering potential aliasing.
Filed Under: optimizationloop optimizationalias analysis