From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1130) id 403D03858D35; Thu, 7 Sep 2023 06:29:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 403D03858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694068159; bh=nZNx4mz2AxbYljDB5dUk4G5cb6uTg/1ocJ8m3fwy3Pw=; h=From:To:Subject:Date:From; b=ljtSclS7C8IztRnaJfzuxTE8v7y+9JqnwiRXQG8/KmEDQA4yDgkeVHcxi11qGn2Xb aDR/BR6I1VwTyTVvkXtkeQJrEUH9eQHO7r8LI+xLStJw0XTntQ+cK/fEuNi3gB099N KOEMlYLzs2KE6L8u00BLk5fhR9LQfOAOaQGi4q1A= 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 r14-3766] lra: Avoid unfolded plus-0 X-Act-Checkin: gcc X-Git-Author: Richard Sandiford X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 572abb52f5761a647035ee39d0e443c1c3622e75 X-Git-Newrev: 10d59b802a7db9ae908291fb20627c1493cfa26c Message-Id: <20230907062919.403D03858D35@sourceware.org> Date: Thu, 7 Sep 2023 06:29:19 +0000 (GMT) List-Id: https://gcc.gnu.org/g:10d59b802a7db9ae908291fb20627c1493cfa26c commit r14-3766-g10d59b802a7db9ae908291fb20627c1493cfa26c Author: Richard Sandiford 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;