From 438c239d7629e2107dd831760835895c82f7d8f3 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Mon, 20 Apr 2009 14:01:52 +0000 Subject: basic-block.h (get_all_dominated_blocks): Declare. 2009-04-20 Richard Guenther * basic-block.h (get_all_dominated_blocks): Declare. * dominance.c (get_all_dominated_blocks): New function. * tree-cfg.c (get_all_dominated_blocks): Remove. (remove_edge_and_dominated_blocks): Adjust. * tree-ssa-phiprop.c (tree_ssa_phiprop_1): Fold in ... (tree_ssa_phiprop): ... here. Use get_all_dominated_blocks instead of recursing. From-SVN: r146425 --- gcc/ChangeLog | 10 ++++++++++ gcc/basic-block.h | 2 ++ gcc/dominance.c | 27 +++++++++++++++++++++++++++ gcc/tree-cfg.c | 16 +--------------- gcc/tree-ssa-phiprop.c | 37 +++++++++++++++---------------------- 5 files changed, 55 insertions(+), 37 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a25d3b0..0fb7222 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2009-04-20 Richard Guenther + + * basic-block.h (get_all_dominated_blocks): Declare. + * dominance.c (get_all_dominated_blocks): New function. + * tree-cfg.c (get_all_dominated_blocks): Remove. + (remove_edge_and_dominated_blocks): Adjust. + * tree-ssa-phiprop.c (tree_ssa_phiprop_1): Fold in ... + (tree_ssa_phiprop): ... here. Use get_all_dominated_blocks + instead of recursing. + 2009-04-20 Doug Kwan * cgraph.h (cgraph_node_ptr): New type for vector functions. diff --git a/gcc/basic-block.h b/gcc/basic-block.h index bd741b5..dfde6739 100644 --- a/gcc/basic-block.h +++ b/gcc/basic-block.h @@ -938,6 +938,8 @@ extern VEC (basic_block, heap) *get_dominated_by (enum cdi_direction, basic_bloc extern VEC (basic_block, heap) *get_dominated_by_region (enum cdi_direction, basic_block *, unsigned); +extern VEC (basic_block, heap) *get_all_dominated_blocks (enum cdi_direction, + basic_block); extern void add_to_dominance_info (enum cdi_direction, basic_block); extern void delete_from_dominance_info (enum cdi_direction, basic_block); basic_block recompute_dominator (enum cdi_direction, basic_block); diff --git a/gcc/dominance.c b/gcc/dominance.c index b4dff4c..2cc1414 100644 --- a/gcc/dominance.c +++ b/gcc/dominance.c @@ -782,6 +782,33 @@ get_dominated_by_region (enum cdi_direction dir, basic_block *region, return doms; } +/* Returns the list of basic blocks including BB dominated by BB, in the + direction DIR. The vector will be sorted in preorder. */ + +VEC (basic_block, heap) * +get_all_dominated_blocks (enum cdi_direction dir, basic_block bb) +{ + VEC(basic_block, heap) *bbs = NULL; + unsigned i; + + i = 0; + VEC_safe_push (basic_block, heap, bbs, bb); + + do + { + basic_block son; + + bb = VEC_index (basic_block, bbs, i++); + for (son = first_dom_son (dir, bb); + son; + son = next_dom_son (dir, son)) + VEC_safe_push (basic_block, heap, bbs, son); + } + while (i < VEC_length (basic_block, bbs)); + + return bbs; +} + /* Redirect all edges pointing to BB to TO. */ void redirect_immediate_dominators (enum cdi_direction dir, basic_block bb, diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 9c70146..009f9a9 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -6681,20 +6681,6 @@ gimple_purge_dead_abnormal_call_edges (basic_block bb) return changed; } -/* Stores all basic blocks dominated by BB to DOM_BBS. */ - -static void -get_all_dominated_blocks (basic_block bb, VEC (basic_block, heap) **dom_bbs) -{ - basic_block son; - - VEC_safe_push (basic_block, heap, *dom_bbs, bb); - for (son = first_dom_son (CDI_DOMINATORS, bb); - son; - son = next_dom_son (CDI_DOMINATORS, son)) - get_all_dominated_blocks (son, dom_bbs); -} - /* Removes edge E and all the blocks dominated by it, and updates dominance information. The IL in E->src needs to be updated separately. If dominance info is not available, only the edge E is removed.*/ @@ -6754,7 +6740,7 @@ remove_edge_and_dominated_blocks (edge e) get_immediate_dominator (CDI_DOMINATORS, e->dest)->index); else { - get_all_dominated_blocks (e->dest, &bbs_to_remove); + bbs_to_remove = get_all_dominated_blocks (CDI_DOMINATORS, e->dest); for (i = 0; VEC_iterate (basic_block, bbs_to_remove, i, bb); i++) { FOR_EACH_EDGE (f, ei, bb->succs) diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index d95b358..f608f1d 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -325,41 +325,34 @@ next:; return phi_inserted; } -/* Helper walking the dominator tree starting from BB and processing - phi nodes with global data PHIVN and N. */ - -static bool -tree_ssa_phiprop_1 (basic_block bb, struct phiprop_d *phivn, size_t n) -{ - bool did_something = false; - basic_block son; - gimple_stmt_iterator gsi; - - for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - did_something |= propagate_with_phi (bb, gsi_stmt (gsi), phivn, n); - - for (son = first_dom_son (CDI_DOMINATORS, bb); - son; - son = next_dom_son (CDI_DOMINATORS, son)) - did_something |= tree_ssa_phiprop_1 (son, phivn, n); - - return did_something; -} - /* Main entry for phiprop pass. */ static unsigned int tree_ssa_phiprop (void) { + VEC(basic_block, heap) *bbs; struct phiprop_d *phivn; + bool did_something = false; + basic_block bb; + gimple_stmt_iterator gsi; + unsigned i; calculate_dominance_info (CDI_DOMINATORS); phivn = XCNEWVEC (struct phiprop_d, num_ssa_names); - if (tree_ssa_phiprop_1 (ENTRY_BLOCK_PTR, phivn, num_ssa_names)) + /* Walk the dominator tree in preorder. */ + bbs = get_all_dominated_blocks (CDI_DOMINATORS, + single_succ (ENTRY_BLOCK_PTR)); + for (i = 0; VEC_iterate (basic_block, bbs, i, bb); ++i) + for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + did_something |= propagate_with_phi (bb, gsi_stmt (gsi), + phivn, num_ssa_names); + + if (did_something) gsi_commit_edge_inserts (); + VEC_free (basic_block, heap, bbs); free (phivn); return 0; -- cgit v1.1