From patchwork Thu Mar 23 08:07:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jin Ma X-Patchwork-Id: 1760176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=HgCi1Cf2; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Phydr04kWz1yXt for ; Thu, 23 Mar 2023 19:08:30 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 085A5387088B for ; Thu, 23 Mar 2023 08:08:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 085A5387088B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679558907; bh=Sd1AEb9U+E4AJRu+iOh/FEAsFZAaRG9mCgpHjTLZ2xw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=HgCi1Cf2Za8s55KJXDqAXlEE6j5TdxBXd2lkcv4ubEzSAFppJ0MkBpfeCq1HFbWwl 4RnaETx5VoCSrd3mrR4VQ+tIjKs/a/GMmHnU36YBF0sVPnxlnPAbrGAkg1CGxqQ16r CFRO7xZ/mKaN8S8YvuFYmnvz0r4CX3yxYGPYfheY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) by sourceware.org (Postfix) with ESMTPS id 0390D385B516 for ; Thu, 23 Mar 2023 08:08:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0390D385B516 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R351e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046056; MF=jinma@linux.alibaba.com; NM=1; PH=DS; RN=7; SR=0; TI=SMTPD_---0VeTcepU_1679558880; Received: from localhost.localdomain(mailfrom:jinma@linux.alibaba.com fp:SMTPD_---0VeTcepU_1679558880) by smtp.aliyun-inc.com; Thu, 23 Mar 2023 16:08:02 +0800 To: gcc-patches@gcc.gnu.org Cc: kito.cheng@sifive.com, kito.cheng@gmail.com, palmer@dabbelt.com, jeffreyalaw@gmail.com, ijinma@yeah.net, Jin Ma Subject: [PATCH] In the ready lists of pipeline, put unrecog insns (such as CLOBBER, USE) at the latest to issue. Date: Thu, 23 Mar 2023 16:07:34 +0800 Message-Id: <20230323080734.423-1-jinma@linux.alibaba.com> X-Mailer: git-send-email 2.38.1.windows.1 MIME-Version: 1.0 X-Spam-Status: No, score=-21.2 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jin Ma via Gcc-patches From: Jin Ma Reply-To: Jin Ma Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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. 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