diff mbox series

Fix PR 85423 (Re: Fix PRs 80463, 83972, 83480)

Message ID 79a550e3-d3ab-6319-6ae5-0ef20a0286b8@ispras.ru
State New
Headers show
Series Fix PR 85423 (Re: Fix PRs 80463, 83972, 83480) | expand

Commit Message

Andrey Belevantsev April 23, 2018, 2:03 p.m. UTC
Hello,

So this PR shows that I have incorrectly mirrored the conditional from
sched-deps.c that creates the dependence from a debug insn on the previous
insn (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80463#c3 for the
hunk).  Thus we have incorrectly discarded some legitimate debug-debug
dependencies.  The straightforward fix works for all of four PRs, tested on
x86-64.

I have put the test in gcc.dg though it requires -march=nano.  Do you want
me to create an extra machine-dependent test?

Best,
Andrey

2018-04-23  Andrey Belevantsev  <abel@ispras.ru>

        PR rtl-optimization/85423

        * sel-sched-ir.c (has_dependence_note_mem_dep): Only discard
        dependencies to debug insns when previous insn is non-debug.

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

Comments

Jakub Jelinek April 23, 2018, 2:08 p.m. UTC | #1
On Mon, Apr 23, 2018 at 05:03:09PM +0300, Andrey Belevantsev wrote:
> I have put the test in gcc.dg though it requires -march=nano.  Do you want
> me to create an extra machine-dependent test?

If it is a compile time test, no need for that.
Just add
/* { dg-additional-options "-march=nano" { target i?86-*-* x86_64-*-* } } */

	Jakub
Alexander Monakov April 23, 2018, 2:26 p.m. UTC | #2
On Mon, 23 Apr 2018, Andrey Belevantsev wrote:

> Hello,
> 
> So this PR shows that I have incorrectly mirrored the conditional from
> sched-deps.c that creates the dependence from a debug insn on the previous
> insn (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80463#c3 for the
> hunk).  Thus we have incorrectly discarded some legitimate debug-debug
> dependencies.  The straightforward fix works for all of four PRs, tested on
> x86-64.
> 
> I have put the test in gcc.dg though it requires -march=nano.  Do you want
> me to create an extra machine-dependent test?

I see Jakub addressed this question (thanks!) so please incorporate his
suggestion.  There's also a typo in the ChangeLog, OK with that fixed.

Alexander

> 2018-04-23  Andrey Belevantsev  <abel@ispras.ru>
> 
>         PR rtl-optimization/85423
> 
>        * sel-sched-ir.c (has_dependence_note_mem_dep): Only discard

Should be "has_dependence_note_dep" (without the "mem_" ;)

Alexander
diff mbox series

Patch

diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index ee970522890..85ff5bd3eb4 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -3308,7 +3308,7 @@  has_dependence_note_dep (insn_t pro, ds_t ds ATTRIBUTE_UNUSED)
      that a bookkeeping copy should be movable as the original insn.
      Detect that here and allow that movement if we allowed it before
      in the first place.  */
-  if (DEBUG_INSN_P (real_con)
+  if (DEBUG_INSN_P (real_con) && !DEBUG_INSN_P (real_pro)
       && INSN_UID (NEXT_INSN (pro)) == INSN_UID (real_con))
     return;
 
diff --git a/gcc/testsuite/gcc.dg/pr85423.c b/gcc/testsuite/gcc.dg/pr85423.c
new file mode 100644
index 00000000000..21d4a2eb4b9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr85423.c
@@ -0,0 +1,26 @@ 
+/* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fselective-scheduling2 -fvar-tracking-assignments -fno-guess-branch-probability -fno-peephole2 -fno-ssa-phiopt -fno-tree-pre --param max-jump-thread-duplication-stmts=8 -w" } */
+
+int vn, xm;
+
+void
+i1 (int);
+
+void
+mb (int *ap, int ev)
+{
+  while (vn < 1)
+    {
+      i1 (vn);
+
+      ev += *ap && ++vn;
+
+      while (xm < 1)
+        ++xm;
+
+      if (*ap == 0)
+        *ap = ev;
+
+      ++vn;
+    }
+}