[PATCH] Remove find_pdom and find_dom

Richard Biener rguenther@suse.de
Thu Nov 11 08:21:47 GMT 2021


This removes now useless wrappers around get_immediate_dominator.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

2021-11-11  Richard Biener  <rguenther@suse.de>

	* cfganal.c (find_pdom): Remove.
	(control_dependences::find_control_dependence): Remove
	special-casing of entry block, call get_immediate_dominator
	directly.
	* gimple-predicate-analysis.cc (find_pdom): Remove.
	(find_dom): Likewise.
	(find_control_equiv_block): Call get_immediate_dominator
	directly.
	(compute_control_dep_chain): Likewise.
	(predicate::init_from_phi_def): Likewise.
---
 gcc/cfganal.c                    | 28 ++++---------------------
 gcc/gimple-predicate-analysis.cc | 36 +++-----------------------------
 2 files changed, 7 insertions(+), 57 deletions(-)

diff --git a/gcc/cfganal.c b/gcc/cfganal.c
index 11ab23623ae..0cba612738d 100644
--- a/gcc/cfganal.c
+++ b/gcc/cfganal.c
@@ -372,25 +372,6 @@ control_dependences::clear_control_dependence_bitmap (basic_block bb)
   bitmap_clear (&control_dependence_map[bb->index]);
 }
 
-/* Find the immediate postdominator PDOM of the specified basic block BLOCK.
-   This function is necessary because some blocks have negative numbers.  */
-
-static inline basic_block
-find_pdom (basic_block block)
-{
-  gcc_assert (block != ENTRY_BLOCK_PTR_FOR_FN (cfun));
-
-  if (block == EXIT_BLOCK_PTR_FOR_FN (cfun))
-    return EXIT_BLOCK_PTR_FOR_FN (cfun);
-  else
-    {
-      basic_block bb = get_immediate_dominator (CDI_POST_DOMINATORS, block);
-      if (! bb)
-	return EXIT_BLOCK_PTR_FOR_FN (cfun);
-      return bb;
-    }
-}
-
 /* Determine all blocks' control dependences on the given edge with edge_list
    EL index EDGE_INDEX, ala Morgan, Section 3.6.  */
 
@@ -402,15 +383,14 @@ control_dependences::find_control_dependence (int edge_index)
 
   gcc_assert (get_edge_src (edge_index) != EXIT_BLOCK_PTR_FOR_FN (cfun));
 
-  if (get_edge_src (edge_index) == ENTRY_BLOCK_PTR_FOR_FN (cfun))
-    ending_block = single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun));
-  else
-    ending_block = find_pdom (get_edge_src (edge_index));
+  ending_block = get_immediate_dominator (CDI_POST_DOMINATORS,
+					  get_edge_src (edge_index));
 
   for (current_block = get_edge_dest (edge_index);
        current_block != ending_block
        && current_block != EXIT_BLOCK_PTR_FOR_FN (cfun);
-       current_block = find_pdom (current_block))
+       current_block = get_immediate_dominator (CDI_POST_DOMINATORS,
+						current_block))
     set_control_dependence_map_bit (current_block, edge_index);
 }
 
diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc
index f0c84446194..454113d532e 100644
--- a/gcc/gimple-predicate-analysis.cc
+++ b/gcc/gimple-predicate-analysis.cc
@@ -45,36 +45,6 @@
 
 #define DEBUG_PREDICATE_ANALYZER 1
 
-/* Find the immediate postdominator of the specified basic block BB.  */
-
-static inline basic_block
-find_pdom (basic_block bb)
-{
-  basic_block exit_bb = EXIT_BLOCK_PTR_FOR_FN (cfun);
-  if (bb == exit_bb)
-    return exit_bb;
-
-  if (basic_block pdom = get_immediate_dominator (CDI_POST_DOMINATORS, bb))
-    return pdom;
-
-  return exit_bb;
-}
-
-/* Find the immediate dominator of the specified basic block BB.  */
-
-static inline basic_block
-find_dom (basic_block bb)
-{
-  basic_block entry_bb = ENTRY_BLOCK_PTR_FOR_FN (cfun);
-  if (bb == entry_bb)
-    return entry_bb;
-
-  if (basic_block dom = get_immediate_dominator (CDI_DOMINATORS, bb))
-    return dom;
-
-  return entry_bb;
-}
-
 /* Return true if BB1 is postdominating BB2 and BB1 is not a loop exit
    bb.  The loop exit bb check is simple and does not cover all cases.  */
 
@@ -96,7 +66,7 @@ is_non_loop_exit_postdominating (basic_block bb1, basic_block bb2)
 static inline basic_block
 find_control_equiv_block (basic_block bb)
 {
-  basic_block pdom = find_pdom (bb);
+  basic_block pdom = get_immediate_dominator (CDI_POST_DOMINATORS, bb);
 
   /* Skip the postdominating bb that is also a loop exit.  */
   if (!is_non_loop_exit_postdominating (pdom, bb))
@@ -1167,7 +1137,7 @@ compute_control_dep_chain (basic_block dom_bb, const_basic_block dep_bb,
 	      break;
 	    }
 
-	  cd_bb = find_pdom (cd_bb);
+	  cd_bb = get_immediate_dominator (CDI_POST_DOMINATORS, cd_bb);
 	  post_dom_check++;
 	  if (cd_bb == EXIT_BLOCK_PTR_FOR_FN (cfun)
 	      || post_dom_check > MAX_POSTDOM_CHECK)
@@ -1788,7 +1758,7 @@ predicate::init_from_phi_def (gphi *phi)
 
   basic_block phi_bb = gimple_bb (phi);
   /* Find the closest dominating bb to be the control dependence root.  */
-  basic_block cd_root = find_dom (phi_bb);
+  basic_block cd_root = get_immediate_dominator (CDI_DOMINATORS, phi_bb);
   if (!cd_root)
     return false;
 
-- 
2.31.1


More information about the Gcc-patches mailing list