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 67FA4385828E for ; Tue, 16 Aug 2022 12:18:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 67FA4385828E Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 48E9A1FB66 for ; Tue, 16 Aug 2022 12:18:28 +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 42F262C149 for ; Tue, 16 Aug 2022 12:18:28 +0000 (UTC) Date: Tue, 16 Aug 2022 12:18:28 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Stop backwards thread discovery when leaving a loop 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, 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-List-Received-Date: Tue, 16 Aug 2022 12:18:30 -0000 Message-ID: <20220816121828.SL-vzRdRT1lRftJwZjwIbs7OioxvBjwQGpbJaOwyIIs@z> The backward threader copier cannot deal with the situation of copying blocks belonging to different loops and will reject those paths late. The following uses this to prune path discovery, saving on compile-time. Note the off-loop block is still considered as entry edge origin. Bootstrapped and tested on x86_64-unknown-linux-gnu. I've split this out from the 'Support threading of just the exit edge' patch under discussion - it's really an independent change. Pushed. * tree-ssa-threadbackward.cc (back_threader::find_paths_to_names): Do not walk further if we are leaving the current loop. --- gcc/tree-ssa-threadbackward.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/tree-ssa-threadbackward.cc b/gcc/tree-ssa-threadbackward.cc index b886027fccf..1c362839fab 100644 --- a/gcc/tree-ssa-threadbackward.cc +++ b/gcc/tree-ssa-threadbackward.cc @@ -355,6 +355,12 @@ back_threader::find_paths_to_names (basic_block bb, bitmap interesting, || maybe_register_path ())) ; + // The backwards thread copier cannot copy blocks that do not belong + // to the same loop, so when the new source of the path entry no + // longer belongs to it we don't need to search further. + else if (m_path[0]->loop_father != bb->loop_father) + ; + // Continue looking for ways to extend the path but limit the // search space along a branch else if ((overall_paths = overall_paths * EDGE_COUNT (bb->preds)) -- 2.35.3