https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128007
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |roger at
nextmovesoftware dot com
--- Comment #3 from Roger Sayle <roger at nextmovesoftware dot com> ---
Proposed patch:
diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index 6b19008c0d3..aa06f082f06 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -3473,12 +3473,16 @@ simplify_context::simplify_binary_operation_1 (rtx_code
code,
break;
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. */
+ /* We can't assume x-x is 0 even with non-IEEE floating point.
+ This is unsafe if x is NaN or Inf, and with FE_DOWNWARD as the
+ rounding mode x - x may be -0.0. c.f. PR middle-end/98420. */
if (rtx_equal_p (trueop0, trueop1)
&& ! side_effects_p (op0)
- && (!FLOAT_MODE_P (mode) || !HONOR_NANS (mode)))
+ && (!FLOAT_MODE_P (mode)
+ || (!HONOR_NANS (mode)
+ && !HONOR_INFINITIES (mode)
+ && (!HONOR_SIGN_DEPENDENT_ROUNDING (mode)
+ || !HONOR_SIGNED_ZEROS (mode)))))
return CONST0_RTX (mode);
This synchronizes the logic between match.pd and simplify-rtx.cc.