From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 69163 invoked by alias); 14 Mar 2016 09:53:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 67877 invoked by uid 89); 14 Mar 2016 09:53:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.3 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=UD:pro, selschedirc, UD:sel-sched-ir.c, insn_t X-HELO: mail.ispras.ru Received: from mail.ispras.ru (HELO mail.ispras.ru) (83.149.199.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Mar 2016 09:53:00 +0000 Received: from [10.10.3.52] (pluton2.ispras.ru [83.149.199.44]) by mail.ispras.ru (Postfix) with ESMTPSA id 1DC7854007B; Mon, 14 Mar 2016 12:52:57 +0300 (MSK) Subject: [05/05] Fix PR 69102 To: GCC Patches References: Cc: Alexander Monakov From: Andrey Belevantsev Message-ID: <0ad96ef3-4296-d9db-7576-4366c83d0912@ispras.ru> Date: Mon, 14 Mar 2016 09:53:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------28181BFEC843C7601DE82E7F" X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg00764.txt.bz2 This is a multi-part message in MIME format. --------------28181BFEC843C7601DE82E7F Content-Type: text/plain; charset=koi8-r; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1202 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 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 PR rtl-optimization/69102 * gcc.c-torture/compile/pr69102.c: New test. Best, Andrey --------------28181BFEC843C7601DE82E7F Content-Type: text/x-patch; name="05-pr69102.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="05-pr69102.diff" Content-length: 2170 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); +} --------------28181BFEC843C7601DE82E7F--