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>
Subject: [05/05] Fix PR 69102
Date: Mon, 14 Mar 2016 09:53:00 -0000	[thread overview]
Message-ID: <0ad96ef3-4296-d9db-7576-4366c83d0912@ispras.ru> (raw)
In-Reply-To: <d534c458-8456-51f7-2963-5d1faf112ffe@ispras.ru>

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

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?

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.diff --]
[-- Type: text/x-patch, Size: 2170 bytes --]

diff --git a/gcc/sel-sched-ir.c b/gcc/sel-sched-ir.c
index c1a9e55..b4aa933 100644
--- a/gcc/sel-sched-ir.c
+++ b/gcc/sel-sched-ir.c
@@ -3277,9 +3277,14 @@ has_dependence_note_reg_use (int regno)
 static void
 has_dependence_note_mem_dep (rtx mem ATTRIBUTE_UNUSED,
 			     rtx pending_mem ATTRIBUTE_UNUSED,
-			     insn_t pending_insn ATTRIBUTE_UNUSED,
+			     insn_t pending_insn,
 			     ds_t ds ATTRIBUTE_UNUSED)
 {
+  /* We're only interested in dependencies with the current producer.
+     We might get other insns that were saved in dependence context
+     as last_* or pending_* fields.  */
+  if (INSN_UID (pending_insn) != INSN_UID (has_dependence_data.pro))
+    return;
   if (!sched_insns_conditions_mutex_p (has_dependence_data.pro,
 				       VINSN_INSN_RTX (has_dependence_data.con)))
     {
@@ -3291,9 +3296,14 @@ has_dependence_note_mem_dep (rtx mem ATTRIBUTE_UNUSED,
 
 /* Note a dependence.  */
 static void
-has_dependence_note_dep (insn_t pro ATTRIBUTE_UNUSED,
+has_dependence_note_dep (insn_t pro,
 			 ds_t ds ATTRIBUTE_UNUSED)
 {
+  /* We're only interested in dependencies with the current producer.
+     We might get other insns that were saved in dependence context
+     as last_* or pending_* fields.  */
+  if (INSN_UID (pro) != INSN_UID (has_dependence_data.pro))
+    return;
   if (!sched_insns_conditions_mutex_p (has_dependence_data.pro,
 				       VINSN_INSN_RTX (has_dependence_data.con)))
     {
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr69102.c b/gcc/testsuite/gcc.c-torture/compile/pr69102.c
new file mode 100644
index 0000000..b1328ca
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr69102.c
@@ -0,0 +1,21 @@
+/* { dg-options "-Og -fPIC -fschedule-insns2 -fselective-scheduling2 -fno-tree-fre --param=max-sched-extend-regions-iters=10" } */
+void bar (unsigned int);
+
+void
+foo (void)
+{
+  char buf[1] = { 3 };
+  const char *p = buf;
+  const char **q = &p;
+  unsigned int ch;
+  switch (**q)
+    {
+    case 1:  ch = 5; break;
+    case 2:  ch = 4; break;
+    case 3:  ch = 3; break;
+    case 4:  ch = 2; break;
+    case 5:  ch = 1; break;
+    default: ch = 0; break;
+    }
+  bar (ch);
+}

  parent reply	other threads:[~2016-03-14  9:53 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 ` Andrey Belevantsev [this message]
2016-03-15 15:55   ` [05/05] Fix PR 69102 Andrey Belevantsev
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=0ad96ef3-4296-d9db-7576-4366c83d0912@ispras.ru \
    --to=abel@ispras.ru \
    --cc=amonakov@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    /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).