GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
tree-optimization

Fix floating-point range comparisons with sub-ranges.

Correctly handles floating-point range equality and inequality checks when sub-ranges are involved.

This change corrects a bug in floating-point range comparisons (== and !=) that affected cases involving sub-ranges. Previously, the compiler’s range analysis incorrectly determined equality or inequality by only examining the outer boundaries of the ranges, missing situations where a zero value could be contained within a sub-range. This led to incorrect constant folding, for instance, where e != 0.0 could be wrongly simplified to true.

In Details

The range-op-float.cc implementation of operator_equal::fold_range and operator_not_equal::fold_range now uses the irange::contains_zero_p method. This addresses a bug where these operations incorrectly handled sub-ranges by only inspecting hull endpoints. The contains_zero_p method provides a more accurate check for the presence of zero within the potentially complex structure of nested or sub-ranged intervals, ensuring correct pruning of code involving such comparisons.

For Context
sub-range
A portion of a larger range, representing a more specific interval within a broader one.
constant folding
A compiler optimization that evaluates constant expressions at compile time rather than runtime.
hull endpoints
The minimum and maximum values that define the outermost boundary of a range or a set of ranges.
irange
An internal GCC representation for representing integer or floating-point ranges during optimization.
contains_zero_p
A method or function that checks whether a given range (irange) includes the value zero.
Filed Under: optimizationfloating-pointrange analysis