From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 9706938515F2; Wed, 7 Sep 2022 10:08:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9706938515F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662545297; bh=Y0XbhDWm+NVAVumTLeWDoeY0947TGYJ0OrO9Y6Bangs=; h=From:To:Subject:Date:From; b=c8fH44v6CNlOMjmunuQTgV/GhmWR/jhouMEAZ/Of2mMj9z9KR9wXFFkWMMYEw7z/6 dSHljytNYFHjLpiUW1+RA2V80ZCUga4upWrMS2a+KRJBYfoffkruvNj7H5Hr/PQwx3 MiY/BFuS/30j4Tp8wP9ic3NODNSQhIMi/Ak1rZ6w= 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-2513] mark region also for USE predicate discovery X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: d6106132907f6bd01109f2616d20a87edecc6fc6 X-Git-Newrev: d14514641d7d2052bc2bf1f09018e1f18f19850a Message-Id: <20220907100817.9706938515F2@sourceware.org> Date: Wed, 7 Sep 2022 10:08:17 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d14514641d7d2052bc2bf1f09018e1f18f19850a commit r13-2513-gd14514641d7d2052bc2bf1f09018e1f18f19850a Author: Richard Biener Date: Tue Sep 6 15:30:53 2022 +0200 mark region also for USE predicate discovery The following makes sure to mark the dominating region also for USE predicate discovery, avoiding compute_control_dep_chain to walk to unrelated areas, eating up walking budget. * gimple-predicate-analysis.cc (dfs_mark_dominating_region): Adjust to take the region exit source as argument. (uninit_analysis::init_from_phi_def): Adjust. (uninit_analysis::init_use_preds): Mark the dominating region before computing control dependences. Diff: --- gcc/gimple-predicate-analysis.cc | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index 5dade458947..f81af2589cd 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -934,23 +934,23 @@ simple_control_dep_chain (vec& chain, basic_block from, basic_block to) } /* Perform a DFS walk on predecessor edges to mark the region denoted - by the EXIT edge and DOM which dominates EXIT->src, including DOM. + by the EXIT_SRC block and DOM which dominates EXIT_SRC, including DOM. Blocks in the region are marked with FLAG and added to BBS. BBS is filled up to its capacity only after which the walk is terminated and false is returned. If the whole region was marked, true is returned. */ static bool -dfs_mark_dominating_region (edge exit, basic_block dom, int flag, +dfs_mark_dominating_region (basic_block exit_src, basic_block dom, int flag, vec &bbs) { - if (exit->src == dom || exit->src->flags & flag) + if (exit_src == dom || exit_src->flags & flag) return true; if (!bbs.space (1)) return false; - bbs.quick_push (exit->src); - exit->src->flags |= flag; + bbs.quick_push (exit_src); + exit_src->flags |= flag; auto_vec stack (bbs.allocated () - bbs.length () + 1); - stack.quick_push (ei_start (exit->src->preds)); + stack.quick_push (ei_start (exit_src->preds)); while (!stack.is_empty ()) { /* Look at the edge on the top of the stack. */ @@ -1960,6 +1960,10 @@ uninit_analysis::init_use_preds (predicate &use_preds, basic_block def_bb, } while (1); + auto_bb_flag in_region (cfun); + auto_vec region (MIN (n_basic_blocks_for_fn (cfun), + param_uninit_control_dep_attempts)); + /* Set DEP_CHAINS to the set of edges between CD_ROOT and USE_BB. Each DEP_CHAINS element is a series of edges whose conditions are logical conjunctions. Together, the DEP_CHAINS vector is @@ -1967,7 +1971,9 @@ uninit_analysis::init_use_preds (predicate &use_preds, basic_block def_bb, unsigned num_chains = 0; auto_vec dep_chains[MAX_NUM_CHAINS]; - if (!compute_control_dep_chain (cd_root, use_bb, dep_chains, &num_chains)) + if (!dfs_mark_dominating_region (use_bb, cd_root, in_region, region) + || !compute_control_dep_chain (cd_root, use_bb, dep_chains, &num_chains, + in_region)) { /* If the info in dep_chains is not complete we need to use a conservative approximation for the use predicate. */ @@ -1979,6 +1985,10 @@ uninit_analysis::init_use_preds (predicate &use_preds, basic_block def_bb, simple_control_dep_chain (dep_chains[0], cd_root, use_bb); } + /* Unmark the region. */ + for (auto bb : region) + bb->flags &= ~in_region; + /* From the set of edges computed above initialize *THIS as the OR condition under which the definition in DEF_BB is used in USE_BB. Each OR subexpression is represented by one element of DEP_CHAINS, @@ -2061,7 +2071,8 @@ uninit_analysis::init_from_phi_def (gphi *phi) } } for (unsigned i = 0; i < nedges; i++) - if (!dfs_mark_dominating_region (def_edges[i], cd_root, in_region, region)) + if (!dfs_mark_dominating_region (def_edges[i]->src, cd_root, + in_region, region)) break; unsigned num_chains = 0;