re PR tree-optimization/84552 (Compile time hog w/ -O2 -floop-nest-optimize -fno...
authorRichard Biener <rguenther@suse.de>
Thu, 8 Mar 2018 14:41:39 +0000 (14:41 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 8 Mar 2018 14:41:39 +0000 (14:41 +0000)
2018-03-08  Richard Biener  <rguenther@suse.de>

PR middle-end/84552
* tree-scalar-evolution.c: Include tree-into-ssa.h.
(follow_copies_to_constant): Do not follow SSA names registered
for update.

* gcc.dg/graphite/pr84552.c: New testcase.

From-SVN: r258365

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/graphite/pr84552.c [new file with mode: 0644]
gcc/tree-scalar-evolution.c

index bfff935905f03a868e15ebe29a7f81187215d3b8..0d60c551f4780c7e1b3d4665089cabf06a0a6db2 100644 (file)
@@ -1,3 +1,10 @@
+2018-03-08  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/84552
+       * tree-scalar-evolution.c: Include tree-into-ssa.h.
+       (follow_copies_to_constant): Do not follow SSA names registered
+       for update.
+
 2018-03-08  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/84178
index 3abed3cdbeb720389b8b5053748623c879ed8467..5a5c31a2f6b61c134ec9796aef761eb2ab4b4ed2 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-08  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/84552
+       * gcc.dg/graphite/pr84552.c: New testcase.
+
 2018-03-08  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/84178
diff --git a/gcc/testsuite/gcc.dg/graphite/pr84552.c b/gcc/testsuite/gcc.dg/graphite/pr84552.c
new file mode 100644 (file)
index 0000000..15cbb08
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-nest-optimize -fno-tree-copy-prop -fno-tree-fre -fno-tree-loop-ivcanon" } */
+
+int cx;
+
+int
+e6 (int pj, int xe)
+{
+  for (cx = 0; cx < 2; ++cx)
+    while (xe < 1)
+      {
+       for (cx = 0; cx < 2; ++cx)
+         pj *= 2;
+
+       if (cx != 0)
+         goto o3;
+
+       ++xe;
+      }
+
+o3:
+  return pj;
+}
index 0ba1aa8359adccf0e451ab55244a6320962092d8..fefc9de96af3da9080eb8bd32df1f1c27e09ae70 100644 (file)
@@ -280,6 +280,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "params.h"
 #include "tree-ssa-propagate.h"
 #include "gimple-fold.h"
+#include "tree-into-ssa.h"
 
 static tree analyze_scalar_evolution_1 (struct loop *, tree);
 static tree analyze_scalar_evolution_for_address_of (struct loop *loop,
@@ -1540,7 +1541,10 @@ static tree
 follow_copies_to_constant (tree var)
 {
   tree res = var;
-  while (TREE_CODE (res) == SSA_NAME)
+  while (TREE_CODE (res) == SSA_NAME
+        /* We face not updated SSA form in multiple places and this walk
+           may end up in sibling loops so we have to guard it.  */
+        && !name_registered_for_update_p (res))
     {
       gimple *def = SSA_NAME_DEF_STMT (res);
       if (gphi *phi = dyn_cast <gphi *> (def))