From patchwork Tue Oct 24 17:58:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 157654 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2112092vqx; Tue, 24 Oct 2023 10:59:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGE0CNQ38nXASo368VTLhnsH5y9k9YYuTYJBn9bMhIhCY+0RNeWcA25Rr6u1VM1i1CA6lDt X-Received: by 2002:a67:c092:0:b0:452:55f5:55e9 with SMTP id x18-20020a67c092000000b0045255f555e9mr13472157vsi.14.1698170345946; Tue, 24 Oct 2023 10:59:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698170345; cv=pass; d=google.com; s=arc-20160816; b=gr3Xxr+mSwkcRXB00/wAxUg3ZDk/E5sS+qxvM5BaWGWYutFMUrNuwtnn443LgIKV7+ Pb+VoTZwQWmzv48CtDCe+5MJPAbU2w368FU7yOdSr3kc6eQ8ExYeW+C3TS1IR6yreXxv ijpR9WxUirlDJ/GXBcfF/A4rT7n9R8Oh0X0hBxx/9nM/NXbb1UPSQRSyspK7ZW1XGZNT pfmcZDMAEsl0UlmnZTpCaIczZAg2G3ipn/FccWh7iKyOueCPO1VXejjKfuQSrpMU111Y QETKyLJ1PRi/xoC3bmrX1kiLi1arbTTCVvlIIBra4h7VVWvhRcnPYuH1sqotuSsFoxeg ns3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=DWMDAz2yBO7KQtzKNJWYAfmgJPWxSCimiCKRylOW7LE=; fh=WSfZ840Wi6BqtTz8VZjapJ1yCCJ9QRCfxSVxwOS9rLc=; b=R0OlFqmOTH3gY3hKNd4ggsoABHLNiDuLcUbR1mHwLDOYUqCeGSbaCPj3ZTBCHQ8PgG 48vb7jy6crNquiTQ2QO5ysR+6y/teQWHUFTdr7lPE4ipZjnwsPN2iCFi06IFnRScFwS8 pSRM5drZLiUCC9q7UGJMMAQcukgFekh/zZ1uyarul3BDBzsFavI0ekyhlKVYDzln+a4b N1HBPHte1+9A55/f6IugFxOi8g2ihuu2LFgEzxKysBiBScPfvlX/sELJMieXxhDDvope 3dTzoGhBzQitDNz1ginoCoRZXg/5BKYBVJxNkWMYUeROmxGrT+qgavG/YPiXmFX+6SPK AmjQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l9-20020a0cd6c9000000b0065afc346b27si7147653qvi.28.2023.10.24.10.59.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 10:59:05 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A5F3385DC15 for ; Tue, 24 Oct 2023 17:58:53 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id BEABA3858421 for ; Tue, 24 Oct 2023 17:58:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BEABA3858421 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BEABA3858421 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698170310; cv=none; b=DexueRPIBjDXIZxncM2WpuwX3DDqjJ2qzXoNM3/1cjILI53C7wuDfFTn/h5bsZSJ9PP0PTpgZqsSoPuQFQnTyKlCPY4oau6splyuDFmxBDOInTFLq0VUWa3A/hVcn0F6EtUDzJ1U3oryVKKQY7YAIyZE4YV/i+SallyGSpVd4RQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698170310; c=relaxed/simple; bh=TSpvnq/8AZb0DhMI2CFQg1Wa5X+PPdA2XbyHnWyFQoA=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=QdAKXrh6rFLSxBMsf83XThrFoPlm+fSNvfrlcPZxT18DiMR68nqwrsf6XUfERfnX+skBrMOZS1OKU8rx9biZvC7KUNhOh3CiaerA7X9TegloBnK+LrWCHpXuBhjgrMg7a/VXiuB05pVIcQD5EMBDo9Bg836SWrfUpNtBSMpBsds= ARC-Authentication-Results: i=1; server2.sourceware.org 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 9CA192F4; Tue, 24 Oct 2023 10:59:09 -0700 (PDT) Received: from e121540-lin.manchester.arm.com (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DF8003F64C; Tue, 24 Oct 2023 10:58:27 -0700 (PDT) From: Richard Sandiford To: jlaw@ventanamicro.com, gcc-patches@gcc.gnu.org Cc: Richard Sandiford Subject: [PATCH 2/3] rtl-ssa: Extend make_uses_available Date: Tue, 24 Oct 2023 18:58:04 +0100 Message-Id: <20231024175805.3359331-3-richard.sandiford@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231024175805.3359331-1-richard.sandiford@arm.com> References: <20231024175805.3359331-1-richard.sandiford@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-23.9 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780660668682898853 X-GMAIL-MSGID: 1780660668682898853 The first in-tree use of RTL-SSA was fwprop, and one of the goals was to make the fwprop rewrite preserve the old behaviour as far as possible. The switch to RTL-SSA was supposed to be a pure infrastructure change. So RTL-SSA has various FIXMEs for things that were artifically limited to faciliate the old-fwprop vs. new-fwprop comparison. One of the things that fwprop wants to do is extend live ranges, and function_info::make_use_available tried to keep within the cases that old fwprop could handle. Since the information is built in extended basic blocks, it's easy to handle intra-EBB queries directly. This patch does that, and removes the associated FIXME. To get a flavour for how much difference this makes, I tried compiling the testsuite at -Os for at least one target per supported CPU and OS. For most targets, only a handful of tests changed, but the vast majority of changes were positive. The only target that seemed to benefit significantly was i686-apple-darwin. The main point of the patch is to remove the FIXME and to enable the upcoming post-RA late-combine pass to handle more cases. gcc/ * rtl-ssa/functions.h (function_info::remains_available_at_insn): New member function. * rtl-ssa/accesses.cc (function_info::remains_available_at_insn): Likewise. (function_info::make_use_available): Avoid false negatives for queries within an EBB. --- gcc/rtl-ssa/accesses.cc | 37 +++++++++++++++++++++++++++++++++++-- gcc/rtl-ssa/functions.h | 4 ++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/gcc/rtl-ssa/accesses.cc b/gcc/rtl-ssa/accesses.cc index c35c7efb73d..1b25ecc3e23 100644 --- a/gcc/rtl-ssa/accesses.cc +++ b/gcc/rtl-ssa/accesses.cc @@ -1303,6 +1303,33 @@ function_info::insert_temp_clobber (obstack_watermark &watermark, return insert_access (watermark, clobber, old_defs); } +// See the comment above the declaration. +bool +function_info::remains_available_at_insn (const set_info *set, + insn_info *insn) +{ + auto *ebb = set->ebb (); + gcc_checking_assert (ebb == insn->ebb ()); + + def_info *next_def = set->next_def (); + if (next_def && *next_def->insn () < *insn) + return false; + + if (HARD_REGISTER_NUM_P (set->regno ()) + && TEST_HARD_REG_BIT (m_clobbered_by_calls, set->regno ())) + for (ebb_call_clobbers_info *call_group : ebb->call_clobbers ()) + { + if (!call_group->clobbers (set->resource ())) + continue; + + insn_info *call_insn = next_call_clobbers (*call_group, insn); + if (call_insn && *call_insn < *insn) + return false; + } + + return true; +} + // See the comment above the declaration. bool function_info::remains_available_on_exit (const set_info *set, bb_info *bb) @@ -1354,14 +1381,20 @@ function_info::make_use_available (use_info *use, bb_info *bb, if (is_single_dominating_def (def)) return use; - // FIXME: Deliberately limited for fwprop compatibility testing. + if (def->ebb () == bb->ebb ()) + { + if (remains_available_at_insn (def, bb->head_insn ())) + return use; + return nullptr; + } + basic_block cfg_bb = bb->cfg_bb (); bb_info *use_bb = use->bb (); if (single_pred_p (cfg_bb) && single_pred (cfg_bb) == use_bb->cfg_bb () && remains_available_on_exit (def, use_bb)) { - if (def->ebb () == bb->ebb () || will_be_debug_use) + if (will_be_debug_use) return use; resource_info resource = use->resource (); diff --git a/gcc/rtl-ssa/functions.h b/gcc/rtl-ssa/functions.h index ab253e750cb..ecb40fdaf57 100644 --- a/gcc/rtl-ssa/functions.h +++ b/gcc/rtl-ssa/functions.h @@ -121,6 +121,10 @@ public: // scope until the change has been aborted or successfully completed. obstack_watermark new_change_attempt () { return &m_temp_obstack; } + // SET and INSN belong to the same EBB, with SET occuring before INSN. + // Return true if SET is still available at INSN. + bool remains_available_at_insn (const set_info *set, insn_info *insn); + // SET either occurs in BB or is known to be available on entry to BB. // Return true if it is also available on exit from BB. (The value // might or might not be live.)