From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 777F03858D1E for ; Thu, 1 Sep 2022 13:07:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 777F03858D1E Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 8092C226D3 for ; Thu, 1 Sep 2022 13:07:03 +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 7B3362C141 for ; Thu, 1 Sep 2022 13:07:03 +0000 (UTC) Date: Thu, 1 Sep 2022 13:07:03 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove cycle checking from compute_control_dep_chain 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: Thu, 01 Sep 2022 13:07:10 -0000 Message-ID: <20220901130703.JxOivQ5_dr4Gn482XaR-tgLpRun-xzHEM49v53YqbEs@z> Now that we have DFS_BACK_EDGE marks we can simply avoid walking those instead of repeatedly looking for a cycle on the current chain. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * gimple-predicate-analysis.cc (compute_control_dep_chain): Remove cycle detection, instead avoid walking backedges. --- gcc/gimple-predicate-analysis.cc | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index 2982268fdfd..a754ff0a029 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -1035,18 +1035,6 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, fprintf (dump_file, "chain length exceeds 5: %u\n", cur_chain_len); } - for (unsigned i = 0; i < cur_chain_len; i++) - { - edge e = cur_cd_chain[i]; - /* Cycle detected. */ - if (e->src == dom_bb) - { - if (dump_file) - fprintf (dump_file, "cycle detected\n"); - return false; - } - } - if (DEBUG_PREDICATE_ANALYZER && dump_file) fprintf (dump_file, "%*s%s (dom_bb = %u, dep_bb = %u, cd_chains = { %s }, ...)\n", @@ -1061,7 +1049,7 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, FOR_EACH_EDGE (e, ei, dom_bb->succs) { int post_dom_check = 0; - if (e->flags & (EDGE_FAKE | EDGE_ABNORMAL)) + if (e->flags & (EDGE_FAKE | EDGE_ABNORMAL | EDGE_DFS_BACK)) continue; basic_block cd_bb = e->dest; @@ -1110,6 +1098,12 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb, break; } + /* The post-dominator walk will reach a backedge only + from a forwarder, otherwise it should choose to exit + the SCC. */ + if (single_succ_p (cd_bb) + && single_succ_edge (cd_bb)->flags & EDGE_DFS_BACK) + break; cd_bb = get_immediate_dominator (CDI_POST_DOMINATORS, cd_bb); post_dom_check++; if (cd_bb == EXIT_BLOCK_PTR_FOR_FN (cfun) -- 2.35.3