From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id A3D5E38582BE; Wed, 24 Aug 2022 06:47:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A3D5E38582BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661323668; bh=lOIvJm51yuZUf6WmNtbnzPDKy4KG9cD41TkdwV9y37M=; h=From:To:Subject:Date:From; b=ulb9T/R4u1ABtkOGEKVEUpyLa43cQYiNP6+Db4VOavRCct4APgIDo+mhBGNtG7t+J hYS/ds5ih25o68MvcRkirNfXV3NS7OlaxsiCKIKgHjbg0ID+xPUCafiYCA/rr7MOtJ XVi5Z3cTadtyGKy2OqttvLd1rRtscGbvz2kqVNxM= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2164] Speedup path discovery in predicate::use_cannot_happen X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 82d46ad79e79394f374bc0ddb7591d166b0b61eb X-Git-Newrev: b6864f4ee87fb56299fc82e1e0ced127b747d87a Message-Id: <20220824064748.A3D5E38582BE@sourceware.org> Date: Wed, 24 Aug 2022 06:47:48 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b6864f4ee87fb56299fc82e1e0ced127b747d87a commit r13-2164-gb6864f4ee87fb56299fc82e1e0ced127b747d87a Author: Richard Biener Date: Tue Aug 23 14:05:34 2022 +0200 Speedup path discovery in predicate::use_cannot_happen The following reverts a hunk from r8-5789-g11ef0b22d68cd1 that made compute_control_dep_chain start from function entry rather than the immediate dominator of the source block of the edge with the undefined value on the PHI node. Reverting at that point does not reveal any testsuite FAIL, in particular the added testcase still passes. The following adjusts this to the other function that computes predicates that hold on the PHI incoming edges with undefined values, predicate::init_from_phi_def, which starts at the immediate dominator of the PHI. That's much less likely to run into the CFG walking limit. * gimple-predicate-analysis.cc (predicate::use_cannot_happen): Start the compute_control_dep_chain walk from the immediate dominator of the PHI. Diff: --- gcc/gimple-predicate-analysis.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index a4291657d0b..ea81daacd4f 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -1293,6 +1293,12 @@ predicate::use_cannot_happen (gphi *phi, unsigned opnds) use_guard = &phi_use_guard_intersection; } + basic_block phi_bb = gimple_bb (phi); + /* Find the closest dominating bb to be the control dependence root. */ + basic_block cd_root = get_immediate_dominator (CDI_DOMINATORS, phi_bb); + if (!cd_root) + return false; + /* Look for the control dependencies of all the interesting operands and build guard predicates describing them. */ unsigned n = gimple_phi_num_args (phi); @@ -1308,7 +1314,7 @@ predicate::use_cannot_happen (gphi *phi, unsigned opnds) unsigned num_calls = 0; /* Build the control dependency chain for the PHI argument... */ - if (!compute_control_dep_chain (ENTRY_BLOCK_PTR_FOR_FN (cfun), + if (!compute_control_dep_chain (cd_root, e->src, dep_chains, &num_chains, cur_chain, &num_calls)) {