bzero optimization rarely does
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Sat Jul 13 01:56:00 GMT 2002
> From: Roger Sayle <roger@eyesopen.com>
>
> Hi Kaveh,
> > > 2002-07-11 Roger Sayle <roger@eyesopen.com>
> > >
> > > * expr.c [CLEAR_RATIO]: New macro defining the maximum number
> > > of move instructions to use when clearing memory,
> > > c.f. MOVE_RATIO. [CLEAR_BY_PIECES_P]: New macro, using
> > > CLEAR_RATIO, to determine whether clear_by_pieces should be
> > > used to clear storage. (clear_storage): Use CLEAR_BY_PIECES_P
> > > instead of MOVE_BY_PIECES_P.
> >
> > How about a testcase patterned after execute/string-opt-17.c?
> > (Must len really be less than 2 before we abort in the static memset?)
>
> The problem is that the backend has control over the decision of
> whether to call memset or to use a sequence of clear instructions.
> So for example, in ns32k.h the "#define MOVE_RATIO 0" means that
> this platform always calls memset!
I thought the point of your patch was to divorce memset from
MOVE_RATIO?
> When I wrote execute/string-opt-17.c and its corresponding memset
> optimization, I always transformed writing a single byte with
> memset into a byte store instruction. This allows the "abort"
> in the testcase to check whether the code fires at all.
>
> Alas there is no simple check whether the clear_storage heuristics
> are firing correctly. All the sequences that GCC generates should
> have identical behaviour, and the selection between them is target
> and compiler option (-Os) specific.
You can always check __OPTIMIZE_SIZE__ and bypass the abort for -Os
just like we do for -O0 and __OPTIMIZE__.
Once your patch goes in (except with -Os) everybody should have a
CLEAR_RATIO of at least 15 which is good for more than len == 2,
right? And some of the platforms can do any length if clrstr is
there.
If you're motivated you can always write something like what's in
gcc.dg/20020312-2.c to set the upper bound on how many max bytes
you'll test memset with for each cpu. And for those cpus with clrstr
you add a test with a huge upper bound.
I know it seems like a pain, but in the end IMHO it's worth it because
then the regression checker ensures it's never broken ever again.
--Kaveh
--
Kaveh R. Ghazi Director of Systems Architecture
ghazi@caip.rutgers.edu Qwest Solutions
More information about the Gcc
mailing list