Commit 438c239d by Richard Guenther Committed by Richard Biener

basic-block.h (get_all_dominated_blocks): Declare.

2009-04-20  Richard Guenther  <rguenther@suse.de>

	* 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
parent e69614ad
2009-04-20 Richard Guenther <rguenther@suse.de>
* 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 <dougkwan@google.com> 2009-04-20 Doug Kwan <dougkwan@google.com>
* cgraph.h (cgraph_node_ptr): New type for vector functions. * cgraph.h (cgraph_node_ptr): New type for vector functions.
......
...@@ -938,6 +938,8 @@ extern VEC (basic_block, heap) *get_dominated_by (enum cdi_direction, basic_bloc ...@@ -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, extern VEC (basic_block, heap) *get_dominated_by_region (enum cdi_direction,
basic_block *, basic_block *,
unsigned); 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 add_to_dominance_info (enum cdi_direction, basic_block);
extern void delete_from_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); basic_block recompute_dominator (enum cdi_direction, basic_block);
......
...@@ -782,6 +782,33 @@ get_dominated_by_region (enum cdi_direction dir, basic_block *region, ...@@ -782,6 +782,33 @@ get_dominated_by_region (enum cdi_direction dir, basic_block *region,
return doms; 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. */ /* Redirect all edges pointing to BB to TO. */
void void
redirect_immediate_dominators (enum cdi_direction dir, basic_block bb, redirect_immediate_dominators (enum cdi_direction dir, basic_block bb,
......
...@@ -6681,20 +6681,6 @@ gimple_purge_dead_abnormal_call_edges (basic_block bb) ...@@ -6681,20 +6681,6 @@ gimple_purge_dead_abnormal_call_edges (basic_block bb)
return changed; 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 /* Removes edge E and all the blocks dominated by it, and updates dominance
information. The IL in E->src needs to be updated separately. information. The IL in E->src needs to be updated separately.
If dominance info is not available, only the edge E is removed.*/ If dominance info is not available, only the edge E is removed.*/
...@@ -6754,7 +6740,7 @@ remove_edge_and_dominated_blocks (edge e) ...@@ -6754,7 +6740,7 @@ remove_edge_and_dominated_blocks (edge e)
get_immediate_dominator (CDI_DOMINATORS, e->dest)->index); get_immediate_dominator (CDI_DOMINATORS, e->dest)->index);
else 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 (i = 0; VEC_iterate (basic_block, bbs_to_remove, i, bb); i++)
{ {
FOR_EACH_EDGE (f, ei, bb->succs) FOR_EACH_EDGE (f, ei, bb->succs)
......
...@@ -325,41 +325,34 @@ next:; ...@@ -325,41 +325,34 @@ next:;
return phi_inserted; 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. */ /* Main entry for phiprop pass. */
static unsigned int static unsigned int
tree_ssa_phiprop (void) tree_ssa_phiprop (void)
{ {
VEC(basic_block, heap) *bbs;
struct phiprop_d *phivn; struct phiprop_d *phivn;
bool did_something = false;
basic_block bb;
gimple_stmt_iterator gsi;
unsigned i;
calculate_dominance_info (CDI_DOMINATORS); calculate_dominance_info (CDI_DOMINATORS);
phivn = XCNEWVEC (struct phiprop_d, num_ssa_names); 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 (); gsi_commit_edge_inserts ();
VEC_free (basic_block, heap, bbs);
free (phivn); free (phivn);
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment