This is the mail archive of the gcc-patches@gcc.gnu.org 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]

Re: [patch] cfgrtl.c: Speed up rtl_tidy_fallthru_edge.


On Sat, 2004-11-27 at 21:37 -0500, Kazu Hirata wrote:
> Hi,
> 
> 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
> get
> 
>   EDGE_COUNT (b->succs) == 1
> 
> Tested on i686-pc-linux-gnu.  OK to apply?
> 
> Kazu Hirata
> 
> 2004-11-28  Kazu Hirata  <kazu@cs.umass.edu>
> 
> 	* cfgrtl.c (rtl_tidy_fallthru_edge): Speed up by using
> 	EDGE_COUNT.
Approved.

Jeff



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