]> gcc.gnu.org Git - gcc.git/commitdiff
PR rtl-optimization 61494: Preserve x-0.0 with HONOR_SNANS.
authorRoger Sayle <roger@nextmovesoftware.com>
Mon, 3 Aug 2020 12:15:58 +0000 (13:15 +0100)
committerRoger Sayle <roger@nextmovesoftware.com>
Mon, 3 Aug 2020 12:15:58 +0000 (13:15 +0100)
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.

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.

gcc/simplify-rtx.c

index d2211686accfbec24cc1ba19092b0427fac69ab6..4f0652f553ec280d61e06401211219cfdd175d24 100644 (file)
@@ -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;
 
This page took 0.064768 seconds and 5 git commands to generate.