combine.c (distribute_notes): Avoid adding REG_LABEL notes to JUMP_INSNs with JUMP_LABEL.
authorJakub Jelinek <jakub@redhat.com>
Thu, 20 Dec 2001 08:23:42 +0000 (09:23 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 20 Dec 2001 08:23:42 +0000 (09:23 +0100)
* combine.c (distribute_notes): Avoid adding REG_LABEL notes
to JUMP_INSNs with JUMP_LABEL.

* gcc.c-torture/execute/20011219-1.c: New test.

From-SVN: r48198

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

index 47fe504bb91686dad67013aa843ff9ad4f28da31..f1634cc47449d6a4c030a2d52949e2558eb7707b 100644 (file)
@@ -1,3 +1,8 @@
+2001-12-20  Jakub Jelinek  <jakub@redhat.com>
+
+       * combine.c (distribute_notes): Avoid adding REG_LABEL notes
+       to JUMP_INSNs with JUMP_LABEL.
+
 2001-12-19  Aldy Hernandez  <aldyh@redhat.com>
 
         * doc/install.texi: Add documentation for --enable-altivec.
index 82e86b2816e051a7071c71ca8c62ddaa9da51f59..a0b08ec12581c654e4acc57f272824826a0f9dc3 100644 (file)
@@ -12129,6 +12129,25 @@ distribute_notes (notes, from_insn, i3, i2, elim_i2, elim_i1)
              else
                place = i2;
            }
+
+         /* Don't attach REG_LABEL note to a JUMP_INSN which has
+            JUMP_LABEL already.  Instead, decrement LABEL_NUSES.  */
+         if (place && GET_CODE (place) == JUMP_INSN && JUMP_LABEL (place))
+           {
+             if (JUMP_LABEL (place) != XEXP (note, 0))
+               abort ();
+             if (GET_CODE (JUMP_LABEL (place)) == CODE_LABEL)
+               LABEL_NUSES (JUMP_LABEL (place))--;
+             place = 0;
+           }
+         if (place2 && GET_CODE (place2) == JUMP_INSN && JUMP_LABEL (place2))
+           {
+             if (JUMP_LABEL (place2) != XEXP (note, 0))
+               abort ();
+             if (GET_CODE (JUMP_LABEL (place2)) == CODE_LABEL)
+               LABEL_NUSES (JUMP_LABEL (place2))--;
+             place2 = 0;
+           }
          break;
 
        case REG_NONNEG:
index 00ed5ee17793569c8760ebb1c579b5af6f65da4c..de0cdf8810a3bba9c51d72511abef4947a49c2df 100644 (file)
@@ -1,3 +1,7 @@
+2001-12-20  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.c-torture/execute/20011219-1.c: New test.
+
 2001-12-19  David Billinghurst <David.Billinghurst@riotinto.com>
 
        * gcc.dg/special/ecos.exp:  wkali-1.c unsupported if
diff --git a/gcc/testsuite/gcc.c-torture/execute/20011219-1.c b/gcc/testsuite/gcc.c-torture/execute/20011219-1.c
new file mode 100644 (file)
index 0000000..d0726ad
--- /dev/null
@@ -0,0 +1,49 @@
+/* This testcase failed on IA-32 at -O and above, because combine attached
+   a REG_LABEL note to jump instruction already using JUMP_LABEL.  */
+
+extern void abort (void);
+extern void exit (int);
+
+enum X { A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q };
+
+void
+bar (const char *x, int y, const char *z)
+{
+}
+
+long
+foo (enum X x, const void *y)
+{
+  long a;
+
+  switch (x)
+    {
+    case K:
+      a = *(long *)y;
+      break;
+    case L:
+      a = *(long *)y;
+      break;
+    case M:
+      a = *(long *)y;
+      break;
+    case N:
+      a = *(long *)y;
+      break;
+    case O:
+      a = *(long *)y;
+      break;
+    default:
+      bar ("foo", 1, "bar");
+    }
+  return a;
+}
+
+int
+main ()
+{
+  int i = 24;
+  if (foo (N, &i) != 24)
+    abort ();
+  exit (0);
+}