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

Convert operator_abs::fold_range to use sub-ranges

Improves range analysis for absolute value by processing sub-ranges individually.

This commit refactors the operator_abs::fold_range function within GCC’s range analysis to operate on sub-ranges independently. Previously, taking the absolute value of a range could collapse distinct sub-ranges if they spanned across zero. Now, the absolute value is applied to each sub-range, and the results are unioned, preserving gaps and more accurately representing the range’s properties.

In Details

Refactors operator_abs::fold_range in range-op-float.cc to correctly handle multi-valued floating-point ranges. The previous implementation would compute the hull of the range and then take its absolute value, potentially collapsing sub-ranges and losing information about gaps when zero was present. The new implementation applies abs to each constituent sub-range and unions the results, preserving the distinctness of sub-ranges.

For Context
range analysis
A compiler optimization technique that determines the possible range of values a variable or expression can take. This information can enable further optimizations.
sub-ranges
In range analysis, a range may be composed of multiple disjoint intervals, especially when dealing with functions that are not monotonic (like absolute value or negation). These intervals are called sub-ranges.
fold_range
A function within the range analysis framework that computes the resulting range after applying a specific operation (e.g., absolute value, negation) to an input range.
hull
The smallest single interval that completely encloses all values of a given range or set of sub-ranges.
Filed Under: optimizationrange analysisfloating point