re PR rtl-optimization/28634 (rounding problem with -fdelayed-branch on hppa/mips)
authorRichard Sandiford <richard@codesourcery.com>
Mon, 14 Aug 2006 11:55:52 +0000 (11:55 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Mon, 14 Aug 2006 11:55:52 +0000 (11:55 +0000)
gcc/
PR rtl-optimization/28634
* reorg.c (fill_slots_from_thread): Do not assume A + X - X == A
for floating-point modes unless flag_unsafe_math_optimizations.

gcc/testsuite/
PR rtl-optimization/28634
* gcc.c-torture/execute/ieee/pr28634.c: New test.

From-SVN: r116124

gcc/ChangeLog
gcc/reorg.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/ieee/pr28634.c [new file with mode: 0644]

index 37fbac8519ccc811a23de7d5b4255c7fc6d3abc9..8a53adee42f3c6b8c42274b0273b0dea17ceae85 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-14  Richard Sandiford  <richard@codesourcery.com>
+
+       PR rtl-optimization/28634
+       * reorg.c (fill_slots_from_thread): Do not assume A + X - X == A
+       for floating-point modes unless flag_unsafe_math_optimizations.
+
 2006-08-13  Alexandre Oliva  <aoliva@redhat.com>
            Andrew Pinski  <pinskia@physics.uc.edu>
 
index 42ecda0db4cba7bf94fed5473de225b6a04f711a..8c097dca41255f75c0d20ebab7956a6cae8bc659 100644 (file)
@@ -2817,6 +2817,8 @@ fill_slots_from_thread (rtx insn, rtx condition, rtx thread,
       dest = SET_DEST (pat), src = SET_SRC (pat);
       if ((GET_CODE (src) == PLUS || GET_CODE (src) == MINUS)
          && rtx_equal_p (XEXP (src, 0), dest)
+         && (!FLOAT_MODE_P (GET_MODE (src))
+             || flag_unsafe_math_optimizations)
          && ! reg_overlap_mentioned_p (dest, XEXP (src, 1))
          && ! side_effects_p (pat))
        {
index de4f9e6a789dc7442ad9d22415acc24e6847a2c4..7481db0ec6d3a5e4bc8098a8de7ea3c900fc3c9b 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-14  Richard Sandiford  <richard@codesourcery.com>
+
+       PR rtl-optimization/28634
+       * gcc.c-torture/execute/ieee/pr28634.c: New test.
+
 2006-08-13  Alexandre Oliva  <aoliva@redhat.com>
 
        PR c/27184
diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/pr28634.c b/gcc/testsuite/gcc.c-torture/execute/ieee/pr28634.c
new file mode 100644 (file)
index 0000000..a0c5254
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR rtl-optimization/28634.  On targets with delayed branches,
+   dbr_schedule could do the next iteration's addition in the
+   branch delay slot, then subtract the value again if the branch
+   wasn't taken.  This can lead to rounding errors.  */
+double x = -0x1.0p53;
+double y = 1;
+int
+main (void)
+{
+  while (y > 0)
+    y += x;
+  if (y != x + 1)
+    abort ();
+  exit (0);
+}