public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrey Belevantsev <abel@ispras.ru>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Alexander Monakov <amonakov@ispras.ru>,
	Bernd Schmidt <bernds@codesourcery.com>,
	Jeff Law <law@redhat.com>
Subject: Re: [05/05] Fix PR 69102
Date: Tue, 15 Mar 2016 15:55:00 -0000	[thread overview]
Message-ID: <7fe9ed9d-d431-cfe6-4708-c07bd23f893e@ispras.ru> (raw)
In-Reply-To: <0ad96ef3-4296-d9db-7576-4366c83d0912@ispras.ru>

[-- Attachment #1: Type: text/plain, Size: 2950 bytes --]

Hello,

On 14.03.2016 12:52, Andrey Belevantsev wrote:
> Hello,
>
> The problem here is readonly dependence contexts in selective scheduler.
> We're trying to cache the effect of initializing a dependence context with
> remembering that context and setting a readonly bit on it.  When first
> moving the insn 43 with REG_ARGS_SIZE note through the insn 3 (a simple eax
> set) we also set the last_args_size field of the context.  Later, when we
> make a copy of insn 43 and try to move it again through insn 3, we take the
> cached dependency context and notice the (fake) dep with last_args_size
> insn, which is the old insn 43.  Then the assert saying that we should be
> able to lift the bookkeeping copy up the same way as we did with the
> original insn breaks.
>
> Fixed by the attached patch that makes us notice only deps with the current
> producer insn.
>
> Ok for trunk?

We've discussed the patch with Alexander a bit and decided to take the 
different approach.  The core issue here is not handling the new 
last_args_size field in the readonly contexts.  In general, the readonly 
context approach, when analyzing an insn with a readonly context, would 
create the necessary dependencies with all of the last_ fields but refrain 
from modifying those fields.  The reason is we need to capture the effect 
of only the single producer in the readonly context.  Failing to do so may 
update the last_ fields with the effect of subsequent analyses and having 
the fake dependencies with the insns that got into those fields instead of 
having the dependencies with the currently used producer.

So the right fix here is to guard setting of the last_args_size field with 
!deps->readonly test as it is done elsewhere in the sched-deps.c.  In stage 
1 we will also want to set the asserts in the sel-sched dependency hooks 
(where I have placed early returns in the previous version of the patch) 
actually checking that the dependency is always created with the current 
producer, and such cases will be caught sooner.

The new patch bootstrapped and tested on x86-64 with selective scheduler 
forced enabled with no regressions.  It needs the maintainer outside of 
sel-sched as we touch sched-deps.c file.  Ok for trunk?  The test is the 
same as in previous patch.

Andrey

2016-03-15  Andrey Belevantsev  <abel@ispras.ru>

         PR rtl-optimization/69102
         * sched-deps.c (sched_analyze_insn): Do not set last_args_size field
         when we have a readonly dependency context.

>
> gcc/
>
> 2016-03-14  Andrey Belevantsev  <abel@ispras.ru>
>
>     PR rtl-optimization/69102
>     * sel-sched.c (has_dependence_note_dep): Only take into
>     account dependencies produced by the current producer insn.
>     (has_dependence_note_mem_dep): Likewise.
>
> testsuite/
>
> 2016-03-14  Andrey Belevantsev  <abel@ispras.ru>
>
>     PR rtl-optimization/69102
>     * gcc.c-torture/compile/pr69102.c: New test.
>
> Best,
> Andrey
>


[-- Attachment #2: 05-pr69102-2.diff --]
[-- Type: text/x-patch, Size: 424 bytes --]

diff --git a/gcc/sched-deps.c b/gcc/sched-deps.c
index 3d4a1d5..77ffcd0 100644
--- a/gcc/sched-deps.c
+++ b/gcc/sched-deps.c
@@ -3495,7 +3495,8 @@ sched_analyze_insn (struct deps_desc *deps, rtx x, rtx_insn *insn)
     {
       if (deps->last_args_size)
 	add_dependence (insn, deps->last_args_size, REG_DEP_OUTPUT);
-      deps->last_args_size = insn;
+      if (!deps->readonly)
+	deps->last_args_size = insn;
     }
 }
 

  reply	other threads:[~2016-03-15 15:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-14  9:11 Various selective scheduling fixes Andrey Belevantsev
2016-03-14  9:22 ` [01/05] Fix PR 64411 Andrey Belevantsev
2016-03-14 16:23   ` Alexander Monakov
2016-03-14 16:45     ` Bernd Schmidt
2016-03-15 15:43       ` Andrey Belevantsev
2016-03-14  9:32 ` [02/05] Fix PR 63384 Andrey Belevantsev
2016-03-14 17:13   ` Alexander Monakov
2016-03-15 17:30   ` Marek Polacek
2016-03-15 17:44     ` Alexander Monakov
2016-03-15 18:00       ` Andrey Belevantsev
2016-03-15 18:12         ` Alexander Monakov
2016-03-14  9:36 ` [03/05] Fix PR 66660 Andrey Belevantsev
2016-03-14 17:37   ` Alexander Monakov
2016-03-14  9:40 ` [04/05] Fix PR 69032 Andrey Belevantsev
2016-03-14 18:15   ` Alexander Monakov
2016-03-14  9:53 ` [05/05] Fix PR 69102 Andrey Belevantsev
2016-03-15 15:55   ` Andrey Belevantsev [this message]
2016-03-17 16:39     ` Jeff Law
2016-03-31 14:55 ` Various selective scheduling fixes Andrey Belevantsev
2016-04-01  7:33   ` Christophe Lyon
2016-04-01  8:55     ` Andrey Belevantsev
2016-04-01 13:09       ` Christophe Lyon
2016-04-01 13:12         ` Kyrill Tkachov
2016-04-01 13:26           ` Christophe Lyon
2016-04-01 16:19             ` Jeff Law
2016-04-01 20:08               ` Christophe Lyon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7fe9ed9d-d431-cfe6-4708-c07bd23f893e@ispras.ru \
    --to=abel@ispras.ru \
    --cc=amonakov@ispras.ru \
    --cc=bernds@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).