diff options
author | amacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-02 17:57:54 +0000 |
---|---|---|
committer | amacleod <amacleod@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-02 17:57:54 +0000 |
commit | ba4d2b2f28479db60842a014a93613da093fd150 (patch) | |
tree | 4e565c339cd910e920e36af879ee13b02dd89c3d /gcc/cfganal.c | |
parent | 11f8ac85df3620e926f8eb0d132fa3a71a9b433a (diff) | |
download | gcc-ba4d2b2f28479db60842a014a93613da093fd150.tar.gz |
* tree-flow.h: Remove some prototypes.
* tree-ssa-dce.c (mark_virtual_operand_for_renaming,
mark_virtual_phi_result_for_renaming): Move to tree-into-ssa.c.
* tree-into-ssa.c (mark_virtual_operand_for_renaming,
mark_virtual_phi_result_for_renaming): Relocate here.
* tree-into-ssa.h: Add prototypes.
* tree-ssa-phiopt.c: (tree_ssa_phiopt_worker) Use
single_pred_before_succ_order.
(blocks_in_phiopt_order): Rename and move to cfganal.c.
(nonfreeing_call_p) Move to gimple.c.
* cfganal.c (single_pred_before_succ_order): Move and renamed from
tree-ssa-phiopt.c.
* basic-block.h (single_pred_before_succ_order): Add prototype.
* gimple.c (nonfreeing_call_p): Relocate here.
* gimple.h: Add prototype.
* tree-ssa-ifcombine.c: Include tree-ssa-phiopt.h.
* tree-ssa-dom.h: New file. Relocate prototypes here.
* tree-ssa.h: Include tree-ssa-dom.h.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203122 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfganal.c')
-rw-r--r-- | gcc/cfganal.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/gcc/cfganal.c b/gcc/cfganal.c index 56853b9be13..762eea4ca04 100644 --- a/gcc/cfganal.c +++ b/gcc/cfganal.c @@ -1465,3 +1465,56 @@ bitmap_union_of_preds (sbitmap dst, sbitmap *src, basic_block b) *r++ |= *p++; } } + +/* Returns the list of basic blocks in the function in an order that guarantees + that if a block X has just a single predecessor Y, then Y is after X in the + ordering. */ + +basic_block * +single_pred_before_succ_order (void) +{ + basic_block x, y; + basic_block *order = XNEWVEC (basic_block, n_basic_blocks); + unsigned n = n_basic_blocks - NUM_FIXED_BLOCKS; + unsigned np, i; + sbitmap visited = sbitmap_alloc (last_basic_block); + +#define MARK_VISITED(BB) (bitmap_set_bit (visited, (BB)->index)) +#define VISITED_P(BB) (bitmap_bit_p (visited, (BB)->index)) + + bitmap_clear (visited); + + MARK_VISITED (ENTRY_BLOCK_PTR); + FOR_EACH_BB (x) + { + if (VISITED_P (x)) + continue; + + /* Walk the predecessors of x as long as they have precisely one + predecessor and add them to the list, so that they get stored + after x. */ + for (y = x, np = 1; + single_pred_p (y) && !VISITED_P (single_pred (y)); + y = single_pred (y)) + np++; + for (y = x, i = n - np; + single_pred_p (y) && !VISITED_P (single_pred (y)); + y = single_pred (y), i++) + { + order[i] = y; + MARK_VISITED (y); + } + order[i] = y; + MARK_VISITED (y); + + gcc_assert (i == n - 1); + n -= np; + } + + sbitmap_free (visited); + gcc_assert (n == 0); + return order; + +#undef MARK_VISITED +#undef VISITED_P +} |