summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2010-12-06 19:28:09 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2010-12-06 19:28:09 +0000
commitbb1c580c847d650e2322189dc2e37824fd0e8ec5 (patch)
tree959f69dcff53adb1e2fe7053bcc927890ba29a79 /gcc
parent3a17e644275b905b51fcb3aee55630331e3dd119 (diff)
downloadgcc-bb1c580c847d650e2322189dc2e37824fd0e8ec5.tar.gz
PR rtl-optimization/46777
* cfglayout.c (duplicate_insn_chain): Avoid duplicating also barrier after tablejump. * gcc.dg/pr46777.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167513 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/cfglayout.c15
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr46777.c49
4 files changed, 74 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 285b8b7bd78..047bcef4ba2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2010-12-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/46777
+ * cfglayout.c (duplicate_insn_chain): Avoid duplicating
+ also barrier after tablejump.
+
2010-12-06 Joern Rennecke <amylaar@spamcop.net>
Richard Henderson <rth@redhat.com>
diff --git a/gcc/cfglayout.c b/gcc/cfglayout.c
index e883af4afab..f7d4d104403 100644
--- a/gcc/cfglayout.c
+++ b/gcc/cfglayout.c
@@ -1177,7 +1177,20 @@ duplicate_insn_chain (rtx from, rtx to)
moved far from original jump. */
if (GET_CODE (PATTERN (insn)) == ADDR_VEC
|| GET_CODE (PATTERN (insn)) == ADDR_DIFF_VEC)
- break;
+ {
+ /* Avoid copying following barrier as well if any
+ (and debug insns in between). */
+ rtx next;
+
+ for (next = NEXT_INSN (insn);
+ next != NEXT_INSN (to);
+ next = NEXT_INSN (next))
+ if (!DEBUG_INSN_P (next))
+ break;
+ if (next != NEXT_INSN (to) && BARRIER_P (next))
+ insn = next;
+ break;
+ }
copy = emit_copy_of_insn_after (insn, get_last_insn ());
maybe_copy_prologue_epilogue_insn (insn, copy);
break;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5244634ca93..3c5c43e1696 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2010-12-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR rtl-optimization/46777
+ * gcc.dg/pr46777.c: New test.
+
2010-12-06 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* ada/acats/run_acats (which): Assign output to temporary
diff --git a/gcc/testsuite/gcc.dg/pr46777.c b/gcc/testsuite/gcc.dg/pr46777.c
new file mode 100644
index 00000000000..e9f40a080eb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr46777.c
@@ -0,0 +1,49 @@
+/* PR rtl-optimization/46777 */
+/* { dg-do compile } */
+/* { dg-options "-fgcse -O -fno-tree-dominator-opts -funroll-loops" } */
+
+struct S { char s[256]; };
+
+static inline int
+foo (int x, int y)
+{
+ switch (x)
+ {
+ case 1:
+ case 2:
+ return 3;
+ case 3:
+ case 4:
+ return 2;
+ case 5:
+ switch (y)
+ {
+ case 4:
+ return 1;
+ }
+ }
+ return 0;
+}
+
+void
+bar (struct S *x, int *y, int *z, int **w)
+{
+ switch (*y ? x->s[*y] : foo (y[1], y[0]))
+ {
+ case 3:
+ if (y + 2 == z)
+ for (;;)
+ {
+ y += 2;
+ switch (*y ? x->s[*y] : foo (y[1], y[0]))
+ {
+ case 6:
+ break;
+ default:
+ *w = y;
+ }
+ if (y == z)
+ break;
+ }
+ }
+}