From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id C8FC73854804 for ; Sun, 18 Apr 2021 15:24:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C8FC73854804 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-147-xscfcPkNNc-LEHdDOV85OQ-1; Sun, 18 Apr 2021 11:24:55 -0400 X-MC-Unique: xscfcPkNNc-LEHdDOV85OQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3EFE18030A0; Sun, 18 Apr 2021 15:24:54 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-115-183.ams2.redhat.com [10.36.115.183]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C5EA519C66; Sun, 18 Apr 2021 15:24:53 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 13IFOp522052667 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 18 Apr 2021 17:24:51 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 13IFOohb2052666; Sun, 18 Apr 2021 17:24:50 +0200 Date: Sun, 18 Apr 2021 17:24:50 +0200 From: Jakub Jelinek To: Segher Boessenkool Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] combine: Don't create REG_UNUSED notes if the reg already died (PR99927) Message-ID: <20210418152450.GY1179226@tucnak> Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Apr 2021 15:25:01 -0000 On Sun, Apr 18, 2021 at 03:03:07PM +0000, Segher Boessenkool wrote: > If the register named in an existing REG_UNUSED note dies somewhere > between where the note used to be and I3, we should just drop it. > > 2021-04-21 Segher Boessenkool > > PR rtl-optimization/99927 > * combine.c (distribute_notes) [REG_UNUSED]: If the register already > is dead, just drop it. > --- > > Committed to trunk. This will need backports to all open branches. Thanks for working on this. Just some nits but note that I don't know much about the combiner... > gcc/combine.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/gcc/combine.c b/gcc/combine.c > index 9063a07bd009..62bf4aeaabae 100644 > --- a/gcc/combine.c > +++ b/gcc/combine.c > @@ -14366,6 +14366,11 @@ distribute_notes (rtx notes, rtx_insn *from_insn, rtx_insn *i3, rtx_insn *i2, > we keep notes from i2 or i1 if they will turn into REG_DEAD > notes. */ > > + /* If this register is set or clobbered between FROM_INSN and I3, > + we should not create a note for it. */ > + if (reg_set_between_p (XEXP (note, 0), from_insn, i3)) > + break; > + > /* If this register is set or clobbered in I3, put the note there > unless there is one already. */ > if (reg_set_p (XEXP (note, 0), PATTERN (i3))) Doesn't this make the if (from_insn != i3 && i2 && INSN_P (i2) && reg_referenced_p (XEXP (note, 0), PATTERN (i2))) { if (!reg_set_p (XEXP (note, 0), PATTERN (i2))) PUT_REG_NOTE_KIND (note, REG_DEAD); if (! (REG_P (XEXP (note, 0)) ? find_regno_note (i2, REG_NOTE_KIND (note), REGNO (XEXP (note, 0))) : find_reg_note (i2, REG_NOTE_KIND (note), XEXP (note, 0)))) place = i2; } case unreachable (the reg_set_p stuff at least; I mean if reg_set_p is true on i2 and i2 is in between from_ins and i3, then reg_set_between_p will surely be true)? And, shouldn't the record_value_for_reg (XEXP (note, 0), NULL, NULL_RTX); be called in some cases? To me it would make more sense to add the if (reg_set_between_p (...)) break; to the individual cases later, so before if (! (REG_P (XEXP (note, 0)) ? find_regno_note (i3, REG_UNUSED, REGNO (XEXP (note, 0))) : find_reg_note (i3, REG_UNUSED, XEXP (note, 0)))) place = i3; and before PUT_REG_NOTE_KIND (note, REG_DEAD); place = i3; and into the if (from_insn != i3 && i2 && INSN_P (i2) && reg_referenced_p (XEXP (note, 0), PATTERN (i2))) but there just checking if it isn't set in between from_insn and i2 Jakub