]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/61607 (DOM missed jump threading and destroyed loops)
authorRichard Biener <rguenther@suse.de>
Thu, 26 Jun 2014 11:29:34 +0000 (11:29 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 26 Jun 2014 11:29:34 +0000 (11:29 +0000)
2014-06-26  Richard Biener  <rguenther@suse.de>

PR tree-optimization/61607
* tree-ssa-copy.c (copy_prop_visit_phi_node): Adjust comment
explaining why we restrict copies on loop depth.
* tree-ssa-dom.c (cprop_operand): Remove restriction on
on loop depth.
(record_equivalences_from_phis): Instead add it here.

* gcc.dg/tree-ssa/ssa-dom-thread-5.c: New testcase.

From-SVN: r212026

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-5.c [new file with mode: 0644]
gcc/tree-ssa-copy.c
gcc/tree-ssa-dom.c

index e3a5b77c0bdd6d5b647cc9d2f3d2f56a16b9c283..e7ced0c453254a05c7e3e16857d92dd054eed818 100644 (file)
@@ -1,3 +1,12 @@
+2014-06-26  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/61607
+       * tree-ssa-copy.c (copy_prop_visit_phi_node): Adjust comment
+       explaining why we restrict copies on loop depth.
+       * tree-ssa-dom.c (cprop_operand): Remove restriction on
+       on loop depth.
+       (record_equivalences_from_phis): Instead add it here.
+
 2014-06-26  Bernd Schmidt  <bernds@codesourcery.com>
 
         * Makefile.in (COLLECT2_OBJS): Add collect-utils.o.
index 3b5cd4f9bc98ea1ad39ecfc23ece58cca29ec59d..5266253595b017ebd574abc68b1fe94f23d72bfa 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-26  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/61607
+       * gcc.dg/tree-ssa/ssa-dom-thread-5.c: New testcase.
+
 2014-06-26  Vidya Praveen  <vidyapraveen@arm.com>
 
        * gcc.dg/inline-22.c: Add bind_pic_locally.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-5.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-5.c
new file mode 100644 (file)
index 0000000..9a984d4
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-Os -fno-tree-fre -fdump-tree-dom1-details" } */
+
+void foo(int *);
+void f2(int dst[3], int R)
+{
+  int i, inter[2];
+  _Bool inter0p = 0;
+  _Bool inter1p = 0;
+  for (i = 1; i < R; i++)
+    {
+      inter0p = 1;
+      inter1p = 1;
+    }
+  if (inter0p)
+    inter[0] = 1;
+  if (inter1p)
+    inter[1] = 1;
+  foo(inter);
+}
+
+/* { dg-final { scan-tree-dump "Threaded jump" "dom1" } } */
+/* { dg-final { cleanup-tree-dump "dom1" } } */
index 1d404d27b14488512deaae84d8a281b82b284e79..0ba665bbe9188dc8143c97587511b25a2bf59de1 100644 (file)
@@ -401,11 +401,8 @@ copy_prop_visit_phi_node (gimple phi)
        arg_value = valueize_val (arg);
 
       /* Avoid copy propagation from an inner into an outer loop.
-        Otherwise, this may move loop variant variables outside of
-        their loops and prevent coalescing opportunities.  If the
-        value was loop invariant, it will be hoisted by LICM and
-        exposed for copy propagation.
-        ???  The value will be always loop invariant.
+        Otherwise, this may introduce uses of loop variant variables
+        outside of their loops and prevent coalescing opportunities.
         In loop-closed SSA form do not copy-propagate through
         PHI nodes in blocks with a loop exit edge predecessor.  */
       if (TREE_CODE (arg_value) == SSA_NAME
index 62444b262de119763691cd0f1e093eff7d459c56..795ed09ae86b0dd6e4adec66cad9410b6be53de3 100644 (file)
@@ -1234,7 +1234,13 @@ record_equivalences_from_phis (basic_block bb)
         this, since this is a true assignment and not an equivalence
         inferred from a comparison.  All uses of this ssa name are dominated
         by this assignment, so unwinding just costs time and space.  */
-      if (i == gimple_phi_num_args (phi) && may_propagate_copy (lhs, rhs))
+      if (i == gimple_phi_num_args (phi)
+         && may_propagate_copy (lhs, rhs)
+         /* Do not propagate copies if the propagated value is at a deeper loop
+            depth than the propagatee.  Otherwise, this may introduce uses
+            of loop variant variables outside of their loops and prevent
+            coalescing opportunities.  */
+         && !(loop_depth_of_name (rhs) > loop_depth_of_name (lhs)))
        set_ssa_name_value (lhs, rhs);
     }
 }
@@ -2247,14 +2253,6 @@ cprop_operand (gimple stmt, use_operand_p op_p)
       if (!may_propagate_copy (op, val))
        return;
 
-      /* Do not propagate copies if the propagated value is at a deeper loop
-        depth than the propagatee.  Otherwise, this may move loop variant
-        variables outside of their loops and prevent coalescing
-        opportunities.  If the value was loop invariant, it will be hoisted
-        by LICM and exposed for copy propagation.  */
-      if (loop_depth_of_name (val) > loop_depth_of_name (op))
-       return;
-
       /* Do not propagate copies into simple IV increment statements.
          See PR23821 for how this can disturb IV analysis.  */
       if (TREE_CODE (val) != INTEGER_CST