]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
lra: Avoid unfolded plus-0
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 7 Sep 2023 06:28:50 +0000 (07:28 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Thu, 7 Sep 2023 06:28:50 +0000 (07:28 +0100)
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.

gcc/lra-eliminations.cc

index df613cdda76c700d8c88be86aedeefd962c7d8b2..4daaff1a124fbe1b7fd6f693aee69350dc0039ec 100644 (file)
@@ -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;