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

Fix ICE optimizing 0.0 - x with -ffinite-math-only

Corrects an integer compiler error (ICE) when optimizing floating-point expressions involving negative zero under the -ffinite-math-only flag.

An Integer Compiler Error (ICE) occurring when optimizing expressions like (T)0.0 - x with the -ffinite-math-only flag has been resolved. The issue stemmed from an incorrect assumption about how GCC handles negative zero in floating-point constants. A new predicate, real_negzerop, has been introduced to robustly identify negative zero across various constant types (real, vector, complex) and prevent the ICE.

In Details

This commit addresses PR middle-end/126775, resolving an ICE in match.pd related to the optimization of 0.0 - x to -x when -ffinite-math-only is active. The recent change assumed real_zerop(@0) implied TREE_CODE(@0) == REAL_CST. This patch introduces real_negzerop, a new predicate that correctly identifies -0.0 equivalents for REAL_CST, VECTOR_CST, and COMPLEX_CST, and safely handles unexpected TREE_CODEs, preventing the ICE.

For Context
ICE
Integer Compiler Error. This is GCC's internal term for a crash or assertion failure within the compiler itself during the compilation process, distinct from runtime errors.
-ffinite-math-only
A GCC optimization flag that instructs the compiler to assume that floating-point operations behave according to mathematical properties, avoiding reliance on IEEE 754 specifics like NaN and infinities. This can enable more aggressive optimizations.
predicate
In the context of GCC's internal representation, a predicate is a function that tests a condition on a 'tree' node, returning true or false. For example, integer_zerop checks if a tree represents the integer zero.
tree
GCC's internal representation for source code constructs, forming an abstract syntax tree. 'Tree codes' denote the type of node (e.g., expression, statement, type).
Filed Under: optimizationfloating-pointcompiler-bug