From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by sourceware.org (Postfix) with ESMTPS id 838A83858D28 for ; Thu, 30 Dec 2021 12:52:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 838A83858D28 Received: by mail-io1-xd33.google.com with SMTP id u8so29449189iol.5 for ; Thu, 30 Dec 2021 04:52:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=33OrcJmQRy9E0kF0mt65lLPew+ySiGn/mdmSVPRJF0Y=; b=De68WR2jTgTEDs1M6kBRyGCyG0BVob+pX9QVwn7DCQI0pyYqWo5C6nVyUKk6rmFeOD gnKN1udz1AH/BO5TVVm8XdBs+GgfADehcUsLh3quHormFMwhFYVKlKoc2V92kBV0aiVo ZhDQekcNp18rdDY6fybsd3/n5ZW19rNf5bUkl0ZTdVl5UDEYQQgnc2ojB9y5M7jMMUP3 IeLNURjQSfjhUdkWDQs4xMCygDEv1Gw1Ggwl6UlHtLFDv4fHn7+NsydAj5Apo6PFFKJT 8yo0z4ZGEwhEKgEN6PwXC602Qo21RoAUTQ9hbLk9IfsIUKlKOcQiOKdphs7SfK37y55P CWgw== X-Gm-Message-State: AOAM53272yAGGtdsf4DCvLkIIBsLn9k5ZRhHu8IFl/H7I4VxkVmP6Q48 a+uaFAsPB01cDB9eK3LuCh0= X-Google-Smtp-Source: ABdhPJyYiYrfQNgk4BfM/Y3+1m7XTUkuCLbYqvOu0TmoOVrfEQ0x/AdB8JxiFX/WYqoElGJoK2Cf0w== X-Received: by 2002:a05:6602:2b0b:: with SMTP id p11mr13382314iov.116.1640868773767; Thu, 30 Dec 2021 04:52:53 -0800 (PST) Received: from [172.31.0.175] (c-98-202-48-222.hsd1.ut.comcast.net. [98.202.48.222]) by smtp.gmail.com with ESMTPSA id g3sm13907561ilq.1.2021.12.30.04.52.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Dec 2021 04:52:53 -0800 (PST) Message-ID: <801a77eb-4cbb-c751-53d7-0fccce557cef@gmail.com> Date: Thu, 30 Dec 2021 05:52:52 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH] shrink-wrapping: Fix up prologue block discovery [PR103860] Content-Language: en-US To: Segher Boessenkool , Jakub Jelinek Cc: Richard Biener , gcc-patches@gcc.gnu.org References: <20211230094332.GZ2646553@tucnak> <20211230100825.GL614@gate.crashing.org> From: Jeff Law In-Reply-To: <20211230100825.GL614@gate.crashing.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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 12:52:56 -0000 On 12/30/2021 3:08 AM, Segher Boessenkool wrote: > 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. Well, we should probably fix the maintainer status of shrink-wrap.c. In the mean time, based on Segher's review, this is fine for the trunk. jeff