[patch] bb-reorder.c: Speed up find_traces_1_round.
Kazu Hirata
kazu@cs.umass.edu
Sat Nov 27 03:40:00 GMT 2004
Hi,
Attached is a patch to speed up find_traces_1_round.
Consider the following loop:
edge another_edge;
FOR_EACH_EDGE (another_edge, ei, bb->succs)
if (another_edge != best_edge)
break;
At this point, best_edge is known to be one of the outgoing edges from
bb. Note that all we care about after this loop is whether
another_edge is NULL or not. Let me list out all possibilities after
this loop.
EDGE_COUNT (bb->succs) == 0
Impossible because best_edge is one of the outgoing edges from bb.
EDGE_COUNT (bb->succs) == 1
another_edge == NULL because best_edge is the only outgoing edge
from bb.
EDGE_COUNT (bb->succs) >= 2
another_edge != NULL because we have at least one edge that is
different from best_edge.
ALl in all, "!another_edge" (and the loop to compute another_edge)
boils down to EDGE_COUNT (bb->succs) == 1.
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2004-11-26 Kazu Hirata <kazu@cs.umass.edu>
* bb-reorder.c (find_traces_1_round): Speed up by using
EDGE_COUNT instead of FOR_EACH_EDGE.
Index: bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.86
diff -c -d -p -r1.86 bb-reorder.c
*** bb-reorder.c 25 Nov 2004 09:29:58 -0000 1.86
--- bb-reorder.c 26 Nov 2004 18:49:23 -0000
*************** find_traces_1_round (int branch_th, int
*** 638,651 ****
{
/* The loop has less than 4 iterations. */
! /* Check whether there is another edge from BB. */
! edge another_edge;
! FOR_EACH_EDGE (another_edge, ei, bb->succs)
! if (another_edge != best_edge)
! break;
!
! if (!another_edge && copy_bb_p (best_edge->dest,
! !optimize_size))
{
bb = copy_bb (best_edge->dest, best_edge, bb,
*n_traces);
--- 638,645 ----
{
/* The loop has less than 4 iterations. */
! if (EDGE_COUNT (bb->succs) == 1
! && copy_bb_p (best_edge->dest, !optimize_size))
{
bb = copy_bb (best_edge->dest, best_edge, bb,
*n_traces);
More information about the Gcc-patches
mailing list