OSDN Git Service

PR tree-optimization/18815
authordpatel <dpatel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 5 Mar 2005 02:59:25 +0000 (02:59 +0000)
committerdpatel <dpatel@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 5 Mar 2005 02:59:25 +0000 (02:59 +0000)
       * tree-if-conv.c (combine_blocks): Adjust loop header edges for
       loops with zero exit edges.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95923 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-if-conv.c

index 084aa50..22615e1 100644 (file)
@@ -1,4 +1,10 @@
 2005-03-04  Devang Patel  <dpatel@apple.com>
 2005-03-04  Devang Patel  <dpatel@apple.com>
+       
+       PR tree-optimization/18815
+       * tree-if-conv.c (combine_blocks): Adjust loop header edges for
+       loops with zero exit edges.
+
+2005-03-04  Devang Patel  <dpatel@apple.com>
 
        * doc/invoke.texi: Remove reference to webpage that does not exist.
        
 
        * doc/invoke.texi: Remove reference to webpage that does not exist.
        
index bb832d2..ef9dc57 100644 (file)
@@ -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;
   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);
 
   /* 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.  */
        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));
 
       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); )
        {
       /* Remove labels and make stmts member of loop->header.  */
       for (bsi = bsi_start (bb); !bsi_end_p (bsi); )
        {