Message ID | 002001d668b3$b8f7ca90$2ae75fb0$@nextmovesoftware.com |
---|---|
State | New |
Headers | show |
Series | PR rtl-optimization 61494: Preserve x-0.0 with HONOR_SNANS. | expand |
On Sun, Aug 2, 2020 at 12:02 PM Roger Sayle <roger@nextmovesoftware.com> wrote: > > > The following patch avoids simplifying x-0.0 to x when -fsignaling-nans is > specified, > which resolves PR rtl-optimization 61494. Indeed, running the test program > attached > to that PR now reports no failures. Alas reducing that validation program > to a portable > test for the GCC testsuite is a challenge that I plan to leave to a > volunteer. The fix > itself is a trivial one-liner, so it's curious that the compiler has been > broken for so long. > Hopefully folks agree that correctness is more important than testability > (but both > are desirable). > > The following patch has been tested on x86_64-pc-linux-gnu with a "make > bootstrap" > and "make -k check" with no new regressions. > Ok for mainline? Heh, and I thought we do no FP math simplifications on RTL ... OK. Thanks, Richard. > 2020-08-02 Roger Sayle <roger@nextmovesoftware.com> > > gcc/ChangeLog > PR rtl-optimization/61494 > * simplify-rtx.c (simplify_binary_operation_1) [MINUS]: Don't > simplify x - 0.0 with -fsignaling-nans. > > Thanks in advance, > Roger > -- > Roger Sayle > NextMove Software > Cambridge, UK >
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index d221168..a9d8e8c 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2678,11 +2678,12 @@ simplify_binary_operation_1 (enum rtx_code code, machine_mode mode, && !contains_symbolic_reference_p (op1)) return simplify_gen_unary (NOT, mode, op1, mode); - /* Subtracting 0 has no effect unless the mode has signed zeros - and supports rounding towards -infinity. In such a case, - 0 - 0 is -0. */ + /* Subtracting 0 has no effect unless the mode has signalling NaNs, + or has signed zeros and supports rounding towards -infinity. + In such a case, 0 - 0 is -0. */ if (!(HONOR_SIGNED_ZEROS (mode) && HONOR_SIGN_DEPENDENT_ROUNDING (mode)) + && !HONOR_SNANS (mode) && trueop1 == CONST0_RTX (mode)) return op0;