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

Convert frange_add_zeros to use multi-range detection

Fixes floating-point zero handling in range analysis for complex multi-pair ranges.

This commit corrects the frange_add_zeros function in GCC’s floating-point range analysis. Previously, it relied on the range’s hull endpoints to detect the presence of zero, which failed for multi-pair ranges where zero might exist on an internal boundary. The function now uses a contains_zero_p method for more robust detection, ensuring that both positive and negative zero are correctly accounted for.

In Details

Corrects frange_add_zeros in range-op-float.cc to properly handle multi-pair ranges containing zero. The prior implementation incorrectly used the hull endpoints to determine if zero was present, failing when zero was an interior point of a multi-pair range (e.g., [-1.0,-0.0][1.0,1.0]). The fix introduces a contains_zero_p method to accurately detect zero within any sub-range.

For Context
frange_add_zeros
A function in GCC's floating-point range analysis that ensures both +0.0 and -0.0 are represented in the range if zero is a possible value.
multi-range
A representation of a floating-point range that consists of multiple disjoint intervals (pairs of lower and upper bounds), used when a simple single interval is insufficient.
hull
The smallest single interval that completely encloses all values of a given range or set of sub-ranges.
+0.0 and -0.0
Signed zero values in floating-point arithmetic. While numerically equal, their signs can be significant in certain operations and comparisons.
Filed Under: optimizationrange analysisfloating pointzero