public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: Alexandre Oliva <oliva@adacore.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
	Alexandre Oliva via Gcc-patches <gcc-patches@gcc.gnu.org>,
	dje.gcc@gmail.com
Subject: Re: [PATCH v2 2/2] [PR100106] Reject unaligned subregs when strict alignment is required
Date: Mon, 09 May 2022 09:09:27 +0100	[thread overview]
Message-ID: <mpt1qx3b008.fsf@arm.com> (raw)
In-Reply-To: <orbkwbdj30.fsf_-_@lxoliva.fsfla.org> (Alexandre Oliva's message of "Fri, 06 May 2022 07:57:39 -0300")

Alexandre Oliva <oliva@adacore.com> writes:
> On May  5, 2022, Segher Boessenkool <segher@kernel.crashing.org> wrote:
>
>> On Thu, May 05, 2022 at 08:59:21AM +0100, Richard Sandiford wrote:
>>> Alexandre Oliva via Gcc-patches <gcc-patches@gcc.gnu.org> 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)

  reply	other threads:[~2022-05-09  8:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05  6:52 [PATCH] " Alexandre Oliva
2022-05-05  7:59 ` Richard Sandiford
2022-05-05 13:50   ` Segher Boessenkool
2022-05-06 10:57     ` [PATCH v2 2/2] " Alexandre Oliva
2022-05-09  8:09       ` Richard Sandiford [this message]
2022-05-05 14:33 ` [PATCH] " Segher Boessenkool
2022-05-06  2:41   ` [PATCH v2] " Alexandre Oliva
2022-07-09 17:14     ` Jeff Law
2023-05-24  5:39     ` Alexandre Oliva
2023-05-24  9:04       ` Richard Biener
2022-05-06 18:04 ` [PATCH] " Vladimir Makarov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mpt1qx3b008.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=oliva@adacore.com \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).