From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 65AC03857BA6; Mon, 29 Aug 2022 09:03:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 65AC03857BA6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661763834; bh=0L6eNl9Psi4gCHJ/pOmK4YwVlyTPhipw+UW2QL4nf/4=; h=From:To:Subject:Date:From; b=d9BdEyqG0shLeszy1DQJbTrCXxDKfwDtWBp1UHVgc1gVBvbXPWrkqadUREBIKXg9F 5GwmJTSv9ke6KRmndFcbx4PyEl7R5SjIorGFjhYmQ4/7u1Mm5d15fYHTc9yPw9zPoY 7qjIjg8koDHgY0G5xgQuuGTn1F6l1mcfKBhRJVHw= 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-2245] Refactor init_use_preds and find_control_equiv_block X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 3358c24a32129f6dafa9f7af2dfeab3bca9d68c4 X-Git-Newrev: 9b3cd1755be55fbed5f86fd55bb1a6c3279f1fc4 Message-Id: <20220829090354.65AC03857BA6@sourceware.org> Date: Mon, 29 Aug 2022 09:03:54 +0000 (GMT) List-Id: https://gcc.gnu.org/g:9b3cd1755be55fbed5f86fd55bb1a6c3279f1fc4 commit r13-2245-g9b3cd1755be55fbed5f86fd55bb1a6c3279f1fc4 Author: Richard Biener Date: Fri Aug 26 14:25:51 2022 +0200 Refactor init_use_preds and find_control_equiv_block The following inlines find_control_equiv_block and is_loop_exit into init_use_preds and refactors that for better readability and similarity with the post-dominator walk in compute_control_dep_chain. * gimple-predicate-analysis.cc (is_loop_exit, find_control_equiv_block): Inline into single caller ... (uninit_analysis::init_use_preds): ... here and refactor. Diff: --- gcc/gimple-predicate-analysis.cc | 55 ++++++++++++---------------------------- 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc index 934e9516e7b..e388bb37685 100644 --- a/gcc/gimple-predicate-analysis.cc +++ b/gcc/gimple-predicate-analysis.cc @@ -59,33 +59,6 @@ for the case corresponding to an edge. */ #define MAX_SWITCH_CASES 40 -/* Return true if, when BB1 is postdominating BB2, BB1 is a loop exit. */ - -static bool -is_loop_exit (basic_block bb2, basic_block bb1) -{ - return single_pred_p (bb1) && !single_succ_p (bb2); -} - -/* Find BB's closest postdominator that is its control equivalent (i.e., - that's controlled by the same predicate). */ - -static inline basic_block -find_control_equiv_block (basic_block bb) -{ - basic_block pdom = get_immediate_dominator (CDI_POST_DOMINATORS, bb); - - /* Skip the postdominating bb that is also a loop exit. */ - if (is_loop_exit (bb, pdom)) - return NULL; - - /* If the postdominator is dominated by BB, return it. */ - if (dominated_by_p (CDI_DOMINATORS, pdom, bb)) - return pdom; - - return NULL; -} - /* Return true if X1 is the negation of X2. */ static inline bool @@ -1991,25 +1964,29 @@ bool uninit_analysis::init_use_preds (predicate &use_preds, basic_block def_bb, basic_block use_bb) { - gcc_assert (use_preds.is_empty ()); + gcc_assert (use_preds.is_empty () + && dominated_by_p (CDI_DOMINATORS, use_bb, def_bb)); /* Set CD_ROOT to the basic block closest to USE_BB that is the control equivalent of (is guarded by the same predicate as) DEF_BB that also - dominates USE_BB. */ + dominates USE_BB. This mimics the inner loop in + compute_control_dep_chain. */ basic_block cd_root = def_bb; - while (dominated_by_p (CDI_DOMINATORS, use_bb, cd_root)) + do { - /* Find CD_ROOT's closest postdominator that's its control - equivalent. */ - if (basic_block bb = find_control_equiv_block (cd_root)) - if (dominated_by_p (CDI_DOMINATORS, use_bb, bb)) - { - cd_root = bb; - continue; - } + basic_block pdom = get_immediate_dominator (CDI_POST_DOMINATORS, cd_root); - break; + /* Stop at a loop exit which is also postdominating cd_root. */ + if (single_pred_p (pdom) && !single_succ_p (cd_root)) + break; + + if (!dominated_by_p (CDI_DOMINATORS, pdom, cd_root) + || !dominated_by_p (CDI_DOMINATORS, use_bb, pdom)) + break; + + cd_root = pdom; } + while (1); /* 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