From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678360517; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=K9MrQeJgwFrqTTIlmjKQeAC3Yign3o+lnmtkvOwLq5w=; b=etYYBKkIF0WAJkLBSkTSFJ6X+v5tVAiPpyirlVhNeVdPLIo0v4X87tqEQ0Pu515JODT91y nWTCo1UvserJ3iNMJcmj4OZdlRtS9tVKB4l9lsAlJ2CwuAU2uvjSV4rr9paQcgEBzmYRlx PcdSxeOPhhiN6Pd6GQ9O1MJAw1/D/vo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678360517; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=K9MrQeJgwFrqTTIlmjKQeAC3Yign3o+lnmtkvOwLq5w=; b=N1DzqChfSIDICnSmkK1LCu7upzO9UmISIiUx18IYQODYJxLoYxkVQ0P2lzUyiBbIqhnY9B TShnq9/tKI80nkBQ== 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) From: Richard Biener 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 Content-Type: text/plain; charset=US-ASCII 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 List-Id: Message-ID: <20230309111517.M4uvDz9Dsuy0MnXGRI1CbM8iAspoiiDcKiM19nrCrIs@z> 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); -- 2.35.3