]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Guenther <rguenther@suse.de>
Fri, 12 Nov 2010 14:43:19 +0000 (14:43 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 12 Nov 2010 14:43:19 +0000 (14:43 +0000)
2010-11-12  Richard Guenther  <rguenther@suse.de>

Backport from mainline
2010-11-09  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/46355
* tree-loop-distribution.c (tree_loop_distribution): Do not
distribute loops without a single exit.

* gcc.dg/pr46355.c: New testcase.

2010-11-02  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/46177
* tree-loop-distribution.c (prop_phis): Use
mark_virtual_phi_result_for_renaming.

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

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: r166652

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

index ad047e8197c26ba8e421ae9a996950829d19a51d..5394bbd8f0a3ffb574a61cb4aeb1a840ccef5cb7 100644 (file)
@@ -1,3 +1,25 @@
+2010-11-12  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline
+       2010-11-09  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46355
+       * tree-loop-distribution.c (tree_loop_distribution): Do not
+       distribute loops without a single exit.
+
+       2010-11-02  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46177
+       * tree-loop-distribution.c (prop_phis): Use
+       mark_virtual_phi_result_for_renaming.
+
+       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-11  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
index 067b1f1398ee05bcf0e37b85d226d5c253db3ba5..d87711af61f4e96d3b44ca8ff7cf7649d870154c 100644 (file)
@@ -1,3 +1,21 @@
+2010-11-12  Richard Guenther  <rguenther@suse.de>
+
+       Backport from mainline
+       2010-11-09  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46355
+       * gcc.dg/pr46355.c: New testcase.
+
+       2010-11-02  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46177
+       * gcc.dg/pr46177.c: New testcase.
+
+       2010-11-09  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/46177
+       * gcc.dg/pr46177-2.c: New testcase.
+
 2010-11-11  Jakub Jelinek  <jakub@redhat.com>
 
        Backport from mainline
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;
+      }
+}
diff --git a/gcc/testsuite/gcc.dg/pr46177.c b/gcc/testsuite/gcc.dg/pr46177.c
new file mode 100644 (file)
index 0000000..f1c4d1e
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-copy-prop -ftree-loop-distribution t.c" } */
+
+extern int A[];
+extern int B[];
+
+void
+foo (int j, int c)
+{
+  int i;
+
+  if (c)
+    for (i = 0; i < j; i++)
+      A[i] = B[i] = 0;
+
+  for (i = 0; i < j; i++)
+    A[i] = B[i];
+}
diff --git a/gcc/testsuite/gcc.dg/pr46355.c b/gcc/testsuite/gcc.dg/pr46355.c
new file mode 100644 (file)
index 0000000..e644ec5
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O -ftree-loop-distribution -fstrict-overflow" } */
+
+void
+foo (int *dest, int i, int u, int v)
+{
+  int j = i;
+  while (i)
+    {
+      dest[j--] = v;
+      dest[j--] = u;
+    }
+}
+
index 238024d44ce296b0382a9677d25bbb21b6463bd5..a328860f70052b67522b7abb6cd1e4ba80c224f1 100644 (file)
@@ -321,38 +321,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;
-  gimple_seq phis = phi_nodes (b);
-
-  for (psi = gsi_start (phis); !gsi_end_p (psi); )
-    {
-      gimple phi = gsi_stmt (psi);
-      tree def = gimple_phi_result (phi), use = gimple_phi_arg_def (phi, 0);
-
-      gcc_assert (gimple_phi_num_args (phi) == 1);
-
-      if (!is_gimple_reg (def))
-       {
-         imm_use_iterator iter;
-         use_operand_p use_p;
-         gimple stmt;
-
-         FOR_EACH_IMM_USE_STMT (stmt, iter, def)
-           FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
-             SET_USE (use_p, use);
-       }
-      else
-       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.  */
@@ -422,11 +390,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]);
@@ -1192,7 +1162,12 @@ tree_loop_distribution (void)
 
   FOR_EACH_LOOP (li, loop, 0)
     {
-      VEC (gimple, heap) *work_list = VEC_alloc (gimple, heap, 3);
+      VEC (gimple, heap) *work_list = NULL;
+
+      /* If the loop doesn't have a single exit we will fail anyway,
+        so do that early.  */
+      if (!single_exit (loop))
+       continue;
 
       /* With the following working list, we're asking distribute_loop
         to separate the stores of the loop: when dependences allow,