re PR rtl-optimization/47028 (gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimi...
authorJakub Jelinek <jakub@redhat.com>
Sun, 2 Jan 2011 17:07:15 +0000 (18:07 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sun, 2 Jan 2011 17:07:15 +0000 (18:07 +0100)
PR rtl-optimization/47028
* cfgexpand.c (gimple_expand_cfg): Insert entry edge
insertions after parm_birth_insn instead of at the beginning
of first bb.

* gcc.dg/pr47028.c: New test.

From-SVN: r168401

gcc/ChangeLog
gcc/cfgexpand.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr47028.c [new file with mode: 0644]

index 9a793f41d2d2910f286c0ab81c24e9443c7d9230..343e51056f02ba5f4c5082cf71606b29a4936ec1 100644 (file)
@@ -1,3 +1,10 @@
+2011-01-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/47028
+       * cfgexpand.c (gimple_expand_cfg): Insert entry edge
+       insertions after parm_birth_insn instead of at the beginning
+       of first bb.
+
 2011-01-02  Mingjie Xing  <mingjie.xing@gmail.com>
 
        * doc/generic.texi: Remove duplicated "@subsubsection Statements".
index a3940d01775fa0cdd58b84fbed31e865db99c7bb..13c63be12ef866c396ca246248ea3df72645d2ff 100644 (file)
@@ -4085,7 +4085,19 @@ gimple_expand_cfg (void)
       for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
        {
          if (e->insns.r)
-           commit_one_edge_insertion (e);
+           {
+             /* Avoid putting insns before parm_birth_insn.  */
+             if (e->src == ENTRY_BLOCK_PTR
+                 && single_succ_p (ENTRY_BLOCK_PTR)
+                 && parm_birth_insn)
+               {
+                 rtx insns = e->insns.r;
+                 e->insns.r = NULL_RTX;
+                 emit_insn_after_noloc (insns, parm_birth_insn, e->dest);
+               }
+             else
+               commit_one_edge_insertion (e);
+           }
          else
            ei_next (&ei);
        }
index 3ba534674fe0dd626cb942c90cf0f0e4165d76c7..09e47cfca258512f3c2437a7321969fae8af3d7a 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/47028
+       * gcc.dg/pr47028.c: New test.
+
 2011-01-02  Nicola Pero  <nicola.pero@meta-innovation.com>
 
        * objc.dg/protocol-forward-1.m: Removed TODO.
diff --git a/gcc/testsuite/gcc.dg/pr47028.c b/gcc/testsuite/gcc.dg/pr47028.c
new file mode 100644 (file)
index 0000000..3f80ff1
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR rtl-optimization/47028 */
+/* { dg-do run } */
+/* { dg-options "-O -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts" } */
+
+int
+fib (int n)
+{
+  if (n <= 1)
+    return 1;
+  return fib (n - 2) + fib (n - 1);
+}
+
+int
+main (void)
+{
+  if (fib (5) != 8)
+    __builtin_abort ();
+  return 0;
+}