aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-if-conv.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-if-conv.c')
-rw-r--r--gcc/tree-if-conv.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index fbcbe1ca5d7..c07c04cd9b2 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -821,7 +821,8 @@ process_phi_nodes (struct loop *loop)
/* Replace phi nodes with cond. modify expr. */
for (i = 1; i < orig_loop_num_nodes; i++)
{
- tree phi, cond;
+ /* APPLE LOCAL dunno why this is necessary */
+ tree phi, cond = NULL_TREE;
block_stmt_iterator bsi;
basic_block true_bb = NULL;
bb = ifc_bbs[i];
@@ -830,7 +831,7 @@ process_phi_nodes (struct loop *loop)
continue;
phi = phi_nodes (bb);
- bsi = bsi_start (bb);
+ bsi = bsi_after_labels (bb);
/* BB has two predecessors. Using predecessor's aux field, set
appropriate condition for the PHI node replacement. */
@@ -858,7 +859,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);
@@ -903,11 +905,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); )
{
@@ -1017,7 +1031,7 @@ get_loop_body_in_if_conv_order (const struct loop *loop)
gcc_assert (loop->latch != EXIT_BLOCK_PTR);
blocks = xcalloc (loop->num_nodes, sizeof (basic_block));
- visited = BITMAP_XMALLOC ();
+ visited = BITMAP_ALLOC (NULL);
blocks_in_bfs_order = get_loop_body_in_bfs_order (loop);
@@ -1029,7 +1043,7 @@ get_loop_body_in_if_conv_order (const struct loop *loop)
if (bb->flags & BB_IRREDUCIBLE_LOOP)
{
free (blocks_in_bfs_order);
- BITMAP_XFREE (visited);
+ BITMAP_FREE (visited);
free (blocks);
return NULL;
}
@@ -1052,7 +1066,7 @@ get_loop_body_in_if_conv_order (const struct loop *loop)
}
}
free (blocks_in_bfs_order);
- BITMAP_XFREE (visited);
+ BITMAP_FREE (visited);
return blocks;
}