gcc/gcc49-pr64536.patch

96 lines
1.8 KiB
Diff

2015-01-08 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/64536
* cfgrtl.c (rtl_tidy_fallthru_edge): Don't remove tablejumps.
* gcc.dg/pr64536.c: New test.
--- gcc/cfgrtl.c.jj 2015-01-05 13:07:12.000000000 +0100
+++ gcc/cfgrtl.c 2015-01-08 17:03:18.511218340 +0100
@@ -1782,10 +1782,14 @@ rtl_tidy_fallthru_edge (edge e)
if (INSN_P (q))
return;
+ q = BB_END (b);
+ /* Don't remove table jumps here. */
+ if (tablejump_p (q, NULL, NULL))
+ return;
+
/* Remove what will soon cease being the jump insn from the source block.
If block B consisted only of this single jump, turn it into a deleted
note. */
- q = BB_END (b);
if (JUMP_P (q)
&& onlyjump_p (q)
&& (any_uncondjump_p (q)
--- gcc/testsuite/gcc.dg/pr64536.c.jj 2015-01-08 17:13:32.218929003 +0100
+++ gcc/testsuite/gcc.dg/pr64536.c 2015-01-08 17:28:56.758428958 +0100
@@ -0,0 +1,67 @@
+/* PR rtl-optimization/64536 */
+/* { dg-do link } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-fPIC" { target fpic } } */
+
+struct S { long q; } *h;
+long a, b, g, j, k, *c, *d, *e, *f, *i;
+long *baz (void)
+{
+ asm volatile ("" : : : "memory");
+ return e;
+}
+
+void
+bar (int x)
+{
+ int y;
+ for (y = 0; y < x; y++)
+ {
+ switch (b)
+ {
+ case 0:
+ case 2:
+ a++;
+ break;
+ case 3:
+ a++;
+ break;
+ case 1:
+ a++;
+ }
+ if (d)
+ {
+ f = baz ();
+ g = k++;
+ if (&h->q)
+ {
+ j = *f;
+ h->q = *f;
+ }
+ else
+ i = (long *) (h->q = *f);
+ *c++ = (long) f;
+ e += 6;
+ }
+ else
+ {
+ f = baz ();
+ g = k++;
+ if (&h->q)
+ {
+ j = *f;
+ h->q = *f;
+ }
+ else
+ i = (long *) (h->q = *f);
+ *c++ = (long) f;
+ e += 6;
+ }
+ }
+}
+
+int
+main ()
+{
+ return 0;
+}