re PR tree-optimization/84111 (Compile time hog w/ -O2)
authorJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 Jan 2018 15:58:22 +0000 (16:58 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 Jan 2018 15:58:22 +0000 (16:58 +0100)
PR tree-optimization/84111
* tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely_1): Skip
inner loops added during recursion, as they don't have up-to-date
SSA form.

* gcc.c-torture/compile/pr84111.c: New test.

From-SVN: r257188

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr84111.c [new file with mode: 0644]
gcc/tree-ssa-loop-ivcanon.c

index dc75ffab7c8fe1beab4cac885519e63188c9c8c8..0d2e8d53139bf5fee5676aa9b9591faba8bc0ea4 100644 (file)
@@ -1,3 +1,11 @@
+2018-01-30  Richard Biener  <rguenther@suse.de>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/84111
+       * tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely_1): Skip
+       inner loops added during recursion, as they don't have up-to-date
+       SSA form.
+
 2018-01-30  Jan Hubicka  <hubicka@ucw.cz>
 
        PR ipa/81360
index a963d4b527d1cd662229f0b69355e7fc2aab4852..c348529ea9bcc1d4c1acc72423e61afb3f85659d 100644 (file)
@@ -1,3 +1,8 @@
+2018-01-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/84111
+       * gcc.c-torture/compile/pr84111.c: New test.
+
 2018-01-30  Jan Hubicka  <hubicka@ucw.cz>
 
        PR ipa/83179
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr84111.c b/gcc/testsuite/gcc.c-torture/compile/pr84111.c
new file mode 100644 (file)
index 0000000..51f598f
--- /dev/null
@@ -0,0 +1,31 @@
+/* PR tree-optimization/84111 */
+
+void
+foo (int x, int y, int z)
+{
+  int a = 0;
+  int *b = &x;
+
+  while (a < 1)
+    {
+      int c = y;
+      *b = x;
+ lab:
+      for (a = 0; a < 36; ++a)
+        {
+          *b = 0;
+          if (x != 0)
+            y = 0;
+          while (c < 1)
+           ;
+        }
+    }
+  if (z < 33)
+    {
+      b = (int *) 0;
+      ++y;
+      ++z;
+      if (x / *b != 0)
+        goto lab;
+    }
+}
index a87ed0b920bdee8202ee37318de454f6b1f7e272..24bf60eaa49291c57d5271babdabbc1d62e89c9d 100644 (file)
@@ -1373,13 +1373,17 @@ tree_unroll_loops_completely_1 (bool may_increase_size, bool unroll_outer,
   bool changed = false;
   struct loop *inner;
   enum unroll_level ul;
+  unsigned num = number_of_loops (cfun);
 
-  /* Process inner loops first.  */
+  /* Process inner loops first.  Don't walk loops added by the recursive
+     calls because SSA form is not up-to-date.  They can be handled in the
+     next iteration.  */
   for (inner = loop->inner; inner != NULL; inner = inner->next)
-    changed |= tree_unroll_loops_completely_1 (may_increase_size,
-                                              unroll_outer, father_bbs,
-                                              inner);
+    if ((unsigned) inner->num < num)
+      changed |= tree_unroll_loops_completely_1 (may_increase_size,
+                                                unroll_outer, father_bbs,
+                                                inner);
+
   /* If we changed an inner loop we cannot process outer loops in this
      iteration because SSA form is not up-to-date.  Continue with
      siblings of outer loops instead.  */