public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-3766] lra: Avoid unfolded plus-0
@ 2023-09-07  6:29 Richard Sandiford
  0 siblings, 0 replies; only message in thread
From: Richard Sandiford @ 2023-09-07  6:29 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:10d59b802a7db9ae908291fb20627c1493cfa26c

commit r14-3766-g10d59b802a7db9ae908291fb20627c1493cfa26c
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Thu Sep 7 07:28:50 2023 +0100

    lra: Avoid unfolded plus-0
    
    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.
    
    gcc/
            * lra-eliminations.cc (lra_eliminate_regs_1): Use simplify_gen_binary
            rather than gen_rtx_PLUS.

Diff:
---
 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 df613cdda76c..4daaff1a124f 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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-07  6:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-07  6:29 [gcc r14-3766] lra: Avoid unfolded plus-0 Richard Sandiford

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).