]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/46177 (ICE: in prop_phis, at tree-loop-distribution.c:327...
authorRichard Guenther <rguenther@suse.de>
Tue, 9 Nov 2010 15:01:41 +0000 (15:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 9 Nov 2010 15:01:41 +0000 (15:01 +0000)
2010-11-09  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/46177
* tree-loop-distribution.c (prop_phis): Remove.
(generate_builtin): Re-use the old loop exit edge to avoid
needing to update PHI nodes.

* gcc.dg/pr46177-2.c: New testcase.

From-SVN: r166492

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr46177-2.c [new file with mode: 0644]
gcc/tree-loop-distribution.c

index f4c868a9c5ddda2cc5ffe06b3eb2e54263617624..de4d48453e0429aac368305806585639541a9338 100644 (file)
@@ -1,3 +1,10 @@
+2010-11-09  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46177
+       * tree-loop-distribution.c (prop_phis): Remove.
+       (generate_builtin): Re-use the old loop exit edge to avoid
+       needing to update PHI nodes.
+
 2010-11-09  Joern Rennecke  <amylaar@spamcop.net>
 
        * ix86_expand_split_stack_prologue (args_size): Change type to
index 4214d4e27ef4787f26ee6f4327f2fba53da87ed6..70493d9c322ee68ed1df3c87c372e3b99553bffa 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-09  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46177
+       * gcc.dg/pr46177-2.c: New testcase.
+
 2010-11-09  Richard Guenther  <rguenther@suse.de>
 
        PR testsuite/46312
diff --git a/gcc/testsuite/gcc.dg/pr46177-2.c b/gcc/testsuite/gcc.dg/pr46177-2.c
new file mode 100644 (file)
index 0000000..91fd20e
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-copy-prop -ftree-loop-distribution" } */
+
+int A[30], B[30];
+
+void
+foo (int j)
+{
+  int i, k;
+  for (k = 0; k < 10; k++)
+    if (j)
+      {
+       for (; j < k; j++)
+         ;
+       for (i = 0; i < k; i++)
+         A[i] = B[i] = 0;
+      }
+}
index bc3f54d97d46abaffd278a6f6c7af128e71b9161..59585cdd761704308c33698163ac44707fa56c44 100644 (file)
@@ -311,31 +311,6 @@ generate_memset_zero (gimple stmt, tree op0, tree nb_iter,
   return res;
 }
 
-/* Propagate phis in BB b to their uses and remove them.  */
-
-static void
-prop_phis (basic_block b)
-{
-  gimple_stmt_iterator psi;
-
-  for (psi = gsi_start_phis (b); !gsi_end_p (psi); )
-    {
-      gimple phi = gsi_stmt (psi);
-      tree def = gimple_phi_result (phi);
-
-      if (!is_gimple_reg (def))
-       mark_virtual_phi_result_for_renaming (phi);
-      else
-       {
-         tree use = gimple_phi_arg_def (phi, 0);
-         gcc_assert (gimple_phi_num_args (phi) == 1);
-         replace_uses_by (def, use);
-       }
-
-      remove_phi_node (&psi, true);
-    }
-}
-
 /* Tries to generate a builtin function for the instructions of LOOP
    pointed to by the bits set in PARTITION.  Returns true when the
    operation succeeded.  */
@@ -405,11 +380,13 @@ generate_builtin (struct loop *loop, bitmap partition, bool copy_p)
   if (res && !copy_p)
     {
       unsigned nbbs = loop->num_nodes;
-      basic_block src = loop_preheader_edge (loop)->src;
-      basic_block dest = single_exit (loop)->dest;
-      prop_phis (dest);
-      make_edge (src, dest, EDGE_FALLTHRU);
+      edge exit = single_exit (loop);
+      basic_block src = loop_preheader_edge (loop)->src, dest = exit->dest;
+      redirect_edge_pred (exit, src);
+      exit->flags &= ~(EDGE_TRUE_VALUE|EDGE_FALSE_VALUE);
+      exit->flags |= EDGE_FALLTHRU;
       cancel_loop_tree (loop);
+      rescan_loop_exit (exit, false, true);
 
       for (i = 0; i < nbbs; i++)
        delete_basic_block (bbs[i]);