From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 76C4E3858C83 for ; Mon, 27 Mar 2023 17:01:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 76C4E3858C83 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2AAECC14; Mon, 27 Mar 2023 10:02:02 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E78A93F6C4; Mon, 27 Mar 2023 10:01:16 -0700 (PDT) From: Richard Sandiford To: Jin Ma via Gcc-patches Mail-Followup-To: Jin Ma via Gcc-patches ,Jin Ma , "kito.cheng\@sifive.com" , "kito.cheng\@gmail.com" , "palmer\@dabbelt.com" , "jeffreyalaw\@gmail.com" , "ijinma\@yeah.net" , richard.sandiford@arm.com Cc: Jin Ma , "kito.cheng\@sifive.com" , "kito.cheng\@gmail.com" , "palmer\@dabbelt.com" , "jeffreyalaw\@gmail.com" , "ijinma\@yeah.net" Subject: Re: [PATCH] In the ready lists of pipeline, put unrecog insns (such as CLOBBER, USE) at the latest to issue. References: <20230323080734.423-1-jinma@linux.alibaba.com> Date: Mon, 27 Mar 2023 18:01:15 +0100 In-Reply-To: <20230323080734.423-1-jinma@linux.alibaba.com> (Jin Ma via Gcc-patches's message of "Thu, 23 Mar 2023 08:07:34 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-33.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Jin Ma via Gcc-patches writes: > Unrecog insns (such as CLOBBER, USE) does not represent real instructions, but in the > process of pipeline optimization, they will wait for transmission in ready list like > other insns, without considering resource conflicts and cycles. This results in a > multi-issue CPU architecture that can be issued at any time if other regular insns > have resource conflicts or cannot be launched for other reasons. As a result, its > position is advanced in the generated insns sequence, which will affect register > allocation and often lead to more redundant mov instructions. Is it the clobber rather than the use case that is causing problems? I would expect that scheduling a use ASAP would be better for register pressure, since it might close off the associated live range and so reduce the number of conflicts. I.e. is the problem that, when a live range starts with a clobber, the current code will tend to move the clobber up and so extend the associated live range? If so, that sounds like something we should address more directly, for two reasons: (1) We should try to prevent clobbers that start a live range from being moved up even if first_cycle_insn_p. (2) Clobbers can also be used to close off a live range, which is useful if a pseudo is only written to in parts. The current behaviour is probably better for those clobbers. In general, if you're hitting register pressure problems with scheduling, have you tried enabling -fsched-pressure by default, possibly with --param=sched-pressure-algorithm=2 (but try with the default algo too)? Thanks, Richard > > gcc/ChangeLog: > > * haifa-sched.cc (prune_ready_list): Consider unrecog insns(CLOBBER and USE) > in pruning ready lists. > --- > gcc/haifa-sched.cc | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/gcc/haifa-sched.cc b/gcc/haifa-sched.cc > index 48b53776fa9..72c4c44da76 100644 > --- a/gcc/haifa-sched.cc > +++ b/gcc/haifa-sched.cc > @@ -6318,6 +6318,14 @@ prune_ready_list (state_t temp_state, bool first_cycle_insn_p, > cost = 1; > reason = "not a shadow"; > } > + else if (recog_memoized (insn) < 0 > + && (GET_CODE (PATTERN (insn)) == CLOBBER > + || GET_CODE (PATTERN (insn)) == USE)) > + { > + if (!first_cycle_insn_p) > + cost = 1; > + reason = "unrecog insn"; > + } > else if (recog_memoized (insn) < 0) > { > if (!first_cycle_insn_p