sel-sched: skip outer loop in get_all_loop_exits (PR 84206)
authorAndrey Belevantsev <abel@ispras.ru>
Tue, 2 Apr 2019 15:45:57 +0000 (18:45 +0300)
committerAlexander Monakov <amonakov@gcc.gnu.org>
Tue, 2 Apr 2019 15:45:57 +0000 (18:45 +0300)
2019-04-02  Andrey Belevantsev  <abel@ispras.ru>

PR rtl-optimization/84206
* sel-sched-ir.h (get_all_loop_exits): Avoid the outer loop when
iterating over loop headers.

* gcc.dg/pr84206.c: New test.

From-SVN: r270096

gcc/ChangeLog
gcc/sel-sched-ir.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr84206.c [new file with mode: 0644]

index e02099715e3ee09157623735f9ebcd5fcd001732..f36a769e354bfb116e284bae1c7af62b06d80cb9 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-02  Andrey Belevantsev  <abel@ispras.ru>
+
+       PR rtl-optimization/84206
+       * sel-sched-ir.h (get_all_loop_exits): Avoid the outer loop when
+       iterating over loop headers.
+
 2019-04-02  Andrey Belevantsev  <abel@ispras.ru>
 
        PR rtl-optimization/85876
index 1d9c04a322a219869d826df43415eec9ea8b79a0..5dd273f40a43c7d9a4e15ff35d383f13fe037f37 100644 (file)
@@ -1144,6 +1144,7 @@ get_all_loop_exits (basic_block bb)
       struct loop *this_loop;
       struct loop *pred_loop = NULL;
       int i;
+      unsigned this_depth;
       edge e;
 
       for (this_loop = bb->loop_father;
@@ -1155,11 +1156,14 @@ get_all_loop_exits (basic_block bb)
       gcc_assert (this_loop != NULL);
 
       exits = get_loop_exit_edges_unique_dests (this_loop);
+      this_depth = loop_depth (this_loop);
 
-      /* Traverse all loop headers.  */
+      /* Traverse all loop headers.  Be careful not to go back
+        to the outer loop's header (see PR 84206).  */
       for (i = 0; exits.iterate (i, &e); i++)
-       if (in_current_region_p (e->dest)
-           || inner_loop_header_p (e->dest))
+       if ((in_current_region_p (e->dest)
+            || (inner_loop_header_p (e->dest)))
+           && loop_depth (e->dest->loop_father) >= this_depth)
          {
            vec<edge> next_exits = get_all_loop_exits (e->dest);
 
index 04d9de4473499469f4f4ddfe63c43352af8c5270..6e26cbe272dc99a7f507e42a88f7cbb8c8fbdf5e 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-02  Andrey Belevantsev  <abel@ispras.ru>
+
+       PR rtl-optimization/84206
+       * gcc.dg/pr84206.c: New test.
+
 2019-04-02  Andrey Belevantsev  <abel@ispras.ru>
 
        PR rtl-optimization/85876
diff --git a/gcc/testsuite/gcc.dg/pr84206.c b/gcc/testsuite/gcc.dg/pr84206.c
new file mode 100644 (file)
index 0000000..b4ac9c2
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fselective-scheduling -fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -fno-forward-propagate -fno-tree-fre -w" } */
+
+long long unsigned int ao;
+int hk;
+
+void
+b8 (void)
+{
+  int *w9;
+
+ c8:
+  ao = 0;
+  w9 = &ao;
+  for (;;)
+    for (hk = 0; hk < 1; ++hk)
+      for (ao = 0; ao < 4; ++ao)
+        {
+          int f4 = (ao != 0) ? *w9 : hk;
+
+          if (f4 != 0)
+            goto c8;
+        }
+}