From patchwork Thu Mar 9 11:15:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 66789 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp229359wrd; Thu, 9 Mar 2023 03:16:04 -0800 (PST) X-Google-Smtp-Source: AK7set9ex/7BS77FJ2zlwsP8E8DJENo5o+tD7zw3t5gZ33VTMHaI5WKgK6AI2dplML/N2Nwqozei X-Received: by 2002:a17:907:9694:b0:881:f2f:6633 with SMTP id hd20-20020a170907969400b008810f2f6633mr25476782ejc.50.1678360564072; Thu, 09 Mar 2023 03:16:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678360564; cv=none; d=google.com; s=arc-20160816; b=vmFXEqf0GVtepIjtdK5/Rc1h87042uH6elieXrGgsTqnoGhABKOvK79UmQy+GgQ3yJ XNB5H2c4JlzyASit/a45CjcV/Pum1rD4C7z1VmegspfKtfwLJJIt4wDJ5l4/oJCegJuf iwtf+GxueJmx0cc+kfCfApKVw0VxiNUXjPHY3fLK/7F9SPwpfKD0PrMuCTyG6OjHZeyo 8CACEH+TIB4lJdyxtqNRcdhKm1qiEYBSfdEZpCatTo5l9b0DfxoZZ8Ct/LXqATjNV8fk bhb3h8JKgj/tnnKoXuciTeiAeLgA+pm8eENyTLYik35cY4QiOnMTSbTBh4KJQdJnAv9R cgow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=K9MrQeJgwFrqTTIlmjKQeAC3Yign3o+lnmtkvOwLq5w=; b=BVh+h3CwcPpsJfOnmX+qlrJ6emcBxslpHCWikfx+LeSSPcqEVmmrcC5hKmBCERtPir ybVWbGEgr3j9Du41PGnhzXI80J6gOWQma0s8p6yFAirLzmwuTZqPqFocfR5Z0rv/dmb+ QkGZrP2UwLxYH0H1kOV54+lA77FYMyKhWrgsbTv5k0z63zH7HIstJF5wQ9fRyFKbxZqZ xrDP97oAeTO6a5N7pND4NvhdPWjxP6/gSb8zLektmhzMmCIjfOrWAQ+VbouRAmxly7CT DmrRM8usPghL+P7X2fjGEBF4hUswQVCY92+S7e3O/Ajq4iDPK70XCPX8jmNsx0BO/T6w nuHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TpkOxtoi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c17-20020a170906d19100b008d3be841ccdsi5535345ejz.326.2023.03.09.03.16.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 03:16:04 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TpkOxtoi; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 D79AC3858C3A for ; Thu, 9 Mar 2023 11:16:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D79AC3858C3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678360562; bh=K9MrQeJgwFrqTTIlmjKQeAC3Yign3o+lnmtkvOwLq5w=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=TpkOxtoimdQ5PxoZnabgoAhNmOpqk5TvzYX8L3X0upZY5orvaVfqeiA+0rQBkjGvD zPAcVTPFb9sVEaxu+r/VDzZybQ62ByxGUS/fcfc6Ibi+qulmYtUrJnaRkBTpY8a2su jFk9ZQRMuMgnTmbymyuwNGhSoVT+MlzunHNIWoMc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 601E23858D33 for ; Thu, 9 Mar 2023 11:15:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 601E23858D33 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 48B9E20111 for ; Thu, 9 Mar 2023 11:15:17 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 9ED312C1D0 for ; Thu, 9 Mar 2023 11:15:13 +0000 (UTC) Date: Thu, 9 Mar 2023 11:15:17 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/44794 - avoid excessive RTL unrolling on epilogues User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, 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 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20230309111602.D79AC3858C3A@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759888606693853001?= X-GMAIL-MSGID: =?utf-8?q?1759888606693853001?= The following adjusts tree_[transform_and_]unroll_loop to set an upper bound on the number of iterations on the epilogue loop it creates. For the testcase at hand which involves array prefetching this avoids applying RTL unrolling to them when -funroll-loops is specified. Other users of this API includes predictive commoning and unroll-and-jam. Bootstrapped and tested on x86_64-unknown-linux-gnu, queued for stage1. PR tree-optimization/44794 * tree-ssa-loop-manip.cc (tree_transform_and_unroll_loop): If an epilogue loop is required set its iteration upper bound. --- gcc/tree-ssa-loop-manip.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/tree-ssa-loop-manip.cc b/gcc/tree-ssa-loop-manip.cc index 09acc1c94cc..c804a7353d5 100644 --- a/gcc/tree-ssa-loop-manip.cc +++ b/gcc/tree-ssa-loop-manip.cc @@ -1297,6 +1297,12 @@ tree_transform_and_unroll_loop (class loop *loop, unsigned factor, } remove_path (exit); + + /* The epilog loop latch executes at most factor - 1 times. + Since the epilog is entered unconditionally it will need to handle + up to factor executions of its body. */ + new_loop->any_upper_bound = 1; + new_loop->nb_iterations_upper_bound = factor - 1; } else new_exit = single_dom_exit (loop);