cfgrtl.c (try_redirect_by_replacing_jump): Speed up the check that tests if all edges...
authorKazu Hirata <kazu@cs.umass.edu>
Fri, 26 Nov 2004 06:54:13 +0000 (06:54 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Fri, 26 Nov 2004 06:54:13 +0000 (06:54 +0000)
* cfgrtl.c (try_redirect_by_replacing_jump): Speed up the
check that tests if all edges go to the same destination.

From-SVN: r91334

gcc/ChangeLog
gcc/cfgrtl.c

index 4919f1a68338285a46c64d2823dd73a6ea09f4f0..6ed23714c4bfee6e929b281e758bd599dab37d29 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-26  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * cfgrtl.c (try_redirect_by_replacing_jump): Speed up the
+       check that tests if all edges go to the same destination.
+
 2004-11-25  Jeff Law  <law@redhat.com>
 
        * timevar.def (TV_TREE_LOOP_INIT, TV_TREE_LOOP_FINI): New timevars.
index 4e0fc4cb8fc54f0b1a62f3f038f6522992a642df..3ba3265e6830741c898ca0041aa1e76dbd20b020 100644 (file)
@@ -662,10 +662,8 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
 {
   basic_block src = e->src;
   rtx insn = BB_END (src), kill_from;
-  edge tmp;
   rtx set;
   int fallthru = 0;
-  edge_iterator ei;
 
   /* If we are partitioning hot/cold basic blocks, we don't want to
      mess up unconditional or indirect jumps that cross between hot
@@ -682,12 +680,17 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
          || BB_PARTITION (src) != BB_PARTITION (target)))
     return NULL;
 
-  /* Verify that all targets will be TARGET.  */
-  FOR_EACH_EDGE (tmp, ei, src->succs)
-    if (tmp->dest != target && tmp != e)
-      break;
+  /* We can replace or remove a complex jump only when we have exactly
+     two edges.  Also, if we have exactly one outgoing edge, we can
+     redirect that.  */
+  if (EDGE_COUNT (src->succs) >= 3
+      /* Verify that all targets will be TARGET.  Specifically, the
+        edge that is not E must also go to TARGET.  */
+      || (EDGE_COUNT (src->succs) == 2
+         && EDGE_SUCC (src, EDGE_SUCC (src, 0) == e)->dest != target))
+    return NULL;
 
-  if (tmp || !onlyjump_p (insn))
+  if (!onlyjump_p (insn))
     return NULL;
   if ((!optimize || reload_completed) && tablejump_p (insn, NULL, NULL))
     return NULL;