On Sat, Feb 05, 2022 at 08:21:26AM +0100, Richard Biener wrote: > > Am 05.02.2022 um 00:08 schrieb Jakub Jelinek via Gcc-patches > > <gcc-patches@gcc.gnu.org>: > > The recent PR95115 change to punt in const_binop on folding operation > > with non-NaN operands into NaN if flag_trapping_math broke the following > > testcase, because the x * 0.0 simplification punts just if > > x maybe a NaN (because NaN * 0.0 is NaN not 0.0) or if one of the operands > > could be negative zero. But Inf * 0.0 or -Inf * 0.0 is also NaN, not > > 0.0, so when NaNs are honored we need to punt for possible infinities too. > > > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk > > and 11/10 where the PR95115 change has been unfortunately backported to > > as well? > > Ok
Thanks, committed now. Turns out gcc 10/11 don't suffer from this bug (though reversion of the PR95115 change for 10/11 is probably a good idea anyway), this bug has been introduced in r12-1393-g5b02ed4b87685c0f7c5da9b46cde3ce56fcfd457 where we used there if (!HONOR_NANS (type) && !HONOR_SIGNED_ZEROS (type)) before. Looking at that commit, there was also: (simplify (minus @0 @0) - (if (!FLOAT_TYPE_P (type) || !HONOR_NANS (type)) + (if (!FLOAT_TYPE_P (type) || !tree_expr_maybe_nan_p (@0)) { build_zero_cst (type); })) Inf - Inf or (-Inf) - (-Inf) is NaN, not 0.0, but that got fixed in r12-5529-g6ea5fb3cc7f3cc9b731d72183c66c23543876f5a Jakub