sel-sched: fixup reset of first_insn (PR 85876)
authorAndrey Belevantsev <abel@ispras.ru>
Tue, 2 Apr 2019 15:39:22 +0000 (18:39 +0300)
committerAlexander Monakov <amonakov@gcc.gnu.org>
Tue, 2 Apr 2019 15:39:22 +0000 (18:39 +0300)
2019-04-02  Andrey Belevantsev  <abel@ispras.ru>

PR rtl-optimization/85876
* sel-sched.c (code_motion_path_driver): Avoid unwinding first_insn
beyond the original fence.

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

From-SVN: r270095

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

index 4cdb8029514fccf04a7a70bf596953f1195e0cc6..e02099715e3ee09157623735f9ebcd5fcd001732 100644 (file)
@@ -1,3 +1,9 @@
+2019-04-02  Andrey Belevantsev  <abel@ispras.ru>
+
+       PR rtl-optimization/85876
+       * sel-sched.c (code_motion_path_driver): Avoid unwinding first_insn
+       beyond the original fence.
+
 2019-04-02  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * config.gcc: Mark spu* targets as deprecated/obsolete.
index 552dd0b92636563ae841d635ed700c05e1513d43..f6e94bfc15c1a346a890c5a5a6a35acddebb97e0 100644 (file)
@@ -6439,7 +6439,7 @@ code_motion_path_driver (insn_t insn, av_set_t orig_ops, ilist_t path,
 {
   expr_t expr = NULL;
   basic_block bb = BLOCK_FOR_INSN (insn);
-  insn_t first_insn, bb_tail, before_first;
+  insn_t first_insn, original_insn, bb_tail, before_first;
   bool removed_last_insn = false;
 
   if (sched_verbose >= 6)
@@ -6523,7 +6523,7 @@ code_motion_path_driver (insn_t insn, av_set_t orig_ops, ilist_t path,
   /* It is enough to place only heads and tails of visited basic blocks into
      the PATH.  */
   ilist_add (&path, insn);
-  first_insn = insn;
+  first_insn = original_insn = insn;
   bb_tail = sel_bb_end (bb);
 
   /* Descend the basic block in search of the original expr; this part
@@ -6630,6 +6630,8 @@ code_motion_path_driver (insn_t insn, av_set_t orig_ops, ilist_t path,
         {
           insn = sel_bb_end (bb);
           first_insn = sel_bb_head (bb);
+         if (first_insn != original_insn)
+           first_insn = original_insn;
         }
 
       /* Remove bb tail from path.  */
index 25b8acb0a01c82c3aaf4ba2072d59af15c24a154..04d9de4473499469f4f4ddfe63c43352af8c5270 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-02  Andrey Belevantsev  <abel@ispras.ru>
+
+       PR rtl-optimization/85876
+       * gcc.dg/pr85876.c: New test.
+
 2019-04-02  Andreas Krebbel  <krebbel@linux.ibm.com>
 
        * gcc.target/s390/zvector/vec-double-compile.c: New test.
diff --git a/gcc/testsuite/gcc.dg/pr85876.c b/gcc/testsuite/gcc.dg/pr85876.c
new file mode 100644 (file)
index 0000000..64618e5
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fschedule-insns -fsel-sched-pipelining -fselective-scheduling -fno-if-conversion -fno-tree-dce" } */
+/* { dg-additional-options "-march=bdver1" { target i?86-*-* x86_64-*-* } } */
+
+int ov, rq, ac;
+
+int
+y2 (int);
+
+void
+f8 (int vn)
+{
+  while (rq < 1)
+    {
+      ov *= y2 (ac);
+      vn += (!!ov && !!ac) + ac;
+    }
+}