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

Fix signed zero issue in 0.0-x transformation.

Corrects a signed zero handling bug in the 0.0-x to -x transformation, ensuring IEEE compliance.

This commit corrects an issue in match.pd where the transformation of 0.0 - x to -x incorrectly handled signed zeros, violating IEEE 754 standards. The fix ensures that when signed zeros are honored, +0.0 - +0.0 correctly results in +0.0, and it also addresses cases where x is NaN. New test cases are added to verify the correct behavior.

In Details

PR tree-optimization/126467 is addressed by refining the conditions in match.pd for the 0.0 - x -> -x transformation. The change prevents the transformation when x is +0.0 if signed zeros are being honored, and it continues to disallow it if x is a NaN. This aligns the transformation with IEEE 754 signed zero semantics and NaN handling.

For Context
signed zero
A special floating-point value that is numerically zero but carries a sign. In IEEE 754, both +0.0 and -0.0 exist and can affect the results of certain operations.
IEEE 754
The standard for floating-point arithmetic, defining formats, operations, and exception handling. GCC aims to comply with this standard.
NaN
Not a Number. A special floating-point value used to represent undefined or unrepresentable results.
match.pd
Likely a file containing pattern-matching rules for algebraic simplifications within GCC's optimization passes.
Filed Under: optimizationbugfixfloating-pointieee-754