From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1130) id F25643858002; Thu, 19 Oct 2023 09:49:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F25643858002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697708972; bh=fUZtDPHWKFNL36RkIHos2aBkPpicQMSnkkKdL9bPLyw=; h=From:To:Subject:Date:From; b=fb6uKOb9YnM1IICo7om2QrhburSS/8DAe7hyTvvUN4hQ+6EqQ5T9Ij1PGYo/maU6e fqiZLl2Ub75YyEPK7Z3c0DWBwD6AKh/0nlSelxWiomPCUlHkt1KD6n7tafrGFh9yU5 UZMY79f4mQeW0u6WDeE1RJYD3z5MXQjepWdVodiI= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Sandiford To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-9930] lra: Avoid unfolded plus-0 X-Act-Checkin: gcc X-Git-Author: Richard Sandiford X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: ece703162640102b9cc401451a8d39961254425c X-Git-Newrev: 6a527b809f99d3f05df16f792b2de6b32fa0d579 Message-Id: <20231019094932.F25643858002@sourceware.org> Date: Thu, 19 Oct 2023 09:49:32 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6a527b809f99d3f05df16f792b2de6b32fa0d579 commit r12-9930-g6a527b809f99d3f05df16f792b2de6b32fa0d579 Author: Richard Sandiford Date: Thu Oct 19 10:49:19 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/ PR target/111528 * lra-eliminations.cc (lra_eliminate_regs_1): Use simplify_gen_binary rather than gen_rtx_PLUS. (cherry picked from commit 10d59b802a7db9ae908291fb20627c1493cfa26c) Diff: --- gcc/lra-eliminations.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/lra-eliminations.cc b/gcc/lra-eliminations.cc index c630ff4af2d1..7642d9857a87 100644 --- a/gcc/lra-eliminations.cc +++ b/gcc/lra-eliminations.cc @@ -397,8 +397,8 @@ lra_eliminate_regs_1 (rtx_insn *insn, rtx x, machine_mode mem_mode, rtx to = subst_p ? ep->to_rtx : ep->from_rtx; 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; else