From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id D35963858D33 for ; Wed, 18 Oct 2023 13:37:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D35963858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D35963858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697636274; cv=none; b=AYmKFStApii3US/efktAZzsGLSxyeIChzrLNa7Uima/QiNMCardPDUFPX9mKRuuBt1rY++EqPj5R8ZrfOyk3tKSsssGpn6tvBX0VMjaI04ndM8zKxdRgFYSTRX0xFa4xSMrR88XjzWZFWELodoTMEVqAxK3/sC8P3el88ktnrTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697636274; c=relaxed/simple; bh=mWQNyyT7tW1xMBqvYtBguw1wOpGXfcDiTjzgx43tYH4=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=CblPB3anFAHEQDuYMcwEX9+69Quz/rZSS4D0PJg/J9QaMldkkiVcGBUY5i1j8q6O3KqOytXSKf78BXCULFukzd1BBfAL6M1UUk+MrHFPrY8O+EzU2G1lhsLWRPXV8AMkcWYX+qmfjKfpoQBZSLq1phrhVJFRLuWREo9pdGIOgA8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9476B2F4; Wed, 18 Oct 2023 06:38:32 -0700 (PDT) Received: from localhost (unknown [10.32.110.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EB93D3F762; Wed, 18 Oct 2023 06:37:50 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org,vmakarov@redhat.com, jakub@redhat.com, richard.sandiford@arm.com Cc: vmakarov@redhat.com, jakub@redhat.com Subject: [Backport RFA] lra: Avoid unfolded plus-0 References: Date: Wed, 18 Oct 2023 14:37:49 +0100 In-Reply-To: (Richard Sandiford's message of "Thu, 31 Aug 2023 16:24:23 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-23.8 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,KAM_NUMSUBJECT,KAM_SHORT,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Vlad, is it OK if I backport the patch below to fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111528 ? Jakub has given a conditional OK on irc. Thanks, Richard Richard Sandiford writes: > 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. > > Tested on aarch64-linux-gnu so far, but I'll test on x86_64-linux-gnu too. > Does this look OK? > > There are probably other instances of the same thing elsewhere, > but it seemed safer to stick to the one that caused the issue. > > Thanks, > Richard > > > gcc/ > * lra-eliminations.cc (lra_eliminate_regs_1): Use simplify_gen_binary > rather than gen_rtx_PLUS. > --- > 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 df613cdda76..4daaff1a124 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;