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

range-op-float: Fix inf handling in float to float cast.

Correctly handles infinity in reverse narrowing float-to-float casts, fixing miscompilations.

This change corrects how GCC handles infinity in reverse narrowing floating-point to floating-point casts. Previously, specific infinity range representations like [-inf, -inf] were not widened correctly, leading to miscompilations for certain conversions (e.g., double to float). The fix ensures these ranges are handled more precisely, especially when dealing with the limits of representable numbers.

In Details

The range-op-float pass handles range analysis for floating-point operations. When widening a narrowed float-to-float cast (e.g., double to float), if the input range is a singleton infinity (e.g., [-inf, -inf]), the widening code in float_widen_lhs_range incorrectly treated it as a simple extension. This change modifies float_widen_lhs_range to accept an also_inf flag, allowing correct widening of infinite bounds, addressing PR126464.

For Context
range-op-float
A compiler pass in GCC that analyzes and optimizes operations involving floating-point numbers by tracking their possible value ranges.
ULP
Unit in the Last Place. It represents the smallest change in a floating-point number's representation. Extensions are often measured in fractions or multiples of an ULP.
Filed Under: optimizationfloat