+2004-10-25  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * cfgloopmanip.c (loopify): Take two more arguments true_edge
+       and false_edge.
+       * cfgloop.h: Adjust the corresponding prototype.
+       * loop-unswitch.c (unswitch_loop): Adjust a call to loopify.
+       * tree-ssa-loop-manip.c (tree_ssa_loop_version): Likewise.
+
 2004-10-25  Jakub Jelinek  <jakub@redhat.com>
 
        * dwarf2out.c (rtl_for_decl_location): Avoid segfault if
 
 extern int duplicate_loop_to_header_edge (struct loop *, edge, struct loops *,
                                          unsigned, sbitmap, edge, edge *,
                                          unsigned *, int);
-extern struct loop *loopify (struct loops *, edge, edge, basic_block, bool);
+extern struct loop *loopify (struct loops *, edge, edge,
+                            basic_block, edge, edge, bool);
 extern void unloop (struct loops *, struct loop *);
 extern bool remove_path (struct loops *, edge);
 extern edge split_loop_bb (basic_block, void *);
 
    accordingly. Everything between them plus LATCH_EDGE destination must
    be dominated by HEADER_EDGE destination, and back-reachable from
    LATCH_EDGE source.  HEADER_EDGE is redirected to basic block SWITCH_BB,
-   FALLTHRU_EDGE (SWITCH_BB) to original destination of HEADER_EDGE and
-   BRANCH_EDGE (SWITCH_BB) to original destination of LATCH_EDGE.
+   FALSE_EDGE of SWITCH_BB to original destination of HEADER_EDGE and
+   TRUE_EDGE of SWITCH_BB to original destination of LATCH_EDGE.
    Returns newly created loop.  */
 
 struct loop *
 loopify (struct loops *loops, edge latch_edge, edge header_edge, 
-        basic_block switch_bb, bool redirect_all_edges)
+        basic_block switch_bb, edge true_edge, edge false_edge,
+        bool redirect_all_edges)
 {
   basic_block succ_bb = latch_edge->dest;
   basic_block pred_bb = header_edge->src;
 
   /* Redirect edges.  */
   loop_redirect_edge (latch_edge, loop->header);
-  loop_redirect_edge (BRANCH_EDGE (switch_bb), succ_bb);
+  loop_redirect_edge (true_edge, succ_bb);
 
   /* During loop versioning, one of the switch_bb edge is already properly
      set. Do not redirect it again unless redirect_all_edges is true.  */
   if (redirect_all_edges)
     {
       loop_redirect_edge (header_edge, switch_bb);
-      loop_redirect_edge (FALLTHRU_EDGE (switch_bb), loop->header); 
+      loop_redirect_edge (false_edge, loop->header); 
      
       /* Update dominators.  */
       set_immediate_dominator (CDI_DOMINATORS, switch_bb, pred_bb);
 
 
   /* Loopify from the copy of LOOP body, constructing the new loop.  */
   nloop = loopify (loops, latch_edge,
-                  EDGE_PRED (loop->header->rbi->copy, 0), switch_bb, true);
+                  EDGE_PRED (loop->header->rbi->copy, 0), switch_bb,
+                  BRANCH_EDGE (switch_bb), FALLTHRU_EDGE (switch_bb), true);
 
   /* Remove branches that are now unreachable in new loops.  */
   remove_path (loops, true_edge);
 
 tree_ssa_loop_version (struct loops *loops, struct loop * loop, 
                       tree cond_expr, basic_block *condition_bb)
 {
-  edge entry, latch_edge, exit;
+  edge entry, latch_edge, exit, true_edge, false_edge;
   basic_block first_head, second_head;
   int irred_flag;
   struct loop *nloop;
                                            cond_expr); 
 
   latch_edge = EDGE_SUCC (loop->latch->rbi->copy, 0);
+  
+  extract_true_false_edges_from_block (*condition_bb, &true_edge, &false_edge);
   nloop = loopify (loops, 
                   latch_edge,
                   EDGE_PRED (loop->header->rbi->copy, 0),
-                  *condition_bb,
+                  *condition_bb, true_edge, false_edge,
                   false /* Do not redirect all edges.  */);
 
   exit = loop->single_exit;
   lv_update_pending_stmts (latch_edge);
 
   /* loopify redirected condition_bb's succ edge. Update its PENDING_STMTS.  */ 
-  lv_update_pending_stmts (FALLTHRU_EDGE (*condition_bb));
+  extract_true_false_edges_from_block (*condition_bb, &true_edge, &false_edge);
+  lv_update_pending_stmts (false_edge);
 
   /* Adjust irreducible flag.  */
   if (irred_flag)