public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: gcc-patches@gcc.gnu.org
Cc: vmakarov@redhat.com, jakub@redhat.com
Subject: [Backport RFA] lra: Avoid unfolded plus-0
Date: Wed, 18 Oct 2023 14:37:49 +0100	[thread overview]
Message-ID: <mptmswg126q.fsf@arm.com> (raw)
In-Reply-To: <mpt1qfjz13s.fsf@arm.com> (Richard Sandiford's message of "Thu, 31 Aug 2023 16:24:23 +0100")

Vlad, is it OK if I backport the patch below to fix
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111528 ?  Jakub has
given a conditional OK on irc.

Thanks,
Richard

Richard Sandiford <richard.sandiford@arm.com> writes:
> While backporting another patch to an earlier release, I hit a
> situation in which lra_eliminate_regs_1 would eliminate an address to:
>
>     (plus (reg:P R) (const_int 0))
>
> This address compared not-equal to plain:
>
>     (reg:P R)
>
> which caused an ICE in a later peephole2.  (The ICE showed up in
> gfortran.fortran-torture/compile/pr80464.f90 on the branch but seems
> to be latent on trunk.)
>
> These unfolded PLUSes shouldn't occur in the insn stream, and later code
> in the same function tried to avoid them.
>
> Tested on aarch64-linux-gnu so far, but I'll test on x86_64-linux-gnu too.
> Does this look OK?
>
> There are probably other instances of the same thing elsewhere,
> but it seemed safer to stick to the one that caused the issue.
>
> Thanks,
> Richard
>
>
> gcc/
> 	* lra-eliminations.cc (lra_eliminate_regs_1): Use simplify_gen_binary
> 	rather than gen_rtx_PLUS.
> ---
>  gcc/lra-eliminations.cc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc
> index df613cdda76..4daaff1a124 100644
> --- a/gcc/lra-eliminations.cc
> +++ b/gcc/lra-eliminations.cc
> @@ -406,7 +406,7 @@ lra_eliminate_regs_1 (rtx_insn *insn, rtx x, machine_mode mem_mode,
>  		elimination_fp2sp_occured_p = true;
>  
>  	      if (! update_p && ! full_p)
> -		return gen_rtx_PLUS (Pmode, to, XEXP (x, 1));
> +		return simplify_gen_binary (PLUS, Pmode, to, XEXP (x, 1));
>  
>  	      if (maybe_ne (update_sp_offset, 0))
>  		offset = ep->to_rtx == stack_pointer_rtx ? update_sp_offset : 0;

  parent reply	other threads:[~2023-10-18 13:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31 15:24 [PATCH] " Richard Sandiford
2023-09-05  5:05 ` Jeff Law
2023-10-18 13:37 ` Richard Sandiford [this message]
2023-10-18 13:59   ` [Backport RFA] " 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=mptmswg126q.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=vmakarov@redhat.com \
    /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).