This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] cfgrtl.c: Speed up rtl_tidy_fallthru_edge.


Attached is a patch to speed up rtl_tidy_fallthru_edge.

In rtl_tidy_fallthru_edge, the only result we use out of the
FOR_EACH_EDGE loop is ei.index.

Now, consider a part of the condition in the "if" statement shown in
the patch.

  EDGE_SUCC (b, 0) == e && ei.index == EDGE_COUNT (b->succs) - 1

Since ei.index is the index of edge E within B->succs, the second half
of the condition tests whether the last edge in the edge vector is
equal to E, which we can express as

  EDGE_SUCC (b, 0) == e && EDGE_SUCC (b, EDGE_COUNT (b->succs) - 1) == e

Since edges in any edge vector are unique, the condition above is true
if and only if

  EDGE_COUNT (b->succs) == 1 && EDGE_SUCC (b, 0) == e

But then E is known to be one of the successor edges of B.  In fact, B
is computed as E->src.  Therefore, we can remove the second half and

  EDGE_COUNT (b->succs) == 1

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2004-11-28  Kazu Hirata  <>

	* cfgrtl.c (rtl_tidy_fallthru_edge): Speed up by using

Index: cfgrtl.c
RCS file: /cvs/gcc/gcc/gcc/cfgrtl.c,v
retrieving revision 1.152
diff -u -d -p -r1.152 cfgrtl.c
--- cfgrtl.c	26 Nov 2004 06:54:13 -0000	1.152
+++ cfgrtl.c	27 Nov 2004 17:45:15 -0000
@@ -1201,12 +1201,6 @@ rtl_tidy_fallthru_edge (edge e)
   rtx q;
   basic_block b = e->src, c = b->next_bb;
-  edge e2;
-  edge_iterator ei;
-  FOR_EACH_EDGE (e2, ei, b->succs)
-    if (e == e2)
-      break;
   /* ??? In a late-running flow pass, other folks may have deleted basic
      blocks by nopping out blocks, leaving multiple BARRIERs between here
@@ -1229,7 +1223,7 @@ rtl_tidy_fallthru_edge (edge e)
   if (JUMP_P (q)
       && onlyjump_p (q)
       && (any_uncondjump_p (q)
-	  || (EDGE_SUCC (b, 0) == e && ei.index == EDGE_COUNT (b->succs) - 1)))
+	  || EDGE_COUNT (b->succs) == 1))
 #ifdef HAVE_cc0
       /* If this was a conditional jump, we need to also delete

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]