From ac0bd8018d589a221f8ad95f7a2ddd4d228f1bb5 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 2 Mar 2005 11:45:25 -0800 Subject: [PATCH] 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: r95796 --- gcc/ChangeLog | 6 ++++++ gcc/tree-if-conv.c | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e5e19cc..a4aced0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-03-02 Devang Patel + + PR tree-optimization/18815 + * tree-if-conv.c (combine_blocks): Adjust loop header edges for + loops with zero exit edges. + 2005-03-02 Kazu Hirata * cfg.c (connect_src, connect_dest, disconnect_src, diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c index bb832d2..ce66e2a 100644 --- a/gcc/tree-if-conv.c +++ b/gcc/tree-if-conv.c @@ -905,11 +905,22 @@ 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 && loop->num_exits == 0) + { + 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); ) { -- 2.7.4