This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Minor cleanup for dominator walker
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 09 Feb 2004 13:05:34 -0700
- Subject: [tree-ssa] Minor cleanup for dominator walker
- Reply-to: law at redhat dot com
This minor cleanup has been on my todo list for awhile.
Basically this changes the last argument in the dominator walker callbacks
to be the parent block in the dominator tree rather than the last statement
in the parent block.
Bootstrapped and regression tested on i686-pc-linux-gnu.
* domwalk.c (walk_dominator_tree): Change last argument to be the
parent block in the dominator tree rather than the last statement
in the parent block in the dominator tree. Similarly in all the
callbacks.
* domwalk.h (struct dom_walk_data): Update callback prototypes.
* tree-ssa-dom.c: Corresponding changes.
* tree-ssa.c: Likewise.
Index: domwalk.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/domwalk.c,v
retrieving revision 1.1.2.7
diff -c -3 -p -r1.1.2.7 domwalk.c
*** domwalk.c 4 Feb 2004 19:36:43 -0000 1.1.2.7
--- domwalk.c 9 Feb 2004 19:03:42 -0000
*************** Boston, MA 02111-1307, USA. */
*** 127,140 ****
callback itself. Instead the dominator optimizer itself should walk
the statements calling a callback for each statement encountered.
The direction of the statement walk would be determined by a flag
! in the main dominator walker structure.
!
! The "tree" argument for each callback is really specific to the
! dominator optimizer and we should find a better way to pass around
! that information. Doing so would effectively allow us to use the
! dominator walker for tree->rtl expansion and within the RTL optimizers
! too. */
!
/* Recursively walk the dominator tree.
--- 127,133 ----
callback itself. Instead the dominator optimizer itself should walk
the statements calling a callback for each statement encountered.
The direction of the statement walk would be determined by a flag
! in the main dominator walker structure. */
/* Recursively walk the dominator tree.
*************** Boston, MA 02111-1307, USA. */
*** 144,162 ****
BB is the basic block we are currently visiting.
! LAST is the last statement in our parent's block if our parent's block
! ended with a control structure. Long term this argument should probably
! go away. Once that happens this engine could also be used in the
! RTL optimizers. */
void
walk_dominator_tree (struct dom_walk_data *walk_data,
basic_block bb,
! tree last)
{
void *bd = NULL;
basic_block dest;
- tree clast;
/* Callback to initialize the local data structure. */
if (walk_data->initialize_block_local_data)
--- 137,151 ----
BB is the basic block we are currently visiting.
! PARENT is BB's parent block in the dominator tree. */
void
walk_dominator_tree (struct dom_walk_data *walk_data,
basic_block bb,
! basic_block parent)
{
void *bd = NULL;
basic_block dest;
/* Callback to initialize the local data structure. */
if (walk_data->initialize_block_local_data)
*************** walk_dominator_tree (struct dom_walk_dat
*** 188,209 ****
/* Callback for operations to execute before we have walked the
dominator children, but before we walk statements. */
if (walk_data->before_dom_children_before_stmts)
! (*walk_data->before_dom_children_before_stmts) (walk_data, bb, last);
/* Statement walk before walking dominator children. */
if (walk_data->before_dom_children_walk_stmts)
! (*walk_data->before_dom_children_walk_stmts) (walk_data, bb, last);
/* Callback for operations to execute before we have walked the
dominator children, and after we walk statements. */
if (walk_data->before_dom_children_after_stmts)
! (*walk_data->before_dom_children_after_stmts) (walk_data, bb, last);
!
! /* If this block ends with a control statement, pass it down so that we
! might reason with it. */
! clast = last_stmt (bb);
! if (clast && !is_ctrl_stmt (clast))
! clast = NULL;
/* Recursively call ourselves on the dominator children of BB. */
for (dest = first_dom_son (CDI_DOMINATORS, bb);
--- 177,192 ----
/* Callback for operations to execute before we have walked the
dominator children, but before we walk statements. */
if (walk_data->before_dom_children_before_stmts)
! (*walk_data->before_dom_children_before_stmts) (walk_data, bb, parent);
/* Statement walk before walking dominator children. */
if (walk_data->before_dom_children_walk_stmts)
! (*walk_data->before_dom_children_walk_stmts) (walk_data, bb, parent);
/* Callback for operations to execute before we have walked the
dominator children, and after we walk statements. */
if (walk_data->before_dom_children_after_stmts)
! (*walk_data->before_dom_children_after_stmts) (walk_data, bb, parent);
/* Recursively call ourselves on the dominator children of BB. */
for (dest = first_dom_son (CDI_DOMINATORS, bb);
*************** walk_dominator_tree (struct dom_walk_dat
*** 213,234 ****
/* The destination block may have become unreachable, in
which case there's no point in optimizing it. */
if (dest->pred)
! walk_dominator_tree (walk_data, dest, clast);
}
/* Callback for operations to execute after we have walked the
dominator children, but before we walk statements. */
if (walk_data->after_dom_children_before_stmts)
! (*walk_data->after_dom_children_before_stmts) (walk_data, bb, last);
/* Statement walk after walking dominator children. */
if (walk_data->after_dom_children_walk_stmts)
! (*walk_data->after_dom_children_walk_stmts) (walk_data, bb, last);
/* Callback for operations to execute after we have walked the
dominator children and after we have walked statements. */
if (walk_data->after_dom_children_after_stmts)
! (*walk_data->after_dom_children_after_stmts) (walk_data, bb, last);
if (walk_data->initialize_block_local_data)
{
--- 196,217 ----
/* The destination block may have become unreachable, in
which case there's no point in optimizing it. */
if (dest->pred)
! walk_dominator_tree (walk_data, dest, bb);
}
/* Callback for operations to execute after we have walked the
dominator children, but before we walk statements. */
if (walk_data->after_dom_children_before_stmts)
! (*walk_data->after_dom_children_before_stmts) (walk_data, bb, parent);
/* Statement walk after walking dominator children. */
if (walk_data->after_dom_children_walk_stmts)
! (*walk_data->after_dom_children_walk_stmts) (walk_data, bb, parent);
/* Callback for operations to execute after we have walked the
dominator children and after we have walked statements. */
if (walk_data->after_dom_children_after_stmts)
! (*walk_data->after_dom_children_after_stmts) (walk_data, bb, parent);
if (walk_data->initialize_block_local_data)
{
Index: domwalk.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/domwalk.h,v
retrieving revision 1.1.2.4
diff -c -3 -p -r1.1.2.4 domwalk.h
*** domwalk.h 26 Nov 2003 03:22:23 -0000 1.1.2.4
--- domwalk.h 9 Feb 2004 19:03:42 -0000
*************** struct dom_walk_data
*** 43,69 ****
This typically initializes an block local data and pushes that
data onto BLOCK_DATA_STACK. */
void (*before_dom_children_before_stmts) (struct dom_walk_data *,
! basic_block, tree);
/* Function to call to walk statements before the recursive walk
of the dominator children. */
void (*before_dom_children_walk_stmts) (struct dom_walk_data *,
! basic_block, tree);
/* Function to call after the statement walk occurring before the
recursive walk of the dominator children. */
void (*before_dom_children_after_stmts) (struct dom_walk_data *,
! basic_block, tree);
/* Function to call before the statement walk occurring after the
recursive walk of the dominator children. */
void (*after_dom_children_before_stmts) (struct dom_walk_data *,
! basic_block, tree);
/* Function to call to walk statements after the recursive walk
of the dominator children. */
void (*after_dom_children_walk_stmts) (struct dom_walk_data *,
! basic_block, tree);
/* Function to call after the statement walk occurring after the
recursive walk of the dominator children.
--- 43,69 ----
This typically initializes an block local data and pushes that
data onto BLOCK_DATA_STACK. */
void (*before_dom_children_before_stmts) (struct dom_walk_data *,
! basic_block, basic_block);
/* Function to call to walk statements before the recursive walk
of the dominator children. */
void (*before_dom_children_walk_stmts) (struct dom_walk_data *,
! basic_block, basic_block);
/* Function to call after the statement walk occurring before the
recursive walk of the dominator children. */
void (*before_dom_children_after_stmts) (struct dom_walk_data *,
! basic_block, basic_block);
/* Function to call before the statement walk occurring after the
recursive walk of the dominator children. */
void (*after_dom_children_before_stmts) (struct dom_walk_data *,
! basic_block, basic_block);
/* Function to call to walk statements after the recursive walk
of the dominator children. */
void (*after_dom_children_walk_stmts) (struct dom_walk_data *,
! basic_block, basic_block);
/* Function to call after the statement walk occurring after the
recursive walk of the dominator children.
*************** struct dom_walk_data
*** 71,77 ****
This typically finalizes any block local data and pops
that data from BLOCK_DATA_STACK. */
void (*after_dom_children_after_stmts) (struct dom_walk_data *,
! basic_block, tree);
/* Global data for a walk through the dominator tree. */
void *global_data;
--- 71,77 ----
This typically finalizes any block local data and pops
that data from BLOCK_DATA_STACK. */
void (*after_dom_children_after_stmts) (struct dom_walk_data *,
! basic_block, basic_block);
/* Global data for a walk through the dominator tree. */
void *global_data;
*************** struct dom_walk_data
*** 92,97 ****
varray_type free_block_data;
};
! void walk_dominator_tree (struct dom_walk_data *, basic_block, tree);
void init_walk_dominator_tree (struct dom_walk_data *);
void fini_walk_dominator_tree (struct dom_walk_data *);
--- 92,97 ----
varray_type free_block_data;
};
! void walk_dominator_tree (struct dom_walk_data *, basic_block, basic_block);
void init_walk_dominator_tree (struct dom_walk_data *);
void fini_walk_dominator_tree (struct dom_walk_data *);
Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-dom.c,v
retrieving revision 1.1.2.127
diff -c -3 -p -r1.1.2.127 tree-ssa-dom.c
*** tree-ssa-dom.c 9 Feb 2004 17:35:26 -0000 1.1.2.127
--- tree-ssa-dom.c 9 Feb 2004 19:03:54 -0000
*************** static bool extract_range_from_cond (tre
*** 238,256 ****
static bool cprop_into_stmt (tree);
static void record_equivalences_from_phis (struct dom_walk_data *,
basic_block);
static void record_equivalences_from_incoming_edge (struct dom_walk_data *,
! basic_block, tree);
static bool eliminate_redundant_computations (struct dom_walk_data *,
tree, stmt_ann_t);
static void record_equivalences_from_stmt (tree, struct dom_walk_block_data
*,
int, stmt_ann_t);
static void thread_across_edge (struct dom_walk_data *, edge);
! static void dom_opt_finalize_block (struct dom_walk_data *, basic_block,
tree);
static void dom_opt_initialize_block_local_data (struct dom_walk_data *,
basic_block, bool);
static void dom_opt_initialize_block (struct dom_walk_data *,
! basic_block, tree);
! static void dom_opt_walk_stmts (struct dom_walk_data *, basic_block, tree);
! static void cprop_into_phis (struct dom_walk_data *, basic_block, tree);
static void remove_local_expressions_from_table (varray_type locals,
unsigned limit,
htab_t table);
--- 238,258 ----
static bool cprop_into_stmt (tree);
static void record_equivalences_from_phis (struct dom_walk_data *,
basic_block);
static void record_equivalences_from_incoming_edge (struct dom_walk_data *,
! basic_block, basic_block);
static bool eliminate_redundant_computations (struct dom_walk_data *,
tree, stmt_ann_t);
static void record_equivalences_from_stmt (tree, struct dom_walk_block_data
*,
int, stmt_ann_t);
static void thread_across_edge (struct dom_walk_data *, edge);
! static void dom_opt_finalize_block (struct dom_walk_data *,
! basic_block, basic_block);
static void dom_opt_initialize_block_local_data (struct dom_walk_data *,
basic_block, bool);
static void dom_opt_initialize_block (struct dom_walk_data *,
! basic_block, basic_block);
! static void dom_opt_walk_stmts (struct dom_walk_data *,
! basic_block, basic_block);
! static void cprop_into_phis (struct dom_walk_data *, basic_block,
basic_block);
static void remove_local_expressions_from_table (varray_type locals,
unsigned limit,
htab_t table);
*************** dom_opt_initialize_block_local_data (str
*** 1025,1037 ****
static void
dom_opt_initialize_block (struct dom_walk_data *walk_data,
basic_block bb,
! tree parent_block_last_stmt)
{
if (tree_dump_file && (tree_dump_flags & TDF_DETAILS))
fprintf (tree_dump_file, "\n\nOptimizing block #%d\n\n", bb->index);
! record_equivalences_from_incoming_edge (walk_data, bb,
! parent_block_last_stmt);
/* PHI nodes can create equivalences too. */
record_equivalences_from_phis (walk_data, bb);
--- 1027,1038 ----
static void
dom_opt_initialize_block (struct dom_walk_data *walk_data,
basic_block bb,
! basic_block parent)
{
if (tree_dump_file && (tree_dump_flags & TDF_DETAILS))
fprintf (tree_dump_file, "\n\nOptimizing block #%d\n\n", bb->index);
! record_equivalences_from_incoming_edge (walk_data, bb, parent);
/* PHI nodes can create equivalences too. */
record_equivalences_from_phis (walk_data, bb);
*************** extract_true_false_edges_from_block (bas
*** 1113,1119 ****
static void
dom_opt_finalize_block (struct dom_walk_data *walk_data,
basic_block bb,
! tree parent_block_last_stmt ATTRIBUTE_UNUSED)
{
struct dom_walk_block_data *bd
= VARRAY_TOP_GENERIC_PTR (walk_data->block_data_stack);
--- 1114,1120 ----
static void
dom_opt_finalize_block (struct dom_walk_data *walk_data,
basic_block bb,
! basic_block parent ATTRIBUTE_UNUSED)
{
struct dom_walk_block_data *bd
= VARRAY_TOP_GENERIC_PTR (walk_data->block_data_stack);
*************** record_equivalences_from_phis (struct do
*** 1351,1362 ****
static void
record_equivalences_from_incoming_edge (struct dom_walk_data *walk_data,
basic_block bb,
! tree parent_block_last_stmt)
{
int edge_flags;
struct eq_expr_value eq_expr_value;
struct dom_walk_block_data *bd
! = (struct dom_walk_block_data *)VARRAY_TOP_GENERIC_PTR (walk_data->
block_data_stack);
eq_expr_value.src = NULL;
eq_expr_value.dst = NULL;
--- 1352,1375 ----
static void
record_equivalences_from_incoming_edge (struct dom_walk_data *walk_data,
basic_block bb,
! basic_block parent)
{
int edge_flags;
struct eq_expr_value eq_expr_value;
+ tree parent_block_last_stmt = NULL;
struct dom_walk_block_data *bd
! = VARRAY_TOP_GENERIC_PTR (walk_data->block_data_stack);
!
! /* If our parent block ended with a control statment, then we may be
! able to record some equivalences based on which outgoing edge from
! the parent was followed. */
!
! if (parent)
! {
! parent_block_last_stmt = last_stmt (parent);
! if (parent_block_last_stmt && !is_ctrl_stmt (parent_block_last_stmt))
! parent_block_last_stmt = NULL;
! }
eq_expr_value.src = NULL;
eq_expr_value.dst = NULL;
*************** record_equivalences_from_incoming_edge (
*** 1479,1485 ****
static void
dom_opt_walk_stmts (struct dom_walk_data *walk_data,
basic_block bb,
! tree parent_block_last_stmt ATTRIBUTE_UNUSED)
{
block_stmt_iterator si;
struct dom_walk_block_data *bd
--- 1492,1498 ----
static void
dom_opt_walk_stmts (struct dom_walk_data *walk_data,
basic_block bb,
! basic_block parent ATTRIBUTE_UNUSED)
{
block_stmt_iterator si;
struct dom_walk_block_data *bd
*************** cprop_into_stmt (tree stmt)
*** 2366,2372 ****
static void
cprop_into_phis (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
basic_block bb,
! tree parent_block_last_stmt ATTRIBUTE_UNUSED)
{
edge e;
--- 2379,2385 ----
static void
cprop_into_phis (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
basic_block bb,
! basic_block parent ATTRIBUTE_UNUSED)
{
edge e;
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.192
diff -c -3 -p -r1.1.4.192 tree-ssa.c
*** tree-ssa.c 9 Feb 2004 02:03:48 -0000 1.1.4.192
--- tree-ssa.c 9 Feb 2004 19:04:00 -0000
*************** struct rewrite_block_data
*** 160,176 ****
static struct ssa_stats_d ssa_stats;
/* Local functions. */
! static void rewrite_finalize_block (struct dom_walk_data *, basic_block,
tree);
static void rewrite_initialize_block_local_data (struct dom_walk_data *,
basic_block, bool);
static void rewrite_initialize_block (struct dom_walk_data *,
! basic_block, tree);
! static void rewrite_walk_stmts (struct dom_walk_data *, basic_block, tree);
static void rewrite_add_phi_arguments (struct dom_walk_data *,
! basic_block, tree);
static void mark_def_sites (struct dom_walk_data *walk_data,
basic_block bb,
! tree parent_block_last_stmt ATTRIBUTE_UNUSED);
static void compute_global_livein (bitmap, bitmap);
static void set_def_block (tree, basic_block);
static void set_livein_block (tree, basic_block);
--- 160,178 ----
static struct ssa_stats_d ssa_stats;
/* Local functions. */
! static void rewrite_finalize_block (struct dom_walk_data *,
! basic_block, basic_block);
static void rewrite_initialize_block_local_data (struct dom_walk_data *,
basic_block, bool);
static void rewrite_initialize_block (struct dom_walk_data *,
! basic_block, basic_block);
! static void rewrite_walk_stmts (struct dom_walk_data *,
! basic_block, basic_block);
static void rewrite_add_phi_arguments (struct dom_walk_data *,
! basic_block, basic_block);
static void mark_def_sites (struct dom_walk_data *walk_data,
basic_block bb,
! basic_block parent ATTRIBUTE_UNUSED);
static void compute_global_livein (bitmap, bitmap);
static void set_def_block (tree, basic_block);
static void set_livein_block (tree, basic_block);
*************** compute_global_livein (bitmap livein, bi
*** 521,527 ****
static void
mark_def_sites (struct dom_walk_data *walk_data,
basic_block bb,
! tree parent_block_last_stmt ATTRIBUTE_UNUSED)
{
struct mark_def_sites_global_data *gd = walk_data->global_data;
sbitmap kills = gd->kills;
--- 523,529 ----
static void
mark_def_sites (struct dom_walk_data *walk_data,
basic_block bb,
! basic_block parent ATTRIBUTE_UNUSED)
{
struct mark_def_sites_global_data *gd = walk_data->global_data;
sbitmap kills = gd->kills;
*************** rewrite_initialize_block_local_data (str
*** 822,828 ****
static void
rewrite_initialize_block (struct dom_walk_data *walk_data,
basic_block bb,
! tree parent_block_last_stmt ATTRIBUTE_UNUSED)
{
tree phi;
struct rewrite_block_data *bd
--- 824,830 ----
static void
rewrite_initialize_block (struct dom_walk_data *walk_data,
basic_block bb,
! basic_block parent ATTRIBUTE_UNUSED)
{
tree phi;
struct rewrite_block_data *bd
*************** rewrite_initialize_block (struct dom_wal
*** 850,856 ****
static void
rewrite_walk_stmts (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
basic_block bb,
! tree parent_block_last_stmt ATTRIBUTE_UNUSED)
{
block_stmt_iterator si;
struct rewrite_block_data *bd
--- 852,858 ----
static void
rewrite_walk_stmts (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
basic_block bb,
! basic_block parent ATTRIBUTE_UNUSED)
{
block_stmt_iterator si;
struct rewrite_block_data *bd
*************** rewrite_walk_stmts (struct dom_walk_data
*** 869,875 ****
static void
rewrite_add_phi_arguments (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
basic_block bb,
! tree parent_block_last_stmt ATTRIBUTE_UNUSED)
{
edge e;
--- 871,877 ----
static void
rewrite_add_phi_arguments (struct dom_walk_data *walk_data ATTRIBUTE_UNUSED,
basic_block bb,
! basic_block parent ATTRIBUTE_UNUSED)
{
edge e;
*************** rewrite_add_phi_arguments (struct dom_wa
*** 899,905 ****
static void
rewrite_finalize_block (struct dom_walk_data *walk_data,
basic_block bb ATTRIBUTE_UNUSED,
! tree parent_block_last_stmt ATTRIBUTE_UNUSED)
{
struct rewrite_block_data *bd
= (struct rewrite_block_data *)VARRAY_TOP_GENERIC_PTR (walk_data->
block_data_stack);
--- 901,907 ----
static void
rewrite_finalize_block (struct dom_walk_data *walk_data,
basic_block bb ATTRIBUTE_UNUSED,
! basic_block parent ATTRIBUTE_UNUSED)
{
struct rewrite_block_data *bd
= (struct rewrite_block_data *)VARRAY_TOP_GENERIC_PTR (walk_data->
block_data_stack);