* cfg.c (cached_make_edge): Use find_edge rather than an inlined
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Nov 2004 17:14:00 +0000 (17:14 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 22 Nov 2004 17:14:00 +0000 (17:14 +0000)
        variant.
        * cfgbuild.c (make_edges): Likewise.
        * cfghooks.c (can_duplicate_block_p): Likewise.
        * cfgloop.c (loop_latch_edge): Likewise.
        * cfgloopmanip.c (force_single_succ_latches): Likewise.
        * cfgrtl.c (rtl_flow_call_edges_add): Likewise.
        * predict.c (predict_loops, propagate_freq): Likewise.
        * tracer.c (tail_duplicate): Likewise.
        * tree-cfg.c (disband_implicit_edges): Likewise.
        (tree_forwarder_block_p, tree_flow_call_edges_add): Likewise.

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

gcc/ChangeLog
gcc/cfg.c
gcc/cfgbuild.c
gcc/cfghooks.c
gcc/cfgloop.c
gcc/cfgloopmanip.c
gcc/cfgrtl.c
gcc/predict.c
gcc/tracer.c
gcc/tree-cfg.c

index 6c3ed41..33a81cc 100644 (file)
@@ -1,3 +1,17 @@
+2004-11-21  Jeff Law  <law@redhat.com>
+
+       * cfg.c (cached_make_edge): Use find_edge rather than an inlined
+       variant.
+       * cfgbuild.c (make_edges): Likewise.
+       * cfghooks.c (can_duplicate_block_p): Likewise.
+       * cfgloop.c (loop_latch_edge): Likewise.
+       * cfgloopmanip.c (force_single_succ_latches): Likewise.
+       * cfgrtl.c (rtl_flow_call_edges_add): Likewise.
+       * predict.c (predict_loops, propagate_freq): Likewise.
+       * tracer.c (tail_duplicate): Likewise.
+       * tree-cfg.c (disband_implicit_edges): Likewise.
+       (tree_forwarder_block_p, tree_flow_call_edges_add): Likewise.
+
 2004-11-22  Nick Clifton  <nickc@redhat.com>
 
        * sbitmap.c (sbitmap_union_of_preds): Remove redundant
index 85f6fac..f7e5a79 100644 (file)
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -288,7 +288,6 @@ cached_make_edge (sbitmap *edge_cache, basic_block src, basic_block dst, int fla
 {
   int use_edge_cache;
   edge e;
-  edge_iterator ei;
 
   /* Don't bother with edge cache for ENTRY or EXIT, if there aren't that
      many edges to them, or we didn't allocate memory for it.  */
@@ -309,12 +308,12 @@ cached_make_edge (sbitmap *edge_cache, basic_block src, basic_block dst, int fla
 
       /* Fall through.  */
     case 0:
-      FOR_EACH_EDGE (e, ei, src->succs)
-       if (e->dest == dst)
-         {
-           e->flags |= flags;
-           return NULL;
-         }
+      e = find_edge (src, dst);
+      if (e)
+       {
+         e->flags |= flags;
+         return NULL;
+       }
       break;
     }
 
index f5bf3e8..134a984 100644 (file)
@@ -271,7 +271,6 @@ make_edges (basic_block min, basic_block max, int update_p)
       enum rtx_code code;
       int force_fallthru = 0;
       edge e;
-      edge_iterator ei;
 
       if (LABEL_P (BB_HEAD (bb))
          && LABEL_ALT_ENTRY_P (BB_HEAD (bb)))
@@ -390,12 +389,10 @@ make_edges (basic_block min, basic_block max, int update_p)
 
       /* Find out if we can drop through to the next block.  */
       insn = NEXT_INSN (insn);
-      FOR_EACH_EDGE (e, ei, bb->succs)
-       if (e->dest == EXIT_BLOCK_PTR && e->flags & EDGE_FALLTHRU)
-         {
-           insn = 0;
-           break;
-         }
+      e = find_edge (bb, EXIT_BLOCK_PTR);
+      if (e && e->flags & EDGE_FALLTHRU)
+       insn = NULL;
+
       while (insn
             && NOTE_P (insn)
             && NOTE_LINE_NUMBER (insn) != NOTE_INSN_BASIC_BLOCK)
index 42d1183..841e468 100644 (file)
@@ -675,7 +675,6 @@ bool
 can_duplicate_block_p (basic_block bb)
 {
   edge e;
-  edge_iterator ei;
 
   if (!cfg_hooks->can_duplicate_block_p)
     internal_error ("%s does not support can_duplicate_block_p.",
@@ -686,9 +685,9 @@ can_duplicate_block_p (basic_block bb)
 
   /* Duplicating fallthru block to exit would require adding a jump
      and splitting the real last BB.  */
-  FOR_EACH_EDGE (e, ei, bb->succs)
-    if (e->dest == EXIT_BLOCK_PTR && e->flags & EDGE_FALLTHRU)
-       return false;
+  e = find_edge (bb, EXIT_BLOCK_PTR);
+  if (e && (e->flags & EDGE_FALLTHRU))
+    return false;
 
   return cfg_hooks->can_duplicate_block_p (bb);
 }
index d985a2c..303c218 100644 (file)
@@ -1499,14 +1499,7 @@ verify_loop_structure (struct loops *loops)
 edge
 loop_latch_edge (const struct loop *loop)
 {
-  edge e;
-  edge_iterator ei;
-
-  FOR_EACH_EDGE (e, ei, loop->header->preds)
-    if (e->src == loop->latch)
-      break;
-
-  return e;
+  return find_edge (loop->latch, loop->header);
 }
 
 /* Returns preheader edge of LOOP.  */
index a370e38..06fbf70 100644 (file)
@@ -1221,14 +1221,11 @@ force_single_succ_latches (struct loops *loops)
 
   for (i = 1; i < loops->num; i++)
     {
-      edge_iterator ei;
       loop = loops->parray[i];
       if (loop->latch != loop->header && EDGE_COUNT (loop->latch->succs) == 1)
        continue;
 
-      FOR_EACH_EDGE (e, ei, loop->header->preds)
-       if (e->src == loop->latch)
-         break;
+      e = find_edge (loop->latch, loop->header);
 
       loop_split_edge_with (e, NULL_RTX);
     }
index 8ac7087..6997051 100644 (file)
@@ -2972,15 +2972,13 @@ rtl_flow_call_edges_add (sbitmap blocks)
       if (need_fake_edge_p (insn))
        {
          edge e;
-         edge_iterator ei;
 
-         FOR_EACH_EDGE (e, ei, bb->succs)
-           if (e->dest == EXIT_BLOCK_PTR)
-             {
-               insert_insn_on_edge (gen_rtx_USE (VOIDmode, const0_rtx), e);
-               commit_edge_insertions ();
-               break;
-             }
+         e = find_edge (bb, EXIT_BLOCK_PTR);
+         if (e)
+           {
+             insert_insn_on_edge (gen_rtx_USE (VOIDmode, const0_rtx), e);
+             commit_edge_insertions ();
+           }
        }
     }
 
@@ -3023,9 +3021,8 @@ rtl_flow_call_edges_add (sbitmap blocks)
 #ifdef ENABLE_CHECKING
              if (split_at_insn == BB_END (bb))
                {
-                 edge_iterator ei;
-                 FOR_EACH_EDGE (e, ei, bb->succs)
-                   gcc_assert (e->dest != EXIT_BLOCK_PTR);
+                 e = find_edge (bb, EXIT_BLOCK_PTR);
+                 gcc_assert (e == NULL);
                }
 #endif
 
index 432e837..daf9839 100644 (file)
@@ -669,13 +669,15 @@ predict_loops (struct loops *loops_info, bool rtlsimpleloops)
 
          /* Loop branch heuristics - predict an edge back to a
             loop's head as taken.  */
-         FOR_EACH_EDGE (e, ei, bb->succs)
-           if (e->dest == loop->header
-               && e->src == loop->latch)
-             {
-               header_found = 1;
-               predict_edge_def (e, PRED_LOOP_BRANCH, TAKEN);
-             }
+         if (bb == loop->latch)
+           {
+             e = find_edge (loop->latch, loop->header);
+             if (e)
+               {
+                 header_found = 1;
+                 predict_edge_def (e, PRED_LOOP_BRANCH, TAKEN);
+               }
+           }
 
          /* Loop exit heuristics - predict an edge exiting the loop if the
             conditional has no loop header successors as not taken.  */
@@ -1660,21 +1662,20 @@ propagate_freq (struct loop *loop, bitmap tovisit)
 
       bitmap_clear_bit (tovisit, bb->index);
 
-      /* Compute back edge frequencies.  */
-      FOR_EACH_EDGE (e, ei, bb->succs)
-       if (e->dest == head)
-         {
-           sreal tmp;
+      e = find_edge (bb, head);
+      if (e)
+       {
+         sreal tmp;
            
-           /* EDGE_INFO (e)->back_edge_prob
-              = ((e->probability * BLOCK_INFO (bb)->frequency)
-              / REG_BR_PROB_BASE); */
+         /* EDGE_INFO (e)->back_edge_prob
+            = ((e->probability * BLOCK_INFO (bb)->frequency)
+            / REG_BR_PROB_BASE); */
            
-           sreal_init (&tmp, e->probability, 0);
-           sreal_mul (&tmp, &tmp, &BLOCK_INFO (bb)->frequency);
-           sreal_mul (&EDGE_INFO (e)->back_edge_prob,
-                      &tmp, &real_inv_br_prob_base);
-         }
+         sreal_init (&tmp, e->probability, 0);
+         sreal_mul (&tmp, &tmp, &BLOCK_INFO (bb)->frequency);
+         sreal_mul (&EDGE_INFO (e)->back_edge_prob,
+                    &tmp, &real_inv_br_prob_base);
+       }
 
       /* Propagate to successor blocks.  */
       FOR_EACH_EDGE (e, ei, bb->succs)
index 968d093..9b88766 100644 (file)
@@ -275,12 +275,9 @@ tail_duplicate (void)
              && can_duplicate_block_p (bb2))
            {
              edge e;
-             edge_iterator ei;
              basic_block old = bb2;
 
-             FOR_EACH_EDGE (e, ei, bb2->preds)
-               if (e->src == bb)
-                 break;
+             e = find_edge (bb, bb2);
 
              nduplicated += counts [bb2->index];
              bb2 = duplicate_block (bb2, e);
index 337463c..fea09d8 100644 (file)
@@ -2649,11 +2649,9 @@ disband_implicit_edges (void)
             from cfg_remove_useless_stmts here since it violates the
             invariants for tree--cfg correspondence and thus fits better
             here where we do it anyway.  */
-         FOR_EACH_EDGE (e, ei, bb->succs)
+         e = find_edge (bb, bb->next_bb);
+         if (e)
            {
-             if (e->dest != bb->next_bb)
-               continue;
-
              if (e->flags & EDGE_TRUE_VALUE)
                COND_EXPR_THEN (stmt) = build_empty_stmt ();
              else if (e->flags & EDGE_FALSE_VALUE)
@@ -3892,8 +3890,6 @@ static bool
 tree_forwarder_block_p (basic_block bb)
 {
   block_stmt_iterator bsi;
-  edge e;
-  edge_iterator ei;
 
   /* BB must have a single outgoing edge.  */
   if (EDGE_COUNT (bb->succs) != 1
@@ -3911,10 +3907,8 @@ tree_forwarder_block_p (basic_block bb)
   gcc_assert (bb != ENTRY_BLOCK_PTR);
 #endif
 
-  /* Successors of the entry block are not forwarders.  */
-  FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
-    if (e->dest == bb)
-      return false;
+  if (find_edge (ENTRY_BLOCK_PTR, bb))
+    return false;
 
   /* Now walk through the statements.  We can ignore labels, anything else
      means this is not a forwarder block.  */
@@ -5206,7 +5200,6 @@ tree_flow_call_edges_add (sbitmap blocks)
      Handle this by adding a dummy instruction in a new last basic block.  */
   if (check_last_block)
     {
-      edge_iterator ei;
       basic_block bb = EXIT_BLOCK_PTR->prev_bb;
       block_stmt_iterator bsi = bsi_last (bb);
       tree t = NULL_TREE;
@@ -5217,13 +5210,12 @@ tree_flow_call_edges_add (sbitmap blocks)
        {
          edge e;
 
-         FOR_EACH_EDGE (e, ei, bb->succs)
-           if (e->dest == EXIT_BLOCK_PTR)
-             {
-               bsi_insert_on_edge (e, build_empty_stmt ());
-               bsi_commit_edge_inserts ();
-               break;
-             }
+         e = find_edge (bb, EXIT_BLOCK_PTR);
+         if (e)
+           {
+             bsi_insert_on_edge (e, build_empty_stmt ());
+             bsi_commit_edge_inserts ();
+           }
        }
     }
 
@@ -5260,9 +5252,8 @@ tree_flow_call_edges_add (sbitmap blocks)
 #ifdef ENABLE_CHECKING
                  if (stmt == last_stmt)
                    {
-                     edge_iterator ei;
-                     FOR_EACH_EDGE (e, ei, bb->succs)
-                       gcc_assert (e->dest != EXIT_BLOCK_PTR);
+                     e = find_edge (bb, EXIT_BLOCK_PTR);
+                     gcc_assert (e == NULL);
                    }
 #endif