[PATCH 4/4] [Powerpc] tune/optimize memmove/wordcopy. Call memcpy when appropriate.
Will Schmidt
will_schmidt@vnet.ibm.com
Mon May 14 14:04:00 GMT 2012
On Sat, 2012-05-12 at 17:48 +0200, Andreas Schwab wrote:
> Will Schmidt <will_schmidt@vnet.ibm.com> writes:
>
> > diff --git a/sysdeps/powerpc/memmove.c b/sysdeps/powerpc/memmove.c
> > index c74e556..80de8ac 100644
> > --- a/sysdeps/powerpc/memmove.c
> > +++ b/sysdeps/powerpc/memmove.c
> > @@ -50,6 +50,10 @@ MEMMOVE (a1, a2, len)
> > unsigned long int dstp = (long int) dest;
> > unsigned long int srcp = (long int) src;
> >
> > + /* If there is no overlap between ranges, call the builtin memcpy. */
> > + if ( (dstp >= (srcp + len)) || (srcp > (dstp + len)) )
> > + return __builtin_memcpy (dest, src, len);
>
> In file included from bcopy.c:28:0:
> ../sysdeps/powerpc/memmove.c: In function âbcopyâ:
> ../sysdeps/powerpc/memmove.c:54:5: warning: âreturnâ with a value, in function returning void [enabled by default]
>
> Fixed as attached.
Thanks, I obviously missed my check-for-warnings step on this one. :-o
Your change is good. I didn't notice earlier, but looks like there is
a RETURN(s) and rettype #define mechanism that is meant to handle the
different function return types, that could also have worked here too.
Thanks,
-Will
>
> Andreas.
>
> * sysdeps/powerpc/memmove.c (MEMMOVE): Don't return a value if
> used as bcopy.
>
> diff --git a/sysdeps/powerpc/memmove.c b/sysdeps/powerpc/memmove.c
> index 8918283..1617ece 100644
> --- a/sysdeps/powerpc/memmove.c
> +++ b/sysdeps/powerpc/memmove.c
> @@ -50,12 +50,12 @@ MEMMOVE (a1, a2, len)
> unsigned long int srcp = (long int) src;
>
> /* If there is no overlap between ranges, call the builtin memcpy. */
> - if ( (dstp >= (srcp + len)) || (srcp > (dstp + len)) )
> - return __builtin_memcpy (dest, src, len);
> + if (dstp >= srcp + len || srcp > dstp + len)
> + __builtin_memcpy (dest, src, len);
>
> /* This test makes the forward copying code be used whenever possible.
> Reduces the working set. */
> - if (dstp - srcp >= len) /* *Unsigned* compare! */
> + else if (dstp - srcp >= len) /* *Unsigned* compare! */
> {
> /* Copy from the beginning to the end. */
>
> --
> 1.7.10.2
>
>
More information about the Libc-alpha
mailing list