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 5B2D13858414 for ; Mon, 6 Sep 2021 11:23:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5B2D13858414 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 F1ACF6D; Mon, 6 Sep 2021 04:23:12 -0700 (PDT) Received: from [10.57.39.244] (unknown [10.57.39.244]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 36EAB3F73D; Mon, 6 Sep 2021 04:23:12 -0700 (PDT) Subject: Re: [PATCH 1/3] rtl: allow forming subregs of already unaligned mems [PR102125] To: Richard Biener Cc: Richard Earnshaw , Bernd Edlinger , GCC Patches References: <20210906104018.2697413-1-rearnsha@arm.com> <20210906104018.2697413-2-rearnsha@arm.com> From: Richard Earnshaw Message-ID: Date: Mon, 6 Sep 2021 12:23:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3492.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, SPF_HELO_NONE, SPF_NONE, 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: Mon, 06 Sep 2021 11:23:14 -0000 On 06/09/2021 12:13, Richard Biener wrote: > On Mon, Sep 6, 2021 at 1:08 PM Richard Earnshaw > wrote: >> >> >> >> On 06/09/2021 11:58, Richard Biener via Gcc-patches wrote: >>> On Mon, Sep 6, 2021 at 12:40 PM Richard Earnshaw wrote: >>>> >>>> >>>> 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. >>> >>> Hmm, I think this can end up either generating wrong code or >>> recog fails. The specific combination of alignment and mode of 'op' >>> has been validated to be supported, replacing the mode with sth >>> else would need re-validation of the combination. I'm not sure >>> we can for example just query movmisalign support here and >>> hope for LRA to reload the mem with that. >>> >>> So - where do you run into this? Is it possible to catch the >>> situation on a higher level where more context as in the whole insn >>> is visible? >> >> I ran into it with patch 2 of this series when calling gen_highpart on a >> misaligned mem. IIRC gen_highpart would end up returning (subreg:SI >> (mem:DI (addr [A8])) 4), while gen_lowpart would simplify the operation >> to (mem:SI (addr [A8])) as expected. >> >> (subreg:SI (mem:DI (addr [A8])) 4) is really problematic, because it's >> not a memory_operand (from the manual: it will get reloaded into a >> register later on). But that's no good here, I don't want this >> reloading into a wide register later, I need it to be narrowed to the >> component part now. > > So maybe calling gen_highpart is not what you want then? > adjust_address is IIRC what one uses to offset a MEM and change > its mode. It was based on looking at the patch for PR 100106 (r12-163-c33db31d9ad9). That patch added the MEM_ALIGN constraint when previously there was none here and my call would have been simplified. Are you saying that GCC was always wrong in this respect? All I've done was to tightened the check that Bernd added. R. > > Richard. > >> >> R. >> >>> >>> Thanks, >>> Richard. >>> >>>> >>>> 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(-) >>>>