re PR middle-end/58418 (wrong code at -O2 and -O3 on x86_64-linux-gnu (in 32-bit...
authorVladimir Makarov <vmakarov@redhat.com>
Mon, 16 Sep 2013 15:12:22 +0000 (15:12 +0000)
committerVladimir Makarov <vmakarov@gcc.gnu.org>
Mon, 16 Sep 2013 15:12:22 +0000 (15:12 +0000)
2013-09-16  Vladimir Makarov  <vmakarov@redhat.com>

PR middle-end/58418
* lra-constraints.c (undo_optional_reloads): Consider all optional
reload even if it did not get a hard reg.

2013-09-16  Vladimir Makarov  <vmakarov@redhat.com>

* gcc.target/i386/pr58418.c: New.

From-SVN: r202630

gcc/ChangeLog
gcc/lra-constraints.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr58418.c [new file with mode: 0644]

index 38cdaf0b34c5efe6611f45aaac23a22bcd9410f1..8f437597502f474b4a3bc2e1cc80286026fcfbdb 100644 (file)
@@ -1,3 +1,9 @@
+2013-09-16  Vladimir Makarov  <vmakarov@redhat.com>
+
+       PR middle-end/58418
+       * lra-constraints.c (undo_optional_reloads): Consider all optional
+       reload even if it did not get a hard reg.
+
 2013-09-16  Teresa Johnson  <tejohnson@google.com>
 
        * dumpfile.c (dump_loc): Remove newline emission.
index 479d2cbc22dcf38a109f4d2d7dc30c1088cec5df..b949a6b4f2eca3ee439bced8a8451f6773f6a1ec 100644 (file)
@@ -5454,43 +5454,42 @@ undo_optional_reloads (void)
   bitmap_initialize (&removed_optional_reload_pseudos, &reg_obstack);
   bitmap_copy (&removed_optional_reload_pseudos, &lra_optional_reload_pseudos);
   EXECUTE_IF_SET_IN_BITMAP (&lra_optional_reload_pseudos, 0, regno, bi)
-    if (reg_renumber[regno] >= 0)
-      {
-       keep_p = false;
-       if (reg_renumber[lra_reg_info[regno].restore_regno] >= 0)
-         /* If the original pseudo changed its allocation, just
-            removing the optional pseudo is dangerous as the original
-            pseudo will have longer live range.  */
-         keep_p = true;
-       else
-         EXECUTE_IF_SET_IN_BITMAP (&lra_reg_info[regno].insn_bitmap, 0, uid, bi2)
-           {
-             insn = lra_insn_recog_data[uid]->insn;
-             if ((set = single_set (insn)) == NULL_RTX)
-               continue;
-             src = SET_SRC (set);
-             dest = SET_DEST (set);
-             if (! REG_P (src) || ! REG_P (dest))
-               continue;
-             if (REGNO (dest) == regno
-                 /* Ignore insn for optional reloads itself.  */
-                 && lra_reg_info[regno].restore_regno != (int) REGNO (src)
-                 /* Check only inheritance on last inheritance pass.  */
-                 && (int) REGNO (src) >= new_regno_start
-                 /* Check that the optional reload was inherited.  */
-                 && bitmap_bit_p (&lra_inheritance_pseudos, REGNO (src)))
-               {
-                 keep_p = true;
-                 break;
-               }
-           }
-       if (keep_p)
+    {
+      keep_p = false;
+      if (reg_renumber[lra_reg_info[regno].restore_regno] >= 0)
+       /* If the original pseudo changed its allocation, just
+          removing the optional pseudo is dangerous as the original
+          pseudo will have longer live range.  */
+       keep_p = true;
+      else if (reg_renumber[regno] >= 0)
+       EXECUTE_IF_SET_IN_BITMAP (&lra_reg_info[regno].insn_bitmap, 0, uid, bi2)
          {
-           bitmap_clear_bit (&removed_optional_reload_pseudos, regno);
-           if (lra_dump_file != NULL)
-             fprintf (lra_dump_file, "Keep optional reload reg %d\n", regno);
+           insn = lra_insn_recog_data[uid]->insn;
+           if ((set = single_set (insn)) == NULL_RTX)
+             continue;
+           src = SET_SRC (set);
+           dest = SET_DEST (set);
+           if (! REG_P (src) || ! REG_P (dest))
+             continue;
+           if (REGNO (dest) == regno
+               /* Ignore insn for optional reloads itself.  */
+               && lra_reg_info[regno].restore_regno != (int) REGNO (src)
+               /* Check only inheritance on last inheritance pass.  */
+               && (int) REGNO (src) >= new_regno_start
+               /* Check that the optional reload was inherited.  */
+               && bitmap_bit_p (&lra_inheritance_pseudos, REGNO (src)))
+             {
+               keep_p = true;
+               break;
+             }
          }
-      }
+      if (keep_p)
+       {
+         bitmap_clear_bit (&removed_optional_reload_pseudos, regno);
+         if (lra_dump_file != NULL)
+           fprintf (lra_dump_file, "Keep optional reload reg %d\n", regno);
+       }
+    }
   change_p = ! bitmap_empty_p (&removed_optional_reload_pseudos);
   bitmap_initialize (&insn_bitmap, &reg_obstack);
   EXECUTE_IF_SET_IN_BITMAP (&removed_optional_reload_pseudos, 0, regno, bi)
index 4f9b8a79191454b72cedff83ccaf328f6a855cce..5971d1fd1b67bf077b8f24fc887fb3ed099c06f1 100644 (file)
@@ -1,3 +1,7 @@
+2013-09-16  Vladimir Makarov  <vmakarov@redhat.com>
+
+       * gcc.target/i386/pr58418.c: New.
+
 2013-09-16  James Greenhalgh  <james.greenhalgh@arm.com>
 
        * gcc.target/aarch64/fmla-intrinsic.c: New.
diff --git a/gcc/testsuite/gcc.target/i386/pr58418.c b/gcc/testsuite/gcc.target/i386/pr58418.c
new file mode 100644 (file)
index 0000000..27634c9
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+extern void abort (void);
+int a, b, *c = &b, d = -1, e, f, *g, *h = &f, **i = &g, j;
+
+unsigned int
+foo (unsigned int p)
+{
+  return p == 0 ? 0 : 1 / p;
+}
+
+static int *
+bar ()
+{
+  *c = *h = foo (d) & (-9 < d);
+  for (e = 0; e; e++)
+    ;
+  return 0;
+}
+
+int
+main ()
+{
+  for (; j; j++)
+    for (;; a--)
+      ;
+  *i = bar ();
+  if (f != 0)
+    abort ();
+  return 0;
+}