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 4C20A3858405 for ; Fri, 10 Sep 2021 14:48:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4C20A3858405 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 0648731B; Fri, 10 Sep 2021 07:48:54 -0700 (PDT) Received: from e126323.arm.com (unknown [10.57.22.219]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6154E3F59C; Fri, 10 Sep 2021 07:48:53 -0700 (PDT) From: Richard Earnshaw To: gcc-patches@gcc.gnu.org Cc: Richard Earnshaw , richard.guenther@gmail.com Subject: [PATCH v3 1/3] rtl: directly handle MEM in gen_highpart [PR102125] Date: Fri, 10 Sep 2021 15:48:39 +0100 Message-Id: <20210910144841.3139174-2-rearnsha@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210910144841.3139174-1-rearnsha@arm.com> References: <20210910144841.3139174-1-rearnsha@arm.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.25.1" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.8 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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, 10 Sep 2021 14:48:55 -0000 This is a multi-part message in MIME format. --------------2.25.1 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit gen_lowpart_general handles forming a lowpart of a MEM by using adjust_address to rework and validate a new version of the MEM. Do the same for gen_highpart rather than calling simplify_gen_subreg for this case. gcc/ChangeLog: PR target/102125 * emit-rtl.c (gen_highpart): Use adjust_address to handle MEM rather than calling simplify_gen_subreg. --- gcc/emit-rtl.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) --------------2.25.1 Content-Type: text/x-patch; name="v3-0001-rtl-directly-handle-MEM-in-gen_highpart-PR102125.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="v3-0001-rtl-directly-handle-MEM-in-gen_highpart-PR102125.patch" diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 77ea8948ee8..0ba110879aa 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -1585,19 +1585,22 @@ gen_highpart (machine_mode mode, rtx x) gcc_assert (known_le (msize, (unsigned int) UNITS_PER_WORD) || known_eq (msize, GET_MODE_UNIT_SIZE (GET_MODE (x)))); - result = simplify_gen_subreg (mode, x, GET_MODE (x), - subreg_highpart_offset (mode, GET_MODE (x))); - gcc_assert (result); - - /* simplify_gen_subreg is not guaranteed to return a valid operand for - the target if we have a MEM. gen_highpart must return a valid operand, - emitting code if necessary to do so. */ - if (MEM_P (result)) + /* gen_lowpart_common handles a lot of special cases due to needing to handle + paradoxical subregs; it only calls simplify_gen_subreg when certain that + it will produce something meaningful. The only case we need to handle + specially here is MEM. */ + if (MEM_P (x)) { - result = validize_mem (result); - gcc_assert (result); + poly_int64 offset = subreg_highpart_offset (mode, GET_MODE (x)); + return adjust_address (x, mode, offset); } + result = simplify_gen_subreg (mode, x, GET_MODE (x), + subreg_highpart_offset (mode, GET_MODE (x))); + /* Since we handle MEM directly above, we should never get a MEM back + from simplify_gen_subreg. */ + gcc_assert (result && !MEM_P (result)); + return result; } --------------2.25.1--