https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61494

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-06-13
          Component|target                      |rtl-optimization
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
RTL CSE optimizes x - 0.0 to x.  I thought it does nothing for FP ops ...

Confirmed.

static rtx
simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
                             rtx op0, rtx op1, rtx trueop0, rtx trueop1)
{
...
    case PLUS:
      /* Maybe simplify x + 0 to x.  The two expressions are equivalent
         when x is NaN, infinite, or finite and nonzero.  They aren't
         when x is -0 and the rounding mode is not towards -infinity,
         since (-0) + 0 is then 0.  */
      if (!HONOR_SIGNED_ZEROS (mode) && trueop1 == CONST0_RTX (mode))
        return op0;
...
    case MINUS:
      /* We can't assume x-x is 0 even with non-IEEE floating point,
         but since it is zero except in very strange circumstances, we
         will treat it as zero with -ffinite-math-only.  */
      if (rtx_equal_p (trueop0, trueop1)
          && ! side_effects_p (op0)
          && (!FLOAT_MODE_P (mode) || !HONOR_NANS (mode)))
        return CONST0_RTX (mode);

      /* Change subtraction from zero into negation.  (0 - x) is the
         same as -x when x is NaN, infinite, or finite and nonzero.
         But if the mode has signed zeros, and does not round towards
         -infinity, then 0 - 0 is 0, not -0.  */
      if (!HONOR_SIGNED_ZEROS (mode) && trueop0 == CONST0_RTX (mode))
        return simplify_gen_unary (NEG, mode, op1, mode);

Reply via email to