PR rtl-optimization/31944
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 14 Jan 2008 12:16:58 +0000 (12:16 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 14 Jan 2008 12:16:58 +0000 (12:16 +0000)
* cse.c (remove_pseudo_from_table): New function.
(merge_equiv_classes): Use above function to remove pseudo-registers.
(invalidate): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131522 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cse.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20080114-1.c [new file with mode: 0644]

index 27b4882..d463d4e 100644 (file)
@@ -1,3 +1,10 @@
+2008-01-14  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR rtl-optimization/31944
+       * cse.c (remove_pseudo_from_table): New function.
+       (merge_equiv_classes): Use above function to remove pseudo-registers.
+       (invalidate): Likewise.
+
 2008-01-13  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/34601
index 09f80fe..f6660e4 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -554,7 +554,8 @@ static void delete_reg_equiv (unsigned int);
 static int mention_regs (rtx);
 static int insert_regs (rtx, struct table_elt *, int);
 static void remove_from_table (struct table_elt *, unsigned);
-static struct table_elt *lookup        (rtx, unsigned, enum machine_mode);
+static void remove_pseudo_from_table (rtx, unsigned);
+static struct table_elt *lookup (rtx, unsigned, enum machine_mode);
 static struct table_elt *lookup_for_remove (rtx, unsigned, enum machine_mode);
 static rtx lookup_as_function (rtx, enum rtx_code);
 static struct table_elt *insert (rtx, struct table_elt *, unsigned,
@@ -1288,6 +1289,19 @@ remove_from_table (struct table_elt *elt, unsigned int hash)
   free_element_chain = elt;
 }
 
+/* Same as above, but X is a pseudo-register.  */
+
+static void
+remove_pseudo_from_table (rtx x, unsigned int hash)
+{
+  struct table_elt *elt;
+
+  /* Because a pseudo-register can be referenced in more than one
+     mode, we might have to remove more than one table entry.  */
+  while ((elt = lookup_for_remove (x, hash, VOIDmode)))
+    remove_from_table (elt, hash);
+}
+
 /* Look up X in the hash table and return its table element,
    or 0 if X is not in the table.
 
@@ -1605,7 +1619,10 @@ merge_equiv_classes (struct table_elt *class1, struct table_elt *class2)
              delete_reg_equiv (REGNO (exp));
            }
 
-         remove_from_table (elt, hash);
+         if (REG_P (exp) && REGNO (exp) >= FIRST_PSEUDO_REGISTER)
+           remove_pseudo_from_table (exp, hash);
+         else
+           remove_from_table (elt, hash);
 
          if (insert_regs (exp, class1, 0) || need_rehash)
            {
@@ -1701,14 +1718,7 @@ invalidate (rtx x, enum machine_mode full_mode)
        SUBREG_TICKED (regno) = -1;
 
        if (regno >= FIRST_PSEUDO_REGISTER)
-         {
-           /* Because a register can be referenced in more than one mode,
-              we might have to remove more than one table entry.  */
-           struct table_elt *elt;
-
-           while ((elt = lookup_for_remove (x, hash, GET_MODE (x))))
-             remove_from_table (elt, hash);
-         }
+         remove_pseudo_from_table (x, hash);
        else
          {
            HOST_WIDE_INT in_table
index 180d955..6a6d9b9 100644 (file)
@@ -1,3 +1,7 @@
+2008-01-14  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.c-torture/compile/20080114-1.c: New test.
+
 2008-01-13  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/34665
diff --git a/gcc/testsuite/gcc.c-torture/compile/20080114-1.c b/gcc/testsuite/gcc.c-torture/compile/20080114-1.c
new file mode 100644 (file)
index 0000000..51affb7
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR rtl-optimization/31944 */
+/* Origin: Aurelien Jarno <aurelien@aurel32.net> */
+
+int type;
+
+void stuck(int res)
+{
+  if (type == 1) {
+    if (res == 0) asm volatile("nop");
+  }
+  else if (type == 0) {
+    if (res == 0) asm volatile("nop" : : "i" (0));
+  }
+}