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

Floating-point range analysis now represents and handles inverse constant ranges.

GCC's floating-point range analysis can now represent intervals that exclude specific values, improving precision.

This commit enhances GCC’s floating-point range analysis (frange) to correctly represent the inverse of a constant range. Previously, attempts to exclude a value were lost, turning into a generic ‘varying’ range. The update allows frange to store intervals like x != C by representing them as two sub-ranges, bringing it to parity with other analysis methods and improving the compiler’s ability to optimize code involving inequalities.

In Details

The frange class in value-range.cc now supports set_excluding, enabling the representation of intervals that exclude specific points. This is achieved by transforming an exclusion request (e.g., set(type, C, C, VR_ANTI_RANGE)) into two explicit sub-ranges: [-INF, prev(C)] and [next(C), +INF]. This capability is crucial for precisely handling inequalities like x != C and brings the floating-point value-range propagation (VRP) analysis in line with integer VRP and DOM analysis, particularly benefiting floating-point intensive code like LAPACK.

For Context
frange
Represents a range of floating-point values within GCC's value-range propagation (VRP) analysis. It's part of the compiler's effort to understand and optimize numerical computations.
value-range propagation (VRP)
A compiler optimization technique that tracks the possible range of values a variable can hold throughout the program to enable more aggressive optimizations.
inverse range
A mathematical representation of all values *not* within a specified range. For example, the inverse of the range [2, 5] would be (-infinity, 2) U (5, +infinity).
VR_ANTI_RANGE
A flag used in GCC's value-range analysis to signify the inverse of a normal range, often used to represent exclusion of specific values or sets of values.
VR_VARYING
A state in GCC's value-range analysis indicating that the range of possible values for a variable is too complex or unpredictable to determine precisely.
prev() and next()
Functions that return the representable floating-point number immediately preceding or succeeding a given value, respectively. Crucial for defining bounds of excluded intervals.
Filed Under: optimizationfloating-pointcompiler internalsrange analysis