From patchwork Mon Jul 17 10:36:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 121193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1025632vqt; Mon, 17 Jul 2023 03:38:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlG3JrdNDZ/lW3n96nv5eVBUzvL1xygor+FvjU+mLC8KxcpElZKAdlhh02q5NTfAHGuCAgat X-Received: by 2002:aa7:d803:0:b0:521:7a5e:ab0f with SMTP id v3-20020aa7d803000000b005217a5eab0fmr4888528edq.9.1689590284331; Mon, 17 Jul 2023 03:38:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689590284; cv=none; d=google.com; s=arc-20160816; b=bmDPyETyg6kWTJluR8UwKj3yE2GIwQjeX8PswZ5N36msGVcWWiViH7sUMafe7VLhLU 42mLaoaNC6YM9I5OwYlh6l9dbLWbv/Hclzvybt64Fro08j2xnJOWNt2l04LhEyjJptg2 hhjFR/wthyjafne4MlixnCWjm/95xkQ91Yi+3lDHaSqnxEs0nKUQ4rOrVWNqz0yvNWFx bY8G8SFMjNk+92zm9lS6Pel/DLH01QBP6ogH0yp7vxoWMKVUUYyFoyvh5L/YJ0qo8G2l sUYzTOAIFihJHSvpD6KJkvoejtnnX9VBrm1THo9zp2Xh5EGlxUlbB/18C8PTL/7niyDO t0ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=JOU3t6lfmpiJq8wxL9hdQ6ud8Qfq0lhOdneoyHdXXSY=; fh=KxPrluukuxmHUzYWntxWAHNXePa4vWvGreVeug6Wy5k=; b=BqcLfpGuc43KKOnJGkpsPLamoI2CFvOVIBJMXPbq2iw47EPATyWw+MsOHsUTsa3JjX LTlcxDY2+2V39ca7clkE7SS2ELjdOrBBVHciyHD6Eg/mQopDHfzbQs3DNW+I9gcvAzLL Y3XSSTx4GrfPb0rfhdjQknPn0Kiy8lz0D074c1LWKjBLM+lwE5fBgedVPhH9yeaejD8H a5ktnFKOh2DD4T20wYNA2fc5WXnALw8D5KLtojA+VbCK4sWIIvFRRD/rGcNbMTxpir8R ltJVcAuBCPxuAGw0wFZx1CbQMTj6PDOIL7cc9QbiRD4tf1XPpHKwf2DkVxH95wmJTUQH lCmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=sCMwRoLu; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r19-20020aa7d593000000b0051e28ec9d30si13881701edq.665.2023.07.17.03.38.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 03:38:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=sCMwRoLu; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E7CAB385480D for ; Mon, 17 Jul 2023 10:37:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7CAB385480D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689590232; bh=JOU3t6lfmpiJq8wxL9hdQ6ud8Qfq0lhOdneoyHdXXSY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=sCMwRoLu/cTZszdO3AvTHwtxLOgY3oHkOsl/rd2okdsoIMBstCNVAfvss2XCgPcda TcyGMQsQrVIgfzasU59HcP8XOsSKOqlC8ez5A8qrZkvRXqex809dDoOEwLvzzXWYes g+FEDQO7ULMcKqTXqy/+2nrzpGirVnZK3FWSwnPI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id B561D385DC1F for ; Mon, 17 Jul 2023 10:36:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B561D385DC1F Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 5EB702811B6; Mon, 17 Jul 2023 12:36:24 +0200 (CEST) Date: Mon, 17 Jul 2023 12:36:24 +0200 To: gcc-patches@gcc.gnu.org Subject: Avoid double profile udpate in try_peel_loop Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Jan Hubicka via Gcc-patches From: Jan Hubicka Reply-To: Jan Hubicka Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771663822371570847 X-GMAIL-MSGID: 1771663822371570847 Hi, try_peel_loop uses gimple_duplicate_loop_body_to_header_edge which subtracts the profile from the original loop. However then it tries to scale the profile in a wrong way (it forces header count to be entry count). This eliminates to profile misupdates in the internal loop of sphinx3. gcc/ChangeLog: PR middle-end/110649 * tree-ssa-loop-ivcanon.cc (try_peel_loop): Avoid double profile update. diff --git a/gcc/tree-ssa-loop-ivcanon.cc b/gcc/tree-ssa-loop-ivcanon.cc index 0117dbfc91b..bdb738af7a8 100644 --- a/gcc/tree-ssa-loop-ivcanon.cc +++ b/gcc/tree-ssa-loop-ivcanon.cc @@ -1152,6 +1152,7 @@ try_peel_loop (class loop *loop, } if (may_be_zero) bitmap_clear_bit (wont_exit, 1); + if (!gimple_duplicate_loop_body_to_header_edge ( loop, loop_preheader_edge (loop), npeel, wont_exit, exit, &edges_to_remove, DLTHE_FLAG_UPDATE_FREQ)) @@ -1168,18 +1169,6 @@ try_peel_loop (class loop *loop, adjust_loop_info_after_peeling (loop, npeel, true); profile_count entry_count = profile_count::zero (); - edge e; - edge_iterator ei; - FOR_EACH_EDGE (e, ei, loop->header->preds) - if (e->src != loop->latch) - { - if (e->src->count.initialized_p ()) - entry_count += e->src->count; - gcc_assert (!flow_bb_inside_loop_p (loop, e->src)); - } - profile_probability p; - p = entry_count.probability_in (loop->header->count); - scale_loop_profile (loop, p, -1); bitmap_set_bit (peeled_loops, loop->num); return true; }