OSDN Git Service

PR rtl-optimization/51495
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Dec 2011 21:00:36 +0000 (21:00 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 12 Dec 2011 21:00:36 +0000 (21:00 +0000)
* function.c (thread_prologue_and_epilogue_insns): Don't add
to bb_tail basic blocks that have EDGE_COMPLEX predecessor edges
from basic blocks not needing prologue.

* gcc.c-torture/compile/pr51495.c: New test.

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

gcc/ChangeLog
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr51495.c [new file with mode: 0644]

index 68d354d..6a7fedd 100644 (file)
@@ -1,5 +1,10 @@
 2011-12-12  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/51495
+       * function.c (thread_prologue_and_epilogue_insns): Don't add
+       to bb_tail basic blocks that have EDGE_COMPLEX predecessor edges
+       from basic blocks not needing prologue.
+
        PR tree-optimization/51481
        * gimple-fold.c (gimple_fold_call): Call
        maybe_clean_or_replace_eh_stmt.  Avoid optimization if stmt has EH
index a081b27..506ec03 100644 (file)
@@ -5956,9 +5956,22 @@ thread_prologue_and_epilogue_insns (void)
          FOR_EACH_EDGE (e, ei, tmp_bb->preds)
            if (single_succ_p (e->src)
                && !bitmap_bit_p (&bb_on_list, e->src->index)
-               && can_duplicate_block_p (e->src)
-               && bitmap_set_bit (&bb_tail, e->src->index))
-             VEC_quick_push (basic_block, vec, e->src);
+               && can_duplicate_block_p (e->src))
+             {
+               edge pe;
+               edge_iterator pei;
+
+               /* If there is predecessor of e->src which doesn't
+                  need prologue and the edge is complex,
+                  we might not be able to redirect the branch
+                  to a copy of e->src.  */
+               FOR_EACH_EDGE (pe, pei, e->src->preds)
+                 if ((pe->flags & EDGE_COMPLEX) != 0
+                     && !bitmap_bit_p (&bb_flags, pe->src->index))
+                   break;
+               if (pe == NULL && bitmap_set_bit (&bb_tail, e->src->index))
+                 VEC_quick_push (basic_block, vec, e->src);
+             }
        }
 
       /* Now walk backwards from every block that is marked as needing
index 5f0f195..acf3efc 100644 (file)
@@ -1,5 +1,8 @@
 2011-12-12  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/51495
+       * gcc.c-torture/compile/pr51495.c: New test.
+
        PR tree-optimization/51481
        * gcc.dg/pr51481.c: New test.
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr51495.c b/gcc/testsuite/gcc.c-torture/compile/pr51495.c
new file mode 100644 (file)
index 0000000..34de37b
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR rtl-optimization/51495 */
+
+void bar (void);
+
+int
+foo (int i)
+{
+  static const void *const table[] = { &&begin, &&end };
+  goto *(table[i]);
+begin:
+  bar ();
+end:
+  return 0;
+}