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

Improve tree_expr_nonnegative_p by using the ranger [PR111959]

Enhances GCC's non-negative expression checking by integrating range analysis for better optimization.

GCC’s tree_single_nonnegative_p function is improved by utilizing the range analysis information provided by the ranger. This change aims to make the check for non-negative expressions more accurate and efficient, potentially leading to better optimization opportunities. A test case that would always fail due to the improved analysis has been removed.

In Details

Updates tree_single_nonnegative_p in fold-const.cc to leverage the ranger's capabilities via get_range_query. This provides more precise information about SSA_NAME ranges, improving the accuracy of non-negative checks. The change addresses issues with recursive checks and integrates existing range analysis more effectively into constant folding and other optimization passes that depend on value ranges. A testcase (g++.dg/ipa/pure-const-3.C) was removed as it became unsatisfiable due to the enhanced analysis.

For Context
ranger
A component within GCC that performs range analysis on variables and expressions, determining the possible minimum and maximum values they can hold during program execution. This information is used by various optimization passes.
tree_single_nonnegative_p
A GCC internal function that determines if a given tree expression is guaranteed to be non-negative. This version is updated to use range analysis for improved accuracy.
SSA_NAME
Static Single Assignment form. In SSA, each variable is assigned a value only once. SSA_NAME refers to a specific definition of a variable in SSA form, often used in optimization passes.
optimization passes
Individual stages within the compiler's optimization pipeline that perform specific transformations to improve code efficiency (e.g., constant folding, dead code elimination, loop unrolling).
Filed Under: optimizationrange analysis