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] cfgloopmanip.c: Speed up create_preheader.


On Wed, 2004-12-08 at 08:21 -0500, Kazu Hirata wrote:
> Hi,
> 
> Attached is a patch to speed up create_preheader by "unrolling" and
> simplifying FOR_EACH_EDGE.
> 
> Each of the two hunks below contains an instance of FOR_EACH_EDGE like
> this.
> 
>   FOR_EACH_EDGE (e, ei, loop->header->preds)
>     if (e->src != loop->latch)
>       break;
> 
> Note that a loop header has at least two incoming edges, one back edge
> and another one to enter the loop.  Note also that edges in any edge
> vector are unique.  Let me list out all possible outcomes after the
> FOR_EACH_EDGE.
> 
> EDGE_PRED (loop->header, 0)->src == loop->latch
> 
>   In this case, we have e == EDGE_PRED (loop->header, 1)->src.
> 
> EDGE_PRED (loop->header, 0)->src != loop->latch
> 
>   In this case, we have e == EDGE_PRED (loop->header, 0)->src.
> 
> So we can easily replace FOR_EACH_EDGE with code like so:
> 
>   e = EDGE_PRED (loop->header,
>                  EDGE_PRED (loop->header, 0)->src == loop->latch);
> 
> Tested on i686-pc-linux-gnu.  OK to apply?
> 
> Kazu Hirata
> 
> 2004-12-08  Kazu Hirata  <kazu@cs.umass.edu>
> 
> 	* cfgloopmanip.c (create_preheader): Speed up by "unrolling"
> 	and simplifying FOR_EACH_EDGE.
Approved.
jeff



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