From patchwork Mon Sep 6 10:40:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Earnshaw X-Patchwork-Id: 1524890 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=qXG1xlAg; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H34h85ZCGz9sRf for ; Mon, 6 Sep 2021 20:41:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A2AA63858414 for ; Mon, 6 Sep 2021 10:41:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2AA63858414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1630924884; bh=dosV9IbzNB5qeRudi30N2KuIE/ay+LC/Ton7OESsqkY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=qXG1xlAgXbNIEdmYO8Fsns2qT8dhCQRSBaPiEVQ9jL7uK37O2iLpmjdsinp3Zh3Su gwWI7YMwvrQU/niFepeSYdPPARoZ1WUcj4+Odc9fcCS5mQNqZWZO2diu674yge3Cl5 QHciLuljtSMYAq0R/3SyNLe2e5wWrAkLyMGubSSM= 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 633CE385841E for ; Mon, 6 Sep 2021 10:40:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 633CE385841E 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 078A2D6E; Mon, 6 Sep 2021 03:40:43 -0700 (PDT) Received: from e126323.arm.com (unknown [10.57.39.244]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 448D73F73D; Mon, 6 Sep 2021 03:40:42 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/3] rtl: allow forming subregs of already unaligned mems [PR102125] Date: Mon, 6 Sep 2021 11:40:16 +0100 Message-Id: <20210906104018.2697413-2-rearnsha@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210906104018.2697413-1-rearnsha@arm.com> References: <20210906104018.2697413-1-rearnsha@arm.com> MIME-Version: 1.0 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-Patchwork-Original-From: Richard Earnshaw via Gcc-patches From: Richard Earnshaw Reply-To: Richard Earnshaw Cc: bernd.edlinger@hotmail.de, Richard Earnshaw Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" GCC was recently changed to prevent simplify_subreg from simplifying a subreg of a mem when the mode of the new mem would have stricter alignment constraints than the inner mem already has when the target requires STRICT_ALIGNMENT. However, such targets may have specialist patterns that can handle unaligned accesses and this restriction turns out to be unduly restrictive. So limit this restriction to only apply when the inner mem is naturally aligned to the inner mode. gcc/ChangeLog: PR target/102125 * simplify-rtx.c (simplify_context::simplify_subreg): Allow simplifying (subreg (mem())) when the inner mem is already misaligned for its type. --- gcc/simplify-rtx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index ebad5cb5a79..1baa50cb1b9 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -7317,7 +7317,11 @@ simplify_context::simplify_subreg (machine_mode outermode, rtx op, have instruction to move the whole thing. */ && (! MEM_VOLATILE_P (op) || ! have_insn_for (SET, innermode)) - && !(STRICT_ALIGNMENT && MEM_ALIGN (op) < GET_MODE_ALIGNMENT (outermode)) + /* On STRICT_ALIGNMENT targets, don't allow the alignment to be increased + if the inner object is already naturally aligned. */ + && !(STRICT_ALIGNMENT + && MEM_ALIGN (op) >= GET_MODE_ALIGNMENT (innermode) + && MEM_ALIGN (op) < GET_MODE_ALIGNMENT (outermode)) && known_le (outersize, innersize)) return adjust_address_nv (op, outermode, byte);