[Bug tree-optimization/126467] [13/14/15/16/17 Regression] wrong code with folding 0.0 - x
roger at nextmovesoftware dot com
gcc-bugzilla@gcc.gnu.org
Wed Jul 29 11:15:15 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126467
--- Comment #2 from Roger Sayle <roger at nextmovesoftware dot com> ---
The problem is with the transformation at line 5916 of match.pd:
/* (ARG0 - ARG1) is the same as (-ARG1 + ARG0). So check whether
ARG0 is zero and X + ARG0 reduces to X, since that would mean
(-ARG1 + ARG0) reduces to -ARG1. */
(simplify
(minus real_zerop@0 @1)
(if (fold_real_zero_addition_p (type, @1, @0, 0))
(negate @1)))
The problem is that "x - y" is not the same as "(-y) + x" in IEEE FP,
i.e. the first sentence/statement of the comment is incorrect, so it's
inappropriate to use fold_real_zero_addition_p here. Instead it needs
to check that y can't be zero (or signaling NaN). Technically, if
x is +0.0, it's OK for y to be -0.0.
More information about the Gcc-bugs
mailing list