From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1130) id CE8EB3858C52; Wed, 18 Oct 2023 17:45:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE8EB3858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1697651108; bh=tPLWhMa7SkbQOvF5JEukQio8o6D1GA2GXQYBqRVR0dI=; h=From:To:Subject:Date:From; b=gx25XH9RYbnBNigEk/xr9noo9FaWfXHzOlY0P/xPuSBip3rNc3SHJlN25AQdBcQJ0 Tma4MP84z9uZ/gw+AlxiZWfehwpMyo4SzzjrytTlIf57RU9h0lWq0g/xf+51I9pOuF b2WwC9SFF3kC1Xsx3+d0S093WazSZzNpHky3L3N4= 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 r13-7961] lra: Avoid unfolded plus-0 X-Act-Checkin: gcc X-Git-Author: Richard Sandiford X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: bdf4b6f9f2847b7abba5392e271e30f55541935e X-Git-Newrev: f5e56c5857cc6b704446c3666213468d25f6dcb2 Message-Id: <20231018174508.CE8EB3858C52@sourceware.org> Date: Wed, 18 Oct 2023 17:45:08 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f5e56c5857cc6b704446c3666213468d25f6dcb2 commit r13-7961-gf5e56c5857cc6b704446c3666213468d25f6dcb2 Author: Richard Sandiford Date: Wed Oct 18 18:44:57 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 422063666690..c627dc5db6b7 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