OSDN Git Service

* optabs.c, doc/c-tree.texi, doc/install.texi, doc/md.texi,
[pf3gnuchains/gcc-fork.git] / gcc / loop-unswitch.c
index c39718b..f307dc1 100644 (file)
@@ -24,6 +24,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "tm.h"
 #include "rtl.h"
 #include "hard-reg-set.h"
+#include "obstack.h"
 #include "basic-block.h"
 #include "cfgloop.h"
 #include "cfglayout.h"
@@ -103,11 +104,13 @@ compare_and_jump_seq (rtx op0, rtx op1, enum rtx_code comp, rtx label, int prob,
     {
       /* A hack -- there seems to be no easy generic way how to make a
         conditional jump from a ccmode comparison.  */
-      gcc_assert (cinsn);
+      if (!cinsn)
+       abort ();
       cond = XEXP (SET_SRC (pc_set (cinsn)), 0);
-      gcc_assert (GET_CODE (cond) == comp);
-      gcc_assert (rtx_equal_p (op0, XEXP (cond, 0)));
-      gcc_assert (rtx_equal_p (op1, XEXP (cond, 1)));
+      if (GET_CODE (cond) != comp
+         || !rtx_equal_p (op0, XEXP (cond, 0))
+         || !rtx_equal_p (op1, XEXP (cond, 1)))
+       abort ();
       emit_jump_insn (copy_insn (PATTERN (cinsn)));
       jump = get_last_insn ();
       JUMP_LABEL (jump) = JUMP_LABEL (cinsn);
@@ -116,7 +119,8 @@ compare_and_jump_seq (rtx op0, rtx op1, enum rtx_code comp, rtx label, int prob,
     }
   else
     {
-      gcc_assert (!cinsn);
+      if (cinsn)
+       abort ();
 
       op0 = force_operand (op0, NULL_RTX);
       op1 = force_operand (op1, NULL_RTX);
@@ -177,14 +181,14 @@ may_unswitch_on (basic_block bb, struct loop *loop, rtx *cinsn)
   enum machine_mode mode;
 
   /* BB must end in a simple conditional jump.  */
-  if (!bb->succ || !bb->succ->succ_next || bb->succ->succ_next->succ_next)
+  if (EDGE_COUNT (bb->succs) != 2)
     return NULL_RTX;
   if (!any_condjump_p (BB_END (bb)))
     return NULL_RTX;
 
   /* With branches inside loop.  */
-  if (!flow_bb_inside_loop_p (loop, bb->succ->dest)
-      || !flow_bb_inside_loop_p (loop, bb->succ->succ_next->dest))
+  if (!flow_bb_inside_loop_p (loop, EDGE_SUCC (bb, 0)->dest)
+      || !flow_bb_inside_loop_p (loop, EDGE_SUCC (bb, 1)->dest))
     return NULL_RTX;
 
   /* It must be executed just once each iteration (because otherwise we
@@ -376,7 +380,8 @@ unswitch_single_loop (struct loops *loops, struct loop *loop,
 
   /* Unswitch the loop on this condition.  */
   nloop = unswitch_loop (loops, loop, bbs[i], cond, cinsn);
-  gcc_assert (nloop);
+  if (!nloop)
+  abort ();
 
   /* Invoke itself on modified loops.  */
   unswitch_single_loop (loops, nloop, rconds, num + 1);
@@ -408,17 +413,18 @@ unswitch_loop (struct loops *loops, struct loop *loop, basic_block unswitch_on,
   rtx seq;
 
   /* Some sanity checking.  */
-  gcc_assert (flow_bb_inside_loop_p (loop, unswitch_on));
-
-  gcc_assert (unswitch_on->succ);
-  gcc_assert (unswitch_on->succ->succ_next);
-  gcc_assert (!unswitch_on->succ->succ_next->succ_next);
-
-  gcc_assert (just_once_each_iteration_p (loop, unswitch_on));
-  gcc_assert (!loop->inner);
-  gcc_assert (flow_bb_inside_loop_p (loop, unswitch_on->succ->dest));
-  gcc_assert (flow_bb_inside_loop_p (loop,
-                                    unswitch_on->succ->succ_next->dest));
+  if (!flow_bb_inside_loop_p (loop, unswitch_on))
+    abort ();
+  if (EDGE_COUNT (unswitch_on->succs) != 2)
+    abort ();
+  if (!just_once_each_iteration_p (loop, unswitch_on))
+    abort ();
+  if (loop->inner)
+    abort ();
+  if (!flow_bb_inside_loop_p (loop, EDGE_SUCC (unswitch_on, 0)->dest))
+    abort ();
+  if (!flow_bb_inside_loop_p (loop, EDGE_SUCC (unswitch_on, 1)->dest))
+    abort ();
 
   entry = loop_preheader_edge (loop);
 
@@ -438,7 +444,7 @@ unswitch_loop (struct loops *loops, struct loop *loop, basic_block unswitch_on,
   unswitch_on_alt = unswitch_on->rbi->copy;
   true_edge = BRANCH_EDGE (unswitch_on_alt);
   false_edge = FALLTHRU_EDGE (unswitch_on);
-  latch_edge = loop->latch->rbi->copy->succ;
+  latch_edge = EDGE_SUCC (loop->latch->rbi->copy, 0);
 
   /* Create a block with the condition.  */
   prob = true_edge->probability;
@@ -457,19 +463,20 @@ unswitch_loop (struct loops *loops, struct loop *loop, basic_block unswitch_on,
   if (irred_flag)
     {
       switch_bb->flags |= BB_IRREDUCIBLE_LOOP;
-      switch_bb->succ->flags |= EDGE_IRREDUCIBLE_LOOP;
-      switch_bb->succ->succ_next->flags |= EDGE_IRREDUCIBLE_LOOP;
+      EDGE_SUCC (switch_bb, 0)->flags |= EDGE_IRREDUCIBLE_LOOP;
+      EDGE_SUCC (switch_bb, 1)->flags |= EDGE_IRREDUCIBLE_LOOP;
     }
   else
     {
       switch_bb->flags &= ~BB_IRREDUCIBLE_LOOP;
-      switch_bb->succ->flags &= ~EDGE_IRREDUCIBLE_LOOP;
-      switch_bb->succ->succ_next->flags &= ~EDGE_IRREDUCIBLE_LOOP;
+      EDGE_SUCC (switch_bb, 0)->flags &= ~EDGE_IRREDUCIBLE_LOOP;
+      EDGE_SUCC (switch_bb, 1)->flags &= ~EDGE_IRREDUCIBLE_LOOP;
     }
 
   /* Loopify from the copy of LOOP body, constructing the new loop.  */
   nloop = loopify (loops, latch_edge,
-                  loop->header->rbi->copy->pred, switch_bb);
+                  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);