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

Use !contains_zero_p for known nonzero tests.

Replaced `nonzero_p` with `!contains_zero_p` for clarity in nonzero range checks.

This commit updates several parts of the GCC compiler to use !contains_zero_p instead of the nonzero_p function for checks related to ranges that exclude zero. The nonzero_p function was not always precise, as it returned false for ranges like [1, 5], which do not contain zero but also do not represent all non-zero values. Using !contains_zero_p provides a more accurate and direct representation of the intended condition.

In Details

Several call sites across GCC, including gimple-range-path.cc, tree-ssa-structalias.cc, tree-ssanames.cc, tree-vrp.cc, and region-model.cc, have replaced calls to nonzero_p() with !contains_zero_p(). This change clarifies the intent of these checks, which were previously ambiguously using nonzero_p() to ascertain if a range *excludes* zero, rather than strictly checking if it *only* contains non-zero values. The new predicate accurately reflects the condition of zero exclusion.

For Context
nonzero_p
A predicate function that previously indicated whether a given range of values excluded zero. Its behavior was sometimes ambiguous and has been superseded by more precise checks.
contains_zero_p
A predicate function that checks if a given range of values includes zero. This provides a clearer and more direct check for the presence of zero within a range compared to the removed nonzero_p function.
range
In the context of compiler optimization, a range represents the set of possible values that a variable or expression can take. This can be a continuous interval (e.g., [0, 10]) or a specific set of values.
GIMPLE
GCC's internal representation for performing optimizations. It's a three-address intermediate representation that lies between the language-specific parse tree and the machine-specific code generation.
Filed Under: optimizationrefactor