This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: improve doloop recognition
- From: Geoff Keating <geoffk at geoffk dot org>
- To: dalej at apple dot com
- Cc: dalej at apple dot com, gcc-patches at gcc dot gnu dot org
- Date: Tue, 17 Sep 2002 12:22:40 -0700
- Subject: Re: Patch: improve doloop recognition
- References: <49CE2506-C9D2-11D6-93B1-003065C86F94@apple.com>
> Date: Mon, 16 Sep 2002 17:13:27 -0700
> Cc: Dale Johannesen <dalej@apple.com>, gcc-patches@gcc.gnu.org
> From: Dale Johannesen <dalej@apple.com>
> On Monday, September 16, 2002, at 04:18 PM, Geoff Keating wrote:
> > Dale Johannesen <dalej@apple.com> writes:
> >> This addresses the optimization problem I reported here
> >> http://gcc.gnu.org/ml/gcc-patches/2002-09/msg00614.html
> >> in which CFG's forwarding forces a loop into a form which
> >> can't be recognized as a doloop. Obviously the test could
> >> be more extensive, but AFAIK this is sufficient to catch
> >> all the cases that can be recognized as doloops. Bootstrapped
> >> and tested on Darwin, and I've checked that real branches
> >> out of loops (break, etc.) do get forwarded on a later pass.
> >
> > The patch itself is good, but:
> >
> > - please write a ChangeLog entry
>
> I do put them in, I just usually forget to post them in the patches.
> Here:
> 2002-09-16 Dale Johannesen <dalej@apple.com>
> * cfgcleanup.c (try_forward_edges): Do not forward a
> branch to just after a loop exit before loop optimization;
> this interfered with doloop detection.
[FYI, you don't need to say why a patch is made in the ChangeLog
entry; if you think some chunk of code needs explanation, the best
thing is to add a comment in the actual code.]
> > - say what platform you tested it on, see
> > http://gcc.gnu.org/cvswrite.html#testing
>
> Darwin isn't enough? OK, Darwin on PowerPC.
Oh, sorry, I missed that part of your original message.
> > - please write a testcase. If you can't think of a better way, write
> > a gcc.dg testcase that is powerpc-specific and uses scan-assembler
> > to look for a decrement-and-branch instruction.
>
> I can't think of a better way. This patch is not really target-specific
> so I wasn't crazy about this approach, but I suppose it is better than
> nothing. (The test doesn't specify Darwin; I believe the relevant
> assembler mnemonics are the same on other OSs?)
Yes, the mnemonics don't differ between powerpc-* targets.
> /* Make sure both loops are recognized as doloops.
> If so, "bdnz" will be generated on ppc; if not,
> you will get "blt". */
>
> /* { dg-do compile { target powerpc-*-* } } */
> /* { dg-options "-O2" } */
> void foo (int count, char* pca, char* pcb) {
> int i;
> if (count > 10)
> for (i = 0; i < count; ++i)
> pcb += i;
> else
> for (i = 0; i < count; ++i)
> pca += i;
> *pca = *pcb;
> }
> /* { dg-final { scan-assembler "bdnz" } } */
> /* { dg-final { scan-assembler-not "blt" } } */
Thanks! With these additions, the patch is OK, please commit it.
--
- Geoffrey Keating <geoffk@geoffk.org>