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 3B4D43A1982F for ; Fri, 13 Nov 2020 08:21:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3B4D43A1982F 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 E7F9E142F for ; Fri, 13 Nov 2020 00:21:29 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 90E7E3F718 for ; Fri, 13 Nov 2020 00:21:29 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [20/23] rtlanal: Add simple_regno_set References: Date: Fri, 13 Nov 2020 08:21:27 +0000 In-Reply-To: (Richard Sandiford's message of "Fri, 13 Nov 2020 08:10:54 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Fri, 13 Nov 2020 08:21:31 -0000 This patch adds a routine for finding a =E2=80=9Csimple=E2=80=9D SET for a = register definition. See the comment in the patch for details. gcc/ * rtl.h (simple_regno_set): Declare. * rtlanal.c (simple_regno_set): New function. --- gcc/rtl.h | 1 + gcc/rtlanal.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/gcc/rtl.h b/gcc/rtl.h index e9df95b02c4..3915fae61e7 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3539,6 +3539,7 @@ extern void set_insn_deleted (rtx_insn *); /* Functions in rtlanal.c */ =20 extern rtx single_set_2 (const rtx_insn *, const_rtx); +extern rtx simple_regno_set (rtx, unsigned int); extern bool contains_symbol_ref_p (const_rtx); extern bool contains_symbolic_reference_p (const_rtx); extern bool contains_constant_pool_address_p (const_rtx); diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 404813b7668..80e72d6049d 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -1455,6 +1455,39 @@ set_of (const_rtx pat, const_rtx insn) return data.found; } =20 +/* Check whether instruction pattern PAT contains a SET with the following + properties: + + - the SET is executed unconditionally; + - the destination of the SET is write-only rather than read-write; and + - either: + - the destination of the SET is a REG that contains REGNO; or + - the destination of the SET is a SUBREG of such a REG. + + If PAT does have a SET like that, return the set, otherwise return null. + + This is intended to be an alternative to single_set for passes that + can handle patterns with multiple_sets. */ +rtx +simple_regno_set (rtx pat, unsigned int regno) +{ + if (GET_CODE (pat) =3D=3D PARALLEL) + { + int last =3D XVECLEN (pat, 0) - 1; + for (int i =3D 0; i < last; ++i) + if (rtx set =3D simple_regno_set (XVECEXP (pat, 0, i), regno)) + return set; + + pat =3D XVECEXP (pat, 0, last); + } + + if (GET_CODE (pat) =3D=3D SET + && covers_regno_no_parallel_p (SET_DEST (pat), regno)) + return pat; + + return nullptr; +} + /* Add all hard register in X to *PSET. */ void find_all_hard_regs (const_rtx x, HARD_REG_SET *pset) --=20 2.17.1