GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
vn

VN: Fix infinite recursion in insert_predicates_for_cond for `a != 0`.

Fixes infinite recursion in Value Numbering's predicate insertion for `a != 0` comparisons.

A fix has been implemented for infinite recursion in the insert_predicates_for_cond function within the Value Numbering (VN) optimization pass. The issue occurred when handling comparisons like a != 0 where the comparison itself was not canonicalized before testing for recursion. This change adds canonicalization before the recursive check, resolving the infinite loop and preventing related issues, particularly for PR127261.

In Details

The Value Numbering pass's insert_predicates_for_cond function in tree-ssa-sccvn.cc suffered from infinite recursion due to a prior fix (PR 117859) not robustly handling comparisons like c15_30 = g24_a1.3_8 != c14_12; when _8 was valueized to 0 and _12 to _30. The problem arose because the comparison canonicalization happened *after* the recursive predicate insertion test. This commit introduces canonicalization *before* the test, ensuring that changes in the comparison result are correctly detected and preventing the recursion.

For Context
Value Numbering (VN)
An optimization technique that identifies and replaces redundant computations by assigning unique numbers (values) to expressions.
predicate
A condition or boolean expression used to control program flow or assert properties.
canonicalization
The process of transforming an expression into a standard or canonical form, making it easier to compare and identify redundancies.
recursion
A programming technique where a function calls itself. In this context, it refers to a loop-like behavior in the analysis.
SSA
Static Single Assignment form. An intermediate representation where every variable is assigned exactly once, simplifying many analyses and optimizations.
Filed Under: vnoptimizationvalue-numberingrecursion