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

Fix float_widen_lhs_range for float range operations

Corrected float range widening to prevent overflows and ensure valid range calculations in floating-point operations.

The float_widen_lhs_range function in GCC’s floating-point range analysis has been fixed to prevent potential overflows when extending ranges. The function now correctly handles cases where it’s called with significand bits, ensuring that the widened range remains valid. This change rectifies issues in optimizations like PR109008 and improves the robustness of floating-point range operations, especially when interacting with frange_nextafter.

In Details

The float_widen_lhs_range function, previously a standalone utility, has been converted into a frange method. This refactoring addresses an overflow issue where passing SIGNIFICANT_BITS could lead to an excessively large extension of a floating-point range. The new wlhs.widen(type) method provides a more controlled widening, preventing the incorrect propagation of extreme values that previously caused problems with functions like frange_nextafter in reverse operations.

For Context
float_widen_lhs_range
A GCC internal function used in floating-point range analysis to slightly extend a given floating-point range. This extension is intended to accommodate potential inaccuracies or representational differences during subsequent calculations.
frange
GCC's internal representation and analysis framework for floating-point values, often used to track ranges of possible values for expressions.
frange_nextafter
A function within GCC's floating-point range analysis that determines the next representable floating-point number after a given value. It's crucial for accurately representing the boundaries of computed ranges.
PR109008
A GCC bug report related to a specific optimization that was affected by issues in floating-point range handling.
ulp
Unit in the Last Place. Refers to the smallest possible change in the least significant bit of a floating-point number. ULP-based extensions are common in floating-point error analysis.
Filed Under: optimizationfloating-pointcompiler