Commit f8032688 by Michael Matz Committed by Richard Henderson

Michael Matz <matzmich@cs.tu-berlin.de>

        * dominance.c: New file.
        * Makefile.in (OBJS): Add dominance.o.

        * flow.c (compute_flow_dominators): Remove.
        (compute_immediate_dominators): Remove.
        (compute_immediate_postdominators): Remove.
        * basic-block.h: Remove their prototypes.
        (calculate_dominance_info): Add prototype.

        * dce.c (eliminate_dead_code): Change calls to above functions.
        Don't compute dominators but only immediate dominators.
        * flow.c (flow_loops_find): Change callers.
        * gcse.c (compute_code_hoist_data): Likewise.
        * haifa-sched.c (schedule_insns): Likewise.
        * ifcvt.c (if_convert): Likewise.
        * ssa.c (convert_to_ssa): Likewise, and only compute immediate
        dominators.

From-SVN: r37449
parent 6f122550
2000-11-14 Michael Matz <matzmich@cs.tu-berlin.de>
* dominance.c: New file.
* Makefile.in (OBJS): Add dominance.o.
* flow.c (compute_flow_dominators): Remove.
(compute_immediate_dominators): Remove.
(compute_immediate_postdominators): Remove.
* basic-block.h: Remove their prototypes.
(calculate_dominance_info): Add prototype.
* dce.c (eliminate_dead_code): Change calls to above functions.
Don't compute dominators but only immediate dominators.
* flow.c (flow_loops_find): Change callers.
* gcse.c (compute_code_hoist_data): Likewise.
* haifa-sched.c (schedule_insns): Likewise.
* ifcvt.c (if_convert): Likewise.
* ssa.c (convert_to_ssa): Likewise, and only compute immediate
dominators.
2000-11-14 Richard Henderson <rth@redhat.com>
* stmt.c (warn_if_unused_value): Don't warn if the expression
......
......@@ -735,7 +735,7 @@ OBJS = diagnostic.o version.o tree.o print-tree.o stor-layout.o fold-const.o \
profile.o insn-attrtab.o $(out_object_file) $(EXTRA_OBJS) convert.o \
mbchar.o splay-tree.o graph.o sbitmap.o resource.o hash.o predict.o \
lists.o ggc-common.o $(GGC) simplify-rtx.o ssa.o bb-reorder.o \
sibcall.o conflict.o timevar.o ifcvt.o dependence.o dce.o
sibcall.o conflict.o timevar.o ifcvt.o dominance.o dependence.o dce.o
BACKEND = toplev.o libbackend.a
......@@ -1403,6 +1403,8 @@ unroll.o : unroll.c $(CONFIG_H) system.h $(RTL_H) insn-config.h function.h \
flow.o : flow.c $(CONFIG_H) system.h $(RTL_H) $(TREE_H) flags.h insn-config.h \
$(BASIC_BLOCK_H) $(REGS_H) hard-reg-set.h output.h toplev.h $(RECOG_H) \
insn-flags.h function.h except.h $(EXPR_H) ssa.h $(GGC_H)
dominance.o : dominance.c $(CONFIG_H) system.h $(RTL_H) hard-reg-set.h \
$(BASIC_BLOCK_H)
combine.o : combine.c $(CONFIG_H) system.h $(RTL_H) flags.h function.h \
insn-config.h insn-flags.h insn-codes.h $(INSN_ATTR_H) $(REGS_H) $(EXPR_H) \
$(BASIC_BLOCK_H) $(RECOG_H) real.h hard-reg-set.h toplev.h
......
......@@ -458,10 +458,6 @@ void verify_edge_list PARAMS ((FILE *, struct edge_list *));
int find_edge_index PARAMS ((struct edge_list *,
basic_block, basic_block));
extern void compute_flow_dominators PARAMS ((sbitmap *, sbitmap *));
extern void compute_immediate_dominators PARAMS ((int *, sbitmap *));
extern void compute_immediate_postdominators PARAMS ((int *, sbitmap *));
enum update_life_extent
{
......@@ -565,4 +561,15 @@ extern conflict_graph conflict_graph_compute
PARAMS ((regset,
partition));
/* In dominance.c */
enum cdi_direction
{
CDI_DOMINATORS,
CDI_POST_DOMINATORS
};
extern void calculate_dominance_info PARAMS ((int *, sbitmap *,
enum cdi_direction));
#endif /* _BASIC_BLOCK_H */
......@@ -485,7 +485,6 @@ eliminate_dead_code ()
/* Map element (b,e) is nonzero if the block is control dependent on
edge. "cdbte" abbreviates control dependent block to edge. */
control_dependent_block_to_edge_map cdbte;
sbitmap *postdominators;
/* Element I is the immediate postdominator of block I. */
int *pdom;
struct edge_list *el;
......@@ -504,17 +503,14 @@ eliminate_dead_code ()
compute_bb_for_insn (max_insn_uid);
/* Compute control dependence. */
postdominators = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
compute_flow_dominators (NULL, postdominators);
pdom = (int *) xmalloc (n_basic_blocks * sizeof (int));
for (i = 0; i < n_basic_blocks; ++i)
pdom[i] = INVALID_BLOCK;
compute_immediate_postdominators (pdom, postdominators);
calculate_dominance_info (pdom, NULL, CDI_POST_DOMINATORS);
/* Assume there is a path from each node to the exit block. */
for (i = 0; i < n_basic_blocks; ++i)
if (pdom[i] == INVALID_BLOCK)
pdom[i] = EXIT_BLOCK;
sbitmap_vector_free (postdominators);
el = create_edge_list();
find_all_control_dependences (el, pdom, cdbte);
......
This diff is collapsed. Click to expand it.
......@@ -6247,250 +6247,6 @@ print_rtl_with_bb (outf, rtx_first)
}
}
/* Compute dominator relationships using new flow graph structures. */
void
compute_flow_dominators (dominators, post_dominators)
sbitmap *dominators;
sbitmap *post_dominators;
{
int bb;
sbitmap *temp_bitmap;
edge e;
basic_block *worklist, *workend, *qin, *qout;
int qlen;
/* Allocate a worklist array/queue. Entries are only added to the
list if they were not already on the list. So the size is
bounded by the number of basic blocks. */
worklist = (basic_block *) xmalloc (sizeof (basic_block) * n_basic_blocks);
workend = &worklist[n_basic_blocks];
temp_bitmap = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
sbitmap_vector_zero (temp_bitmap, n_basic_blocks);
if (dominators)
{
/* The optimistic setting of dominators requires us to put every
block on the work list initially. */
qin = qout = worklist;
for (bb = 0; bb < n_basic_blocks; bb++)
{
*qin++ = BASIC_BLOCK (bb);
BASIC_BLOCK (bb)->aux = BASIC_BLOCK (bb);
}
qlen = n_basic_blocks;
qin = worklist;
/* We want a maximal solution, so initially assume everything dominates
everything else. */
sbitmap_vector_ones (dominators, n_basic_blocks);
/* Mark successors of the entry block so we can identify them below. */
for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
e->dest->aux = ENTRY_BLOCK_PTR;
/* Iterate until the worklist is empty. */
while (qlen)
{
/* Take the first entry off the worklist. */
basic_block b = *qout++;
if (qout >= workend)
qout = worklist;
qlen--;
bb = b->index;
/* Compute the intersection of the dominators of all the
predecessor blocks.
If one of the predecessor blocks is the ENTRY block, then the
intersection of the dominators of the predecessor blocks is
defined as the null set. We can identify such blocks by the
special value in the AUX field in the block structure. */
if (b->aux == ENTRY_BLOCK_PTR)
{
/* Do not clear the aux field for blocks which are
successors of the ENTRY block. That way we never add
them to the worklist again.
The intersect of dominators of the preds of this block is
defined as the null set. */
sbitmap_zero (temp_bitmap[bb]);
}
else
{
/* Clear the aux field of this block so it can be added to
the worklist again if necessary. */
b->aux = NULL;
sbitmap_intersection_of_preds (temp_bitmap[bb], dominators, bb);
}
/* Make sure each block always dominates itself. */
SET_BIT (temp_bitmap[bb], bb);
/* If the out state of this block changed, then we need to
add the successors of this block to the worklist if they
are not already on the worklist. */
if (sbitmap_a_and_b (dominators[bb], dominators[bb], temp_bitmap[bb]))
{
for (e = b->succ; e; e = e->succ_next)
{
if (!e->dest->aux && e->dest != EXIT_BLOCK_PTR)
{
*qin++ = e->dest;
if (qin >= workend)
qin = worklist;
qlen++;
e->dest->aux = e;
}
}
}
}
}
if (post_dominators)
{
/* The optimistic setting of dominators requires us to put every
block on the work list initially. */
qin = qout = worklist;
for (bb = 0; bb < n_basic_blocks; bb++)
{
*qin++ = BASIC_BLOCK (bb);
BASIC_BLOCK (bb)->aux = BASIC_BLOCK (bb);
}
qlen = n_basic_blocks;
qin = worklist;
/* We want a maximal solution, so initially assume everything post
dominates everything else. */
sbitmap_vector_ones (post_dominators, n_basic_blocks);
/* Mark predecessors of the exit block so we can identify them below. */
for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
e->src->aux = EXIT_BLOCK_PTR;
/* Iterate until the worklist is empty. */
while (qlen)
{
/* Take the first entry off the worklist. */
basic_block b = *qout++;
if (qout >= workend)
qout = worklist;
qlen--;
bb = b->index;
/* Compute the intersection of the post dominators of all the
successor blocks.
If one of the successor blocks is the EXIT block, then the
intersection of the dominators of the successor blocks is
defined as the null set. We can identify such blocks by the
special value in the AUX field in the block structure. */
if (b->aux == EXIT_BLOCK_PTR)
{
/* Do not clear the aux field for blocks which are
predecessors of the EXIT block. That way we we never
add them to the worklist again.
The intersect of dominators of the succs of this block is
defined as the null set. */
sbitmap_zero (temp_bitmap[bb]);
}
else
{
/* Clear the aux field of this block so it can be added to
the worklist again if necessary. */
b->aux = NULL;
sbitmap_intersection_of_succs (temp_bitmap[bb],
post_dominators, bb);
}
/* Make sure each block always post dominates itself. */
SET_BIT (temp_bitmap[bb], bb);
/* If the out state of this block changed, then we need to
add the successors of this block to the worklist if they
are not already on the worklist. */
if (sbitmap_a_and_b (post_dominators[bb],
post_dominators[bb],
temp_bitmap[bb]))
{
for (e = b->pred; e; e = e->pred_next)
{
if (!e->src->aux && e->src != ENTRY_BLOCK_PTR)
{
*qin++ = e->src;
if (qin >= workend)
qin = worklist;
qlen++;
e->src->aux = e;
}
}
}
}
}
free (worklist);
free (temp_bitmap);
}
/* Given DOMINATORS, compute the immediate dominators into IDOM. If a
block dominates only itself, its entry remains as INVALID_BLOCK. */
void
compute_immediate_dominators (idom, dominators)
int *idom;
sbitmap *dominators;
{
sbitmap *tmp;
int b;
tmp = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
/* Begin with tmp(n) = dom(n) - { n }. */
for (b = n_basic_blocks; --b >= 0;)
{
sbitmap_copy (tmp[b], dominators[b]);
RESET_BIT (tmp[b], b);
}
/* Subtract out all of our dominator's dominators. */
for (b = n_basic_blocks; --b >= 0;)
{
sbitmap tmp_b = tmp[b];
int s;
for (s = n_basic_blocks; --s >= 0;)
if (TEST_BIT (tmp_b, s))
sbitmap_difference (tmp_b, tmp_b, tmp[s]);
}
/* Find the one bit set in the bitmap and put it in the output array. */
for (b = n_basic_blocks; --b >= 0;)
{
int t;
EXECUTE_IF_SET_IN_SBITMAP (tmp[b], 0, t, { idom[b] = t; });
}
sbitmap_vector_free (tmp);
}
/* Given POSTDOMINATORS, compute the immediate postdominators into
IDOM. If a block is only dominated by itself, its entry remains as
INVALID_BLOCK. */
void
compute_immediate_postdominators (idom, postdominators)
int *idom;
sbitmap *postdominators;
{
compute_immediate_dominators (idom, postdominators);
}
/* Recompute register set/reference counts immediately prior to register
allocation.
......@@ -8151,7 +7907,7 @@ flow_loops_find (loops, flags)
/* Compute the dominators. */
dom = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
compute_flow_dominators (dom, NULL);
calculate_dominance_info (NULL, dom, CDI_DOMINATORS);
/* Count the number of loop edges (back edges). This should be the
same as the number of natural loops. */
......
......@@ -5292,7 +5292,7 @@ compute_code_hoist_data ()
compute_local_properties (transp, comp, antloc, 0);
compute_transpout ();
compute_code_hoist_vbeinout ();
compute_flow_dominators (dominators, NULL);
calculate_dominance_info (NULL, dominators, CDI_DOMINATORS);
if (gcse_file)
fprintf (gcse_file, "\n");
}
......
......@@ -7001,10 +7001,8 @@ schedule_insns (dump_file)
so may even be beneficial. */
edge_list = create_edge_list ();
/* Compute the dominators and post dominators. We don't
currently use post dominators, but we should for
speculative motion analysis. */
compute_flow_dominators (dom, NULL);
/* Compute the dominators and post dominators. */
calculate_dominance_info (NULL, dom, CDI_DOMINATORS);
/* build_control_flow will return nonzero if it detects unreachable
blocks or any other irregularity with the cfg which prevents
......
......@@ -2104,7 +2104,7 @@ if_convert (life_data_ok)
if (HAVE_conditional_execution || life_data_ok)
{
post_dominators = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
compute_flow_dominators (NULL, post_dominators);
calculate_dominance_info (NULL, post_dominators, CDI_POST_DOMINATORS);
}
/* Record initial block numbers. */
......
......@@ -1148,7 +1148,6 @@ convert_to_ssa ()
sbitmap *evals;
/* Dominator bitmaps. */
sbitmap *dominators;
sbitmap *dfs;
sbitmap *idfs;
......@@ -1164,15 +1163,9 @@ convert_to_ssa ()
/* Need global_live_at_{start,end} up to date. */
life_analysis (get_insns (), NULL, PROP_KILL_DEAD_CODE | PROP_SCAN_DEAD_CODE);
/* Compute dominators. */
dominators = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
compute_flow_dominators (dominators, NULL);
idom = (int *) alloca (n_basic_blocks * sizeof (int));
memset ((void *)idom, -1, (size_t)n_basic_blocks * sizeof (int));
compute_immediate_dominators (idom, dominators);
sbitmap_vector_free (dominators);
calculate_dominance_info (idom, NULL, CDI_DOMINATORS);
if (rtl_dump_file)
{
......
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