re PR rtl-optimization/28096 (fdlibm/strtod.c miscompiled at -O2)
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 30 Sep 2006 13:31:29 +0000 (13:31 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 30 Sep 2006 13:31:29 +0000 (13:31 +0000)
PR rtl-optimization/28096
* ifcvt.c (check_cond_move_block): Return FALSE if the source of an
assignment has already been used as a destination earlier in the
block.

From-SVN: r117331

gcc/ChangeLog
gcc/ifcvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20060930-1.c [new file with mode: 0644]

index 3f96481599ed47f07e074576322468a820208d48..7a0e026c28129d791cae646be3b65811edbd387e 100644 (file)
@@ -1,4 +1,10 @@
-2006-09-28  Eric Botcazou  <ebotcazou@adacore.com>
+2006-09-30  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR rtl-optimization/28096
+       * ifcvt.c (check_cond_move_block): Return FALSE if the source of an
+       assignment has already been used as a destination earlier in the block.
+
+2006-09-29  Eric Botcazou  <ebotcazou@adacore.com>
 
        * builtins.c (expand_builtin_setjmp): Delete.
        (expand_builtin) <BUILT_IN_SETJMP>: Mark as unreachable.
index 41da0b3af16da59827377cee347c316deab7373d..8609823b33b38838bd9aab0f2af936c912016737 100644 (file)
@@ -2424,7 +2424,7 @@ check_cond_move_block (basic_block bb, rtx *vals, rtx cond)
       src = SET_SRC (set);
       if (!REG_P (dest)
          || (SMALL_REGISTER_CLASSES && HARD_REGISTER_P (dest)))
-       return false;
+       return FALSE;
 
       if (!CONSTANT_P (src) && !register_operand (src, VOIDmode))
        return FALSE;
@@ -2435,6 +2435,14 @@ check_cond_move_block (basic_block bb, rtx *vals, rtx cond)
       if (may_trap_p (src) || may_trap_p (dest))
        return FALSE;
 
+      /* Don't try to handle this if the source register was
+        modified earlier in the block.  */
+      if ((REG_P (src)
+          && vals[REGNO (src)] != NULL)
+         || (GET_CODE (src) == SUBREG && REG_P (SUBREG_REG (src))
+             && vals[REGNO (SUBREG_REG (src))] != NULL))
+       return FALSE;
+
       /* Don't try to handle this if the destination register was
         modified earlier in the block.  */
       if (vals[REGNO (dest)] != NULL)
index 7d29c05ac0804b1d3aec097c94bc19d4befdf7a5..c5c774a66702f16dbd30cb15e720438ec6ad69c1 100644 (file)
@@ -1,3 +1,7 @@
+2006-09-30  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * gcc.c-torture/execute/20060930-1.c: New test.
+
 2006-09-29  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        PR fortran/18791
@@ -15,7 +19,7 @@
        * gfortran.dg/nearest_1.f90: Add -ffloat-store to defeat extra
        precision on some archs.
 
-2006-09-28  Eric Botcazou  <ebotcazou@adacore.com>
+2006-09-29  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.dg/non-local-goto-1.c: New test.
        * gcc.dg/non-local-goto-2.c: Likewise.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20060930-1.c b/gcc/testsuite/gcc.c-torture/execute/20060930-1.c
new file mode 100644 (file)
index 0000000..f12ee55
--- /dev/null
@@ -0,0 +1,42 @@
+/* PR rtl-optimization/28096 */
+/* Origin: Jan Stein <jan@gatespacetelematics.com> */
+
+extern void abort (void);
+
+int bar (int, int) __attribute__((noinline));
+int bar (int a, int b)
+{
+  if (b != 1)
+    abort ();
+}
+
+void foo(int, int) __attribute__((noinline));
+void foo (int e, int n)
+{
+  int i, bb2, bb5;
+
+  if (e > 0)
+    e = -e;
+
+  for (i = 0; i < n; i++)
+    {
+      if (e >= 0)
+       {
+         bb2 = 0;
+         bb5 = 0;
+       }
+      else
+       {
+         bb5 = -e;
+         bb2 = bb5;
+       }
+
+      bar (bb5, bb2);
+    }
+}
+
+int main(void)
+{
+  foo (1, 1);
+  return 0;
+}