From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 01BAD3858D28 for ; Thu, 30 Dec 2021 10:09:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 01BAD3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 1BUA8Q65031197; Thu, 30 Dec 2021 04:08:26 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 1BUA8PsN031196; Thu, 30 Dec 2021 04:08:25 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Thu, 30 Dec 2021 04:08:25 -0600 From: Segher Boessenkool To: Jakub Jelinek Cc: Richard Biener , Jeff Law , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] shrink-wrapping: Fix up prologue block discovery [PR103860] Message-ID: <20211230100825.GL614@gate.crashing.org> References: <20211230094332.GZ2646553@tucnak> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211230094332.GZ2646553@tucnak> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Thu, 30 Dec 2021 10:09:28 -0000 Hi! On Thu, Dec 30, 2021 at 10:43:32AM +0100, Jakub Jelinek wrote: > The following testcase is miscompiled, because a prologue which > contains subq $8, %rsp instruction is emitted at the start of > a basic block which contains conditional jump that depends on > flags register set in an earlier basic block, the prologue instruction > then clobbers those flags. > Normally this case is checked by can_get_prologue predicate, but this > is done only at the start of the loop. If we update pro later in the > loop (because some bb shouldn't be duplicated) and then don't push > anything further into vec and the vec is already empty (this can happen > when the new pro is already in bb_with bitmask and either has no successors > (that is the case in the testcase where that bb ends with a trap) or > all the successors are already in bb_with, then the loop doesn't iterate > further and can_get_prologue will not be checked. > > The following simple patch makes sure we call can_get_prologue even after > the last former iteration when vec is already empty and only break from > the loop afterwards (and only if the updating of pro done because of > !can_get_prologue didn't push anything into vec again). > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? That looks good, and very simple, thanks! git blame says I wrote 69.9% of shrink-wrap.c, but I am not maintainer of it, so I cannot approve your patch -- but it is fine afaics. Segher > 2021-12-30 Jakub Jelinek > > PR rtl-optimization/103860 > * shrink-wrap.c (try_shrink_wrapping): Make sure can_get_prologue is > called on pro even if nothing further is pushed into vec. > > * gcc.dg/pr103860.c: New test.