This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] cfgloopmanip.c: Speed up create_preheader.
- From: Jeffrey A Law <law at redhat dot com>
- To: Kazu Hirata <kazu at cs dot umass dot edu>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 08 Dec 2004 08:42:26 -0700
- Subject: Re: [patch] cfgloopmanip.c: Speed up create_preheader.
- Organization: Red Hat, Inc
- References: <20041208.082118.55852168.kazu@cs.umass.edu>
- Reply-to: law at redhat dot com
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