This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: calculate CDI_DOMINATORS in tree-ssa-sink
Hello,
> >> On 1/4/07, Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> wrote:
> >>> allowing CDI_DOMINATORS | CDI_POST_DOMINATORS just as a special case
> >>> for calculate_dominance_info looks quite inconsistent and missleading
> >>> to me.
> >> Oh, absolutely! That's not what I want at all!
> >>
> >> I want to see the compiler die with a horrible ICE when someone even
> >> attempts to call any dominance.c function with CDI_DOMINATORS |
> >> CDI_POST_DOMINATORS.
> >>
> >> Right now (CDI_DOMINATORS | CDI_POST_DOMINATORS) ==
> >> CDI_POST_DOMINATORS, and so bugs sometimes go unnoticed when someone
> >> tries this. I'd really just want to see a way, *any* way, to prevent
> >> mistakes like this early, i.e. when someone who did this can't compile
> >> his/her code.
> >
> > oh, sorry for missunderstanding; yes, this seems like a good idea to me.
>
> OK, here's the patch I came up with. The subtlety lies in the usage of
> the enumerated type as an array index throughout the code (and
> unfortunately, not just in dominance.c). So, if we _don't_ use 0 and 1
> for the enum values, we end up potentially wasting space in the various
> dominance info arrays. The solution I came up with translates the enum
> value into an array index (while at the same time validating the enum
> value). Personally don't see this as a significant improvement in
> maintainability.
I admit that I did not think about these issues; especially the index
conversions look annoying. I have no major objections against the patch,
though (but of course, I cannot approve it).
> (dom_info_available_p): Remove.
> (dom_info_available): Add.
I would prefer keeping dom_info_available_p (in addition to
"dom_info_available", which might be better named something like
"dom_info_state").
Zdenek
> (set_dom_info_availability): Add.
> * cfghooks.c (split_block): Use dom_info_available() instead of
> dom_computed[].
> (split_edge): Likewise.
> (create_basic_block): Likewise.
> (merge_blocks): Likewise.
> (make_forwarder_block): Likewise.
> * ifcvt.c (find_if_header): Likewise.
> * tree-cfg.c (tree_verify_flow_info): Likewise.
> * tree-ssa-dce.c (remove_dead_stmt): Likewise.
> * tree-ssa.c (verify_ssa): Use dom_info_available() and
> set_dom_info_availability() instead of dom_computed[].
> * tree-cfgcleanup.c (remove_forwarder_block): Call
> dom_info_available instead of dom_info_available_p.
> * tree-complex.c (expand_complex_div_wide): Likewise.
> * tree-mudflap.c (mf_build_check_statement_for): Likewise.
> * dominance.c (calc_dfs_tree_nonrec): Change third param to a
> bool.
> (calc_dfs_tree): Change second param to a bool.
> (init_dom_info): Validate dir before using.
> (dom_convert_dir_to_idx): New.
> (calc_idoms): Use dom_convert_dir_to_idx. Change
> dom_info_available_p to dom_info_available. Change second param
> to a bool.
> (calculate_dominance_info): Use dom_convert_dir_to_idx. Change
> dom_info_available_p to dom_info_available. New variable
> 'reverse' used for calling calc_dfs_tree and calc_idoms.
> (free_dominance_info): Use dom_convert_dir_to_idx. Change
> dom_info_available_p to dom_info_available.
> (get_immediate_dominator): Use dom_convert_dir_to_idx.
> (set_immediate_dominator): Likewise.
> (get_dominated_by): Likewise.
> (redirect_immediate_dominators): Likewise.
> (nearest_common_dominator): Likewise.
> (dominated_by_p): Likewise.
> (bb_dom_dfs_in): Likewise.
> (bb_dom_dfs_out): Likewise.
> (recount_dominator): Likewise.
> (iterate_fix_dominators): Likewise.
> (add_to_dominance_info): Likewise.
> (delete_from_dominance_info): Likewise.
> (first_dom_som): Likewise.
> (next_dom_som): Likewise.
> (dom_info_available_p): Remove.
> (dom_info_available): New.
> (set_dom_info_availability): New.
> (verify_dominators): Use dom_info_available instead of
> dom_info_available_p.
> * tree-ssa-loop-im.c (determine_invariantness): Initialize
> walk_data.dom_direction.
> (move_computations): Likewise.
> * tree-ssa-sink.c (execute_sink_code): Split call to
> calculate_dominance_info into two calls.
>
> Index: gcc/basic-block.h
> ===================================================================
> --- gcc/basic-block.h (revision 120448)
> +++ gcc/basic-block.h (working copy)
> @@ -935,8 +935,8 @@
>
> enum cdi_direction
> {
> - CDI_DOMINATORS,
> - CDI_POST_DOMINATORS
> + CDI_DOMINATORS = 1,
> + CDI_POST_DOMINATORS = 2
> };
>
> enum dom_state
> @@ -946,9 +946,8 @@
> DOM_OK /* Everything is ok. */
> };
>
> -extern enum dom_state dom_computed[2];
> -
> -extern bool dom_info_available_p (enum cdi_direction);
> +extern enum dom_state dom_info_available (enum cdi_direction);
> +extern void set_dom_info_availability (enum cdi_direction, enum dom_state);
> extern void calculate_dominance_info (enum cdi_direction);
> extern void free_dominance_info (enum cdi_direction);
> extern basic_block nearest_common_dominator (enum cdi_direction,
> Index: gcc/cfghooks.c
> ===================================================================
> --- gcc/cfghooks.c (revision 120448)
> +++ gcc/cfghooks.c (working copy)
> @@ -358,7 +358,7 @@
> new_bb->frequency = bb->frequency;
> new_bb->loop_depth = bb->loop_depth;
>
> - if (dom_info_available_p (CDI_DOMINATORS))
> + if (dom_info_available (CDI_DOMINATORS) != DOM_NONE)
> {
> redirect_immediate_dominators (CDI_DOMINATORS, bb, new_bb);
> set_immediate_dominator (CDI_DOMINATORS, new_bb, bb);
> @@ -427,9 +427,9 @@
> while (EDGE_COUNT (bb->succs) != 0)
> remove_edge (EDGE_SUCC (bb, 0));
>
> - if (dom_computed[CDI_DOMINATORS])
> + if (dom_info_available (CDI_DOMINATORS))
> delete_from_dominance_info (CDI_DOMINATORS, bb);
> - if (dom_computed[CDI_POST_DOMINATORS])
> + if (dom_info_available (CDI_POST_DOMINATORS))
> delete_from_dominance_info (CDI_POST_DOMINATORS, bb);
>
> /* Remove the basic block from the array. */
> @@ -465,10 +465,10 @@
> single_succ_edge (ret)->flags |= EDGE_IRREDUCIBLE_LOOP;
> }
>
> - if (dom_computed[CDI_DOMINATORS])
> + if (dom_info_available (CDI_DOMINATORS))
> set_immediate_dominator (CDI_DOMINATORS, ret, single_pred (ret));
>
> - if (dom_computed[CDI_DOMINATORS] >= DOM_NO_FAST_QUERY)
> + if (dom_info_available (CDI_DOMINATORS) >= DOM_NO_FAST_QUERY)
> {
> /* There are two cases:
>
> @@ -524,9 +524,9 @@
>
> ret = cfg_hooks->create_basic_block (head, end, after);
>
> - if (dom_computed[CDI_DOMINATORS])
> + if (dom_info_available (CDI_DOMINATORS))
> add_to_dominance_info (CDI_DOMINATORS, ret);
> - if (dom_computed[CDI_POST_DOMINATORS])
> + if (dom_info_available (CDI_POST_DOMINATORS))
> add_to_dominance_info (CDI_POST_DOMINATORS, ret);
>
> return ret;
> @@ -606,12 +606,12 @@
> /* B hasn't quite yet ceased to exist. Attempt to prevent mishap. */
> b->preds = b->succs = NULL;
>
> - if (dom_computed[CDI_DOMINATORS])
> + if (dom_info_available (CDI_DOMINATORS))
> redirect_immediate_dominators (CDI_DOMINATORS, b, a);
>
> - if (dom_computed[CDI_DOMINATORS])
> + if (dom_info_available (CDI_DOMINATORS))
> delete_from_dominance_info (CDI_DOMINATORS, b);
> - if (dom_computed[CDI_POST_DOMINATORS])
> + if (dom_info_available (CDI_POST_DOMINATORS))
> delete_from_dominance_info (CDI_POST_DOMINATORS, b);
>
> expunge_block (b);
> @@ -662,7 +662,7 @@
> new_bb_cbk (jump);
> }
>
> - if (dom_info_available_p (CDI_DOMINATORS))
> + if (dom_info_available (CDI_DOMINATORS) != DOM_NONE)
> {
> basic_block doms_to_fix[2];
>
> Index: gcc/dominance.c
> ===================================================================
> --- gcc/dominance.c (revision 120448)
> +++ gcc/dominance.c (working copy)
> @@ -46,7 +46,7 @@
> #include "timevar.h"
>
> /* Whether the dominators and the postdominators are available. */
> -enum dom_state dom_computed[2];
> +static enum dom_state dom_computed[2];
>
> /* We name our nodes with integers, beginning with 1. Zero is reserved for
> 'undefined' or 'end of list'. The name of each node is given by the dfs
> @@ -114,13 +114,12 @@
>
> static void init_dom_info (struct dom_info *, enum cdi_direction);
> static void free_dom_info (struct dom_info *);
> -static void calc_dfs_tree_nonrec (struct dom_info *, basic_block,
> - enum cdi_direction);
> -static void calc_dfs_tree (struct dom_info *, enum cdi_direction);
> +static void calc_dfs_tree_nonrec (struct dom_info *, basic_block, bool);
> +static void calc_dfs_tree (struct dom_info *, bool);
> static void compress (struct dom_info *, TBB);
> static TBB eval (struct dom_info *, TBB);
> static void link_roots (struct dom_info *, TBB, TBB);
> -static void calc_idoms (struct dom_info *, enum cdi_direction);
> +static void calc_idoms (struct dom_info *, bool);
> void debug_dominance_info (enum cdi_direction);
>
> /* Keeps track of the*/
> @@ -168,11 +167,34 @@
> di->dfsnum = 1;
> di->nodes = 0;
>
> - di->fake_exit_edge = dir ? BITMAP_ALLOC (NULL) : NULL;
> + switch (dir)
> + {
> + case CDI_DOMINATORS:
> + di->fake_exit_edge = NULL;
> + break;
> + case CDI_POST_DOMINATORS:
> + di->fake_exit_edge = BITMAP_ALLOC (NULL);
> + break;
> + default:
> + gcc_unreachable ();
> + break;
> + }
> }
>
> #undef init_ar
>
> +/* Map dominance calculation type to array index used for various
> + dominance information arrays. This version is simple -- it will need
> + to be modified, obviously, if additional values are added to
> + cdi_direction. */
> +
> +static unsigned int
> +dom_convert_dir_to_idx (enum cdi_direction dir)
> +{
> + gcc_assert (dir == CDI_DOMINATORS || dir == CDI_POST_DOMINATORS);
> + return dir - 1;
> +}
> +
> /* Free all allocated memory in DI, but not DI itself. */
>
> static void
> @@ -199,8 +221,7 @@
> assigned their dfs number and are linked together to form a tree. */
>
> static void
> -calc_dfs_tree_nonrec (struct dom_info *di, basic_block bb,
> - enum cdi_direction reverse)
> +calc_dfs_tree_nonrec (struct dom_info *di, basic_block bb, bool reverse)
> {
> /* We call this _only_ if bb is not already visited. */
> edge e;
> @@ -311,7 +332,7 @@
> because there may be nodes from which the EXIT_BLOCK is unreachable. */
>
> static void
> -calc_dfs_tree (struct dom_info *di, enum cdi_direction reverse)
> +calc_dfs_tree (struct dom_info *di, bool reverse)
> {
> /* The first block is the ENTRY_BLOCK (or EXIT_BLOCK if REVERSE). */
> basic_block begin = reverse ? EXIT_BLOCK_PTR : ENTRY_BLOCK_PTR;
> @@ -471,7 +492,7 @@
> On return the immediate dominator to node V is in di->dom[V]. */
>
> static void
> -calc_idoms (struct dom_info *di, enum cdi_direction reverse)
> +calc_idoms (struct dom_info *di, bool reverse)
> {
> TBB v, w, k, par;
> basic_block en_block;
> @@ -590,19 +611,20 @@
> {
> int num = 0;
> basic_block bb;
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
>
> - gcc_assert (dom_info_available_p (dir));
> + gcc_assert (dom_info_available (dir) != DOM_NONE);
>
> - if (dom_computed[dir] == DOM_OK)
> + if (dom_computed[dir_index] == DOM_OK)
> return;
>
> FOR_ALL_BB (bb)
> {
> - if (!bb->dom[dir]->father)
> - assign_dfs_numbers (bb->dom[dir], &num);
> + if (!bb->dom[dir_index]->father)
> + assign_dfs_numbers (bb->dom[dir_index], &num);
> }
>
> - dom_computed[dir] = DOM_OK;
> + dom_computed[dir_index] = DOM_OK;
> }
>
> /* The main entry point into this module. DIR is set depending on whether
> @@ -613,35 +635,37 @@
> {
> struct dom_info di;
> basic_block b;
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> + bool reverse = (dir == CDI_POST_DOMINATORS) ? true : false;
>
> - if (dom_computed[dir] == DOM_OK)
> + if (dom_computed[dir_index] == DOM_OK)
> return;
>
> timevar_push (TV_DOMINANCE);
> - if (!dom_info_available_p (dir))
> + if (dom_info_available (dir) == DOM_NONE)
> {
> - gcc_assert (!n_bbs_in_dom_tree[dir]);
> + gcc_assert (!n_bbs_in_dom_tree[dir_index]);
>
> FOR_ALL_BB (b)
> {
> - b->dom[dir] = et_new_tree (b);
> + b->dom[dir_index] = et_new_tree (b);
> }
> - n_bbs_in_dom_tree[dir] = n_basic_blocks;
> + n_bbs_in_dom_tree[dir_index] = n_basic_blocks;
>
> init_dom_info (&di, dir);
> - calc_dfs_tree (&di, dir);
> - calc_idoms (&di, dir);
> + calc_dfs_tree (&di, reverse);
> + calc_idoms (&di, reverse);
>
> FOR_EACH_BB (b)
> {
> TBB d = di.dom[di.dfs_order[b->index]];
>
> if (di.dfs_to_bb[d])
> - et_set_father (b->dom[dir], di.dfs_to_bb[d]->dom[dir]);
> + et_set_father (b->dom[dir_index], di.dfs_to_bb[d]->dom[dir_index]);
> }
>
> free_dom_info (&di);
> - dom_computed[dir] = DOM_NO_FAST_QUERY;
> + dom_computed[dir_index] = DOM_NO_FAST_QUERY;
> }
>
> compute_dom_fast_query (dir);
> @@ -654,29 +678,31 @@
> free_dominance_info (enum cdi_direction dir)
> {
> basic_block bb;
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
>
> - if (!dom_info_available_p (dir))
> + if (dom_info_available (dir) == DOM_NONE)
> return;
>
> FOR_ALL_BB (bb)
> {
> - et_free_tree_force (bb->dom[dir]);
> - bb->dom[dir] = NULL;
> + et_free_tree_force (bb->dom[dir_index]);
> + bb->dom[dir_index] = NULL;
> }
> et_free_pools ();
>
> - n_bbs_in_dom_tree[dir] = 0;
> + n_bbs_in_dom_tree[dir_index] = 0;
>
> - dom_computed[dir] = DOM_NONE;
> + dom_computed[dir_index] = DOM_NONE;
> }
>
> /* Return the immediate dominator of basic block BB. */
> basic_block
> get_immediate_dominator (enum cdi_direction dir, basic_block bb)
> {
> - struct et_node *node = bb->dom[dir];
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> + struct et_node *node = bb->dom[dir_index];
>
> - gcc_assert (dom_computed[dir]);
> + gcc_assert (dom_computed[dir_index]);
>
> if (!node->father)
> return NULL;
> @@ -690,10 +716,11 @@
> set_immediate_dominator (enum cdi_direction dir, basic_block bb,
> basic_block dominated_by)
> {
> - struct et_node *node = bb->dom[dir];
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> + struct et_node *node = bb->dom[dir_index];
> +
> + gcc_assert (dom_computed[dir_index]);
>
> - gcc_assert (dom_computed[dir]);
> -
> if (node->father)
> {
> if (node->father->data == dominated_by)
> @@ -702,10 +729,10 @@
> }
>
> if (dominated_by)
> - et_set_father (node, dominated_by->dom[dir]);
> + et_set_father (node, dominated_by->dom[dir_index]);
>
> - if (dom_computed[dir] == DOM_OK)
> - dom_computed[dir] = DOM_NO_FAST_QUERY;
> + if (dom_computed[dir_index] == DOM_OK)
> + dom_computed[dir_index] = DOM_NO_FAST_QUERY;
> }
>
> /* Store all basic blocks immediately dominated by BB into BBS and return
> @@ -713,11 +740,12 @@
> int
> get_dominated_by (enum cdi_direction dir, basic_block bb, basic_block **bbs)
> {
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> int n;
> - struct et_node *node = bb->dom[dir], *son = node->son, *ason;
> + struct et_node *node = bb->dom[dir_index], *son = node->son, *ason;
> +
> + gcc_assert (dom_computed[dir_index]);
>
> - gcc_assert (dom_computed[dir]);
> -
> if (!son)
> {
> *bbs = NULL;
> @@ -766,9 +794,13 @@
> redirect_immediate_dominators (enum cdi_direction dir, basic_block bb,
> basic_block to)
> {
> - struct et_node *bb_node = bb->dom[dir], *to_node = to->dom[dir], *son;
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> + struct et_node *bb_node, *to_node, *son;
> +
> + bb_node = bb->dom[dir_index];
> + to_node = to->dom[dir_index];
>
> - gcc_assert (dom_computed[dir]);
> + gcc_assert (dom_computed[dir_index]);
>
> if (!bb_node->son)
> return;
> @@ -781,22 +813,24 @@
> et_set_father (son, to_node);
> }
>
> - if (dom_computed[dir] == DOM_OK)
> - dom_computed[dir] = DOM_NO_FAST_QUERY;
> + if (dom_computed[dir_index] == DOM_OK)
> + dom_computed[dir_index] = DOM_NO_FAST_QUERY;
> }
>
> /* Find first basic block in the tree dominating both BB1 and BB2. */
> basic_block
> nearest_common_dominator (enum cdi_direction dir, basic_block bb1, basic_block bb2)
> {
> - gcc_assert (dom_computed[dir]);
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
>
> + gcc_assert (dom_computed[dir_index]);
> +
> if (!bb1)
> return bb2;
> if (!bb2)
> return bb1;
>
> - return et_nca (bb1->dom[dir], bb2->dom[dir])->data;
> + return et_nca (bb1->dom[dir_index], bb2->dom[dir_index])->data;
> }
>
>
> @@ -898,11 +932,12 @@
> bool
> dominated_by_p (enum cdi_direction dir, basic_block bb1, basic_block bb2)
> {
> - struct et_node *n1 = bb1->dom[dir], *n2 = bb2->dom[dir];
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> + struct et_node *n1 = bb1->dom[dir_index], *n2 = bb2->dom[dir_index];
> +
> + gcc_assert (dom_computed[dir_index]);
>
> - gcc_assert (dom_computed[dir]);
> -
> - if (dom_computed[dir] == DOM_OK)
> + if (dom_computed[dir_index] == DOM_OK)
> return (n1->dfs_num_in >= n2->dfs_num_in
> && n1->dfs_num_out <= n2->dfs_num_out);
>
> @@ -914,9 +949,10 @@
> unsigned
> bb_dom_dfs_in (enum cdi_direction dir, basic_block bb)
> {
> - struct et_node *n = bb->dom[dir];
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> + struct et_node *n = bb->dom[dir_index];
>
> - gcc_assert (dom_computed[dir] == DOM_OK);
> + gcc_assert (dom_computed[dir_index] == DOM_OK);
> return n->dfs_num_in;
> }
>
> @@ -925,9 +961,10 @@
> unsigned
> bb_dom_dfs_out (enum cdi_direction dir, basic_block bb)
> {
> - struct et_node *n = bb->dom[dir];
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> + struct et_node *n = bb->dom[dir_index];
>
> - gcc_assert (dom_computed[dir] == DOM_OK);
> + gcc_assert (dom_computed[dir_index] == DOM_OK);
> return n->dfs_num_out;
> }
>
> @@ -938,7 +975,7 @@
> int err = 0;
> basic_block bb;
>
> - gcc_assert (dom_info_available_p (dir));
> + gcc_assert (dom_info_available (dir) != DOM_NONE);
>
> FOR_EACH_BB (bb)
> {
> @@ -981,11 +1018,12 @@
> basic_block
> recount_dominator (enum cdi_direction dir, basic_block bb)
> {
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> basic_block dom_bb = NULL;
> edge e;
> edge_iterator ei;
>
> - gcc_assert (dom_computed[dir]);
> + gcc_assert (dom_computed[dir_index]);
>
> if (dir == CDI_DOMINATORS)
> {
> @@ -1017,10 +1055,11 @@
> void
> iterate_fix_dominators (enum cdi_direction dir, basic_block *bbs, int n)
> {
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> int i, changed = 1;
> basic_block old_dom, new_dom;
>
> - gcc_assert (dom_computed[dir]);
> + gcc_assert (dom_computed[dir_index]);
>
> for (i = 0; i < n; i++)
> set_immediate_dominator (dir, bbs[i], NULL);
> @@ -1047,28 +1086,32 @@
> void
> add_to_dominance_info (enum cdi_direction dir, basic_block bb)
> {
> - gcc_assert (dom_computed[dir]);
> - gcc_assert (!bb->dom[dir]);
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
>
> - n_bbs_in_dom_tree[dir]++;
> + gcc_assert (dom_computed[dir_index]);
> + gcc_assert (!bb->dom[dir_index]);
> +
> + n_bbs_in_dom_tree[dir_index]++;
>
> - bb->dom[dir] = et_new_tree (bb);
> + bb->dom[dir_index] = et_new_tree (bb);
>
> - if (dom_computed[dir] == DOM_OK)
> - dom_computed[dir] = DOM_NO_FAST_QUERY;
> + if (dom_computed[dir_index] == DOM_OK)
> + dom_computed[dir_index] = DOM_NO_FAST_QUERY;
> }
>
> void
> delete_from_dominance_info (enum cdi_direction dir, basic_block bb)
> {
> - gcc_assert (dom_computed[dir]);
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
>
> - et_free_tree (bb->dom[dir]);
> - bb->dom[dir] = NULL;
> - n_bbs_in_dom_tree[dir]--;
> + gcc_assert (dom_computed[dir_index]);
>
> - if (dom_computed[dir] == DOM_OK)
> - dom_computed[dir] = DOM_NO_FAST_QUERY;
> + et_free_tree (bb->dom[dir_index]);
> + bb->dom[dir_index] = NULL;
> + n_bbs_in_dom_tree[dir_index]--;
> +
> + if (dom_computed[dir_index] == DOM_OK)
> + dom_computed[dir_index] = DOM_NO_FAST_QUERY;
> }
>
> /* Returns the first son of BB in the dominator or postdominator tree
> @@ -1077,7 +1120,8 @@
> basic_block
> first_dom_son (enum cdi_direction dir, basic_block bb)
> {
> - struct et_node *son = bb->dom[dir]->son;
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> + struct et_node *son = bb->dom[dir_index]->son;
>
> return son ? son->data : NULL;
> }
> @@ -1088,20 +1132,33 @@
> basic_block
> next_dom_son (enum cdi_direction dir, basic_block bb)
> {
> - struct et_node *next = bb->dom[dir]->right;
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> + struct et_node *next = bb->dom[dir_index]->right;
>
> return next->father->son == next ? NULL : next->data;
> }
>
> /* Returns true if dominance information for direction DIR is available. */
>
> -bool
> -dom_info_available_p (enum cdi_direction dir)
> +enum dom_state
> +dom_info_available (enum cdi_direction dir)
> {
> - return dom_computed[dir] != DOM_NONE;
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> +
> + return dom_computed[dir_index];
> }
>
> +/* Set the dominance availability for dominance info DIR to NEW_STATE. */
> +
> void
> +set_dom_info_availability (enum cdi_direction dir, enum dom_state new_state)
> +{
> + unsigned int dir_index = dom_convert_dir_to_idx (dir);
> +
> + dom_computed[dir_index] = new_state;
> +}
> +
> +void
> debug_dominance_info (enum cdi_direction dir)
> {
> basic_block bb, bb2;
> Index: gcc/ifcvt.c
> ===================================================================
> --- gcc/ifcvt.c (revision 120448)
> +++ gcc/ifcvt.c (working copy)
> @@ -2847,7 +2847,7 @@
> && find_cond_trap (test_bb, then_edge, else_edge))
> goto success;
>
> - if (dom_computed[CDI_POST_DOMINATORS] >= DOM_NO_FAST_QUERY
> + if (dom_info_available (CDI_POST_DOMINATORS) >= DOM_NO_FAST_QUERY
> && (! HAVE_conditional_execution || reload_completed))
> {
> if (find_if_case_1 (test_bb, then_edge, else_edge))
> Index: gcc/tree-cfg.c
> ===================================================================
> --- gcc/tree-cfg.c (revision 120448)
> +++ gcc/tree-cfg.c (working copy)
> @@ -3974,7 +3974,7 @@
> }
> }
>
> - if (dom_computed[CDI_DOMINATORS] >= DOM_NO_FAST_QUERY)
> + if (dom_info_available (CDI_DOMINATORS) >= DOM_NO_FAST_QUERY)
> verify_dominators (CDI_DOMINATORS);
>
> return err;
> Index: gcc/tree-cfgcleanup.c
> ===================================================================
> --- gcc/tree-cfgcleanup.c (revision 120448)
> +++ gcc/tree-cfgcleanup.c (working copy)
> @@ -457,7 +457,7 @@
> }
>
> /* Update the dominators. */
> - if (dom_info_available_p (CDI_DOMINATORS))
> + if (dom_info_available (CDI_DOMINATORS) != DOM_NONE)
> {
> basic_block dom, dombb, domdest;
>
> Index: gcc/tree-complex.c
> ===================================================================
> --- gcc/tree-complex.c (revision 120448)
> +++ gcc/tree-complex.c (working copy)
> @@ -1080,7 +1080,7 @@
>
> /* Update dominance info. Note that bb_join's data was
> updated by split_block. */
> - if (dom_info_available_p (CDI_DOMINATORS))
> + if (dom_info_available (CDI_DOMINATORS) != DOM_NONE)
> {
> set_immediate_dominator (CDI_DOMINATORS, bb_true, bb_cond);
> set_immediate_dominator (CDI_DOMINATORS, bb_false, bb_cond);
> Index: gcc/tree-mudflap.c
> ===================================================================
> --- gcc/tree-mudflap.c (revision 120448)
> +++ gcc/tree-mudflap.c (working copy)
> @@ -541,7 +541,7 @@
>
> /* Update dominance info. Note that bb_join's data was
> updated by split_block. */
> - if (dom_info_available_p (CDI_DOMINATORS))
> + if (dom_info_available (CDI_DOMINATORS) != DOM_NONE)
> {
> set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb);
> set_immediate_dominator (CDI_DOMINATORS, join_bb, cond_bb);
> Index: gcc/tree-ssa.c
> ===================================================================
> --- gcc/tree-ssa.c (revision 120448)
> +++ gcc/tree-ssa.c (working copy)
> @@ -576,7 +576,7 @@
> basic_block *definition_block = XCNEWVEC (basic_block, num_ssa_names);
> ssa_op_iter iter;
> tree op;
> - enum dom_state orig_dom_state = dom_computed[CDI_DOMINATORS];
> + enum dom_state orig_dom_state = dom_info_available (CDI_DOMINATORS);
> bitmap names_defined_in_bb = BITMAP_ALLOC (NULL);
>
> gcc_assert (!need_ssa_update_p ());
> @@ -717,7 +717,7 @@
> if (orig_dom_state == DOM_NONE)
> free_dominance_info (CDI_DOMINATORS);
> else
> - dom_computed[CDI_DOMINATORS] = orig_dom_state;
> + set_dom_info_availability (CDI_DOMINATORS, orig_dom_state);
>
> BITMAP_FREE (names_defined_in_bb);
> timevar_pop (TV_TREE_SSA_VERIFY);
> Index: gcc/tree-ssa-dce.c
> ===================================================================
> --- gcc/tree-ssa-dce.c (revision 120448)
> +++ gcc/tree-ssa-dce.c (working copy)
> @@ -588,7 +588,7 @@
> basic_block post_dom_bb;
>
> /* The post dominance info has to be up-to-date. */
> - gcc_assert (dom_computed[CDI_POST_DOMINATORS] == DOM_OK);
> + gcc_assert (dom_info_available (CDI_POST_DOMINATORS) == DOM_OK);
> /* Get the immediate post dominator of bb. */
> post_dom_bb = get_immediate_dominator (CDI_POST_DOMINATORS, bb);
>
> Index: gcc/tree-ssa-loop-im.c
> ===================================================================
> --- gcc/tree-ssa-loop-im.c (revision 120448)
> +++ gcc/tree-ssa-loop-im.c (working copy)
> @@ -683,6 +683,7 @@
> struct dom_walk_data walk_data;
>
> memset (&walk_data, 0, sizeof (struct dom_walk_data));
> + walk_data.dom_direction = CDI_DOMINATORS;
> walk_data.before_dom_children_before_stmts = determine_invariantness_stmt;
>
> init_walk_dominator_tree (&walk_data);
> @@ -753,6 +754,7 @@
> struct dom_walk_data walk_data;
>
> memset (&walk_data, 0, sizeof (struct dom_walk_data));
> + walk_data.dom_direction = CDI_DOMINATORS;
> walk_data.before_dom_children_before_stmts = move_computations_stmt;
>
> init_walk_dominator_tree (&walk_data);
> Index: gcc/tree-ssa-sink.c
> ===================================================================
> --- gcc/tree-ssa-sink.c (revision 120448)
> +++ gcc/tree-ssa-sink.c (working copy)
> @@ -527,7 +527,8 @@
>
> connect_infinite_loops_to_exit ();
> memset (&sink_stats, 0, sizeof (sink_stats));
> - calculate_dominance_info (CDI_DOMINATORS | CDI_POST_DOMINATORS);
> + calculate_dominance_info (CDI_DOMINATORS);
> + calculate_dominance_info (CDI_POST_DOMINATORS);
> sink_code_in_bb (EXIT_BLOCK_PTR);
> if (dump_file && (dump_flags & TDF_STATS))
> fprintf (dump_file, "Sunk statements:%d\n", sink_stats.sunk);