diff options
author | Devang Patel <dpatel@apple.com> | 2005-03-04 18:59:25 -0800 |
---|---|---|
committer | Devang Patel <dpatel@gcc.gnu.org> | 2005-03-04 18:59:25 -0800 |
commit | 537a2904e71f46dce47e2cbcd5b90b59b974568f (patch) | |
tree | 4522297f7e571484534190b847a0f058c3f5bd80 /gcc/tree-if-conv.c | |
parent | c533f56b23e374e2cc15f704408f61c57915b091 (diff) | |
download | gcc-537a2904e71f46dce47e2cbcd5b90b59b974568f.zip gcc-537a2904e71f46dce47e2cbcd5b90b59b974568f.tar.gz gcc-537a2904e71f46dce47e2cbcd5b90b59b974568f.tar.bz2 |
re PR tree-optimization/18815 (Tree if-conversion screws up cfg very badly)
PR tree-optimization/18815
* tree-if-conv.c (combine_blocks): Adjust loop header edges for
loops with zero exit edges.
From-SVN: r95923
Diffstat (limited to 'gcc/tree-if-conv.c')
-rw-r--r-- | gcc/tree-if-conv.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index bb832d2..ef9dc57 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -858,7 +858,8 @@ combine_blocks (struct loop *loop) basic_block bb, exit_bb, merge_target_bb; unsigned int orig_loop_num_nodes = loop->num_nodes; unsigned int i; - + unsigned int n_exits; + edge *exits = get_loop_exit_edges (loop, &n_exits); /* Process phi nodes to prepare blocks for merge. */ process_phi_nodes (loop); @@ -905,11 +906,23 @@ combine_blocks (struct loop *loop) continue; /* It is time to remove this basic block. First remove edges. */ - while (EDGE_COUNT (bb->succs) > 0) - remove_edge (EDGE_SUCC (bb, 0)); while (EDGE_COUNT (bb->preds) > 0) remove_edge (EDGE_PRED (bb, 0)); + /* This is loop latch and loop does not have exit then do not + delete this basic block. Just remove its PREDS and reconnect + loop->header and loop->latch blocks. */ + if (bb == loop->latch && n_exits == 0) + { + exits = NULL; /* To suppress unused warning. */ + make_edge (loop->header, loop->latch, EDGE_FALLTHRU); + set_immediate_dominator (CDI_DOMINATORS, loop->latch, loop->header); + continue; + } + + while (EDGE_COUNT (bb->succs) > 0) + remove_edge (EDGE_SUCC (bb, 0)); + /* Remove labels and make stmts member of loop->header. */ for (bsi = bsi_start (bb); !bsi_end_p (bsi); ) { |