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

Convert int to float casts to sub-ranges

Integer to float casts now correctly handle sub-ranges for more accurate floating-point range analysis.

GCC’s range analysis for floating-point operations now correctly handles integer-to-float casts by processing each sub-range of the integer type individually. Previously, operator_cast::fold_range only considered the overall hull of the integer range, potentially leading to inaccuracies. This change improves the precision of floating-point range analysis, especially for complex integer-to-float conversions, and includes a new test case.

In Details

The operator_cast::fold_range function within range-op-float.cc was updated to iterate over and convert each integer sub-range of an input type, rather than just processing the bounding hull. This is essential because an integer range might be composed of multiple disjoint sub-ranges (e.g., due to prior reductions or analyses), and simply widening the hull could lose precision. The new range_op_float_tests verifies this behavior.

For Context
range analysis
A compiler optimization technique that determines the possible range of values an expression can take during runtime. This information can be used to eliminate redundant checks or improve other optimizations.
sub-ranges
In the context of range analysis, if a variable's possible values are not contiguous, they can be represented as a union of multiple disjoint ranges, known as sub-ranges.
operator_cast::fold_range
A specific function within GCC's range analysis framework responsible for calculating the resulting range after a type cast operation.
hull
The smallest convex set containing a given set of points. In range analysis, it typically refers to the minimum and maximum values of a range.
Filed Under: optimizationfloating-pointcompiler