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 05CD33857805 for ; Mon, 9 May 2022 08:09:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 05CD33857805 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 805CF1042; Mon, 9 May 2022 01:09:29 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BA5C13F66F; Mon, 9 May 2022 01:09:28 -0700 (PDT) From: Richard Sandiford To: Alexandre Oliva Mail-Followup-To: Alexandre Oliva , Segher Boessenkool , Alexandre Oliva via Gcc-patches , dje.gcc@gmail.com, richard.sandiford@arm.com Cc: Segher Boessenkool , Alexandre Oliva via Gcc-patches , dje.gcc@gmail.com Subject: Re: [PATCH v2 2/2] [PR100106] Reject unaligned subregs when strict alignment is required References: <20220505135023.GB25951@gate.crashing.org> Date: Mon, 09 May 2022 09:09:27 +0100 In-Reply-To: (Alexandre Oliva's message of "Fri, 06 May 2022 07:57:39 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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, 09 May 2022 08:09:32 -0000 Alexandre Oliva writes: > On May 5, 2022, Segher Boessenkool wrote: > >> On Thu, May 05, 2022 at 08:59:21AM +0100, Richard Sandiford wrote: >>> Alexandre Oliva via Gcc-patches writes: >>> I know this is the best being the enemy of the good, but given >>> that we're at the start of stage 1, would it be feasible to try >>> to get rid of (subreg (mem)) altogether for GCC 13? > >> Yes please! > > I'm not sure this is what you two had in mind, but the news I have is > not great. With this patch, x86_64 has some regressions in vector > testcases (*), and ppc64le doesn't bootstrap (tsan_interface_atomic.o > ends up with a nil SET_DEST in split all insns). aarch64 is still > building stage2. > > I'm not sure this is enough. IIRC register allocation modifies in place > pseudos that can't be assigned to hard registers, turning them into > MEMs. If that's so, SUBREGs of such pseudos will silently become > SUBREGs of MEMs, and I don't know that they are validated again and, if > so, what happens to those that fail validation. Yeah, the changes would be a bit more invasive than this. They would touch more than just emit-rtl.cc. > I kind of feel that this is more than I can tackle ATM, so I'd > appreciate if someone else would take this up and drive this transition. OK, I'll have a go if there's time. Thanks, Richard > Disallow SUBREG of MEM > > Introduce TARGET_ALLOW_SUBREG_OF_MEM, defaulting to 0. > > Reject SUBREG of MEM regardless of alignment, unless the macro is > defined to nonzero. > > > for gcc/ChangeLog > > PR target/100106 > * emit-rtl.cc (validate_subreg) [!TARGET_ALLOW_SUBREG_OF_MEM]: > Reject SUBREG of MEM. > --- > gcc/emit-rtl.cc | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc > index 9c03e27894fff..f055179b3b8a6 100644 > --- a/gcc/emit-rtl.cc > +++ b/gcc/emit-rtl.cc > @@ -983,8 +983,12 @@ validate_subreg (machine_mode omode, machine_mode imode, > return subreg_offset_representable_p (regno, imode, offset, omode); > } > /* Do not allow SUBREG with stricter alignment than the inner MEM. */ > - else if (reg && MEM_P (reg) && STRICT_ALIGNMENT > - && MEM_ALIGN (reg) < GET_MODE_ALIGNMENT (omode)) > + else if (reg && MEM_P (reg) > +#if TARGET_ALLOW_SUBREG_OF_MEM /* ??? Reject them all eventually. */ > + && STRICT_ALIGNMENT > + && MEM_ALIGN (reg) < GET_MODE_ALIGNMENT (omode) > +#endif > + ) > return false; > > /* The outer size must be ordered wrt the register size, otherwise > > > > (*) here are the x86_64 regressions introduced by the patch: > > + FAIL: gcc.target/i386/avx-2.c (internal compiler error: in gen_rtx_SUBREG, at emit-rtl.cc:1030) > + FAIL: gcc.target/i386/avx-2.c (test for excess errors) > + FAIL: gcc.target/i386/sse-14.c (internal compiler error: in gen_rtx_SUBREG, at emit-rtl.cc:1030) > + FAIL: gcc.target/i386/sse-14.c (test for excess errors) > + FAIL: gcc.target/i386/sse-22.c (internal compiler error: in gen_rtx_SUBREG, at emit-rtl.cc:1030) > + FAIL: gcc.target/i386/sse-22.c (test for excess errors) > + FAIL: gcc.target/i386/sse-22a.c (internal compiler error: in gen_rtx_SUBREG, at emit-rtl.cc:1030) > + FAIL: gcc.target/i386/sse-22a.c (test for excess errors)