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: improve doloop recognition


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.

- say what platform you tested it on, see
  http://gcc.gnu.org/cvswrite.html#testing
Darwin isn't enough?  OK, Darwin on PowerPC.

- 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?)

/* 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" } } */


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