[PATCH 1/4] [Powerpc] tune/optimize memmove/wordcopy. Add helper macro to call MERGE

Ryan S. Arnold ryan.arnold@gmail.com
Thu Mar 22 14:45:00 GMT 2012


On Mon, Mar 19, 2012 at 4:01 PM, Will Schmidt <will_schmidt@vnet.ibm.com> wrote:
> [Powerpc] tune/optimize memmove/wordcopy. Add helper macro to call MERGE
>
> Add helper macros to handle calling the MERGE function with the proper
> alignments.  This significantly shortens the code.
>
> 2012-03-19  Will Schmidt <will_schmidt@vnet.ibm.com>
>
>        * sysdeps/powerpc/powerpc64/power6/wordcopy.c: Add fwd_align_merge and
>        bwd_align_merge macros.
>        * sysdeps/powerpc/powerpc32/power6/wordcopy.c: Likewise.
> ---
>  sysdeps/powerpc/powerpc32/power6/wordcopy.c |  117 ++++----------
>  sysdeps/powerpc/powerpc64/power6/wordcopy.c |  234 +++++----------------------
>  2 files changed, 79 insertions(+), 272 deletions(-)
>
> diff --git a/sysdeps/powerpc/powerpc32/power6/wordcopy.c b/sysdeps/powerpc/powerpc32/power6/wordcopy.c
> index ddf2865..9748268 100644
> --- a/sysdeps/powerpc/powerpc32/power6/wordcopy.c
> +++ b/sysdeps/powerpc/powerpc32/power6/wordcopy.c
> @@ -1,5 +1,5 @@
>  /* _memcopy.c -- subroutines for memory copy functions.
> -   Copyright (C) 1991, 1996, 2006 Free Software Foundation, Inc.
> +   Copyright (C) 1991, 1996, 2006, 2012 Free Software Foundation, Inc.

Per the contribution checklist you may now collapse the copyright year
range, e.g.,

Copyright (C) 1991-2012 Free Software Foundation, Inc.

>    This file is part of the GNU C Library.
>    Contributed by Torbjorn Granlund (tege@sics.se).
>    Updated for POWER6 by Steven Munroe (sjmunroe@us.ibm.com).
> @@ -66,6 +66,20 @@ _wordcopy_fwd_aligned (dstp, srcp, len)
>    DSTP should be aligned for memory operations on `op_t's, but SRCP must
>    *not* be aligned.  */
>
> +#define fwd_align_merge(align)                                         \
> +  do                                                                   \
> +    {                                                                  \
> +      a1 = ((op_t *) srcp)[1];                                         \
> +      a2 = ((op_t *) srcp)[2];                                         \
> +      ((op_t *) dstp)[0] = MERGE (a0, align*8, a1, (32-align*8));      \
> +      ((op_t *) dstp)[1] = MERGE (a1, align*8, a2, (32-align*8));      \
> +      a0 = a2;                                                         \
> +      srcp += 2 * OPSIZ;                                               \
> +      dstp += 2 * OPSIZ;                                               \
> +      len -= 2;                                                                \
> +    }                                                                  \
> +  while (len != 0);
> +
>  void
>  _wordcopy_fwd_dest_aligned (dstp, srcp, len)
>      long int dstp;
> @@ -105,49 +119,13 @@ _wordcopy_fwd_dest_aligned (dstp, srcp, len)
>   switch (align)
>     {
>     case 1:
> -      do
> -        {
> -          a1 = ((op_t *) srcp)[1];
> -          a2 = ((op_t *) srcp)[2];
> -          ((op_t *) dstp)[0] = MERGE (a0, 8, a1, (32-8));
> -          ((op_t *) dstp)[1] = MERGE (a1, 8, a2, (32-8));
> -          a0 = a2;
> -
> -          srcp += 2 * OPSIZ;
> -          dstp += 2 * OPSIZ;
> -          len -= 2;
> -        }
> -      while (len != 0);
> +      fwd_align_merge(1)

This should be and future instances of it and bwd_align_merge should
have a space between then symbol name and the parenthesis, e.g.,

fwd_align_merge (1)

I know that technically due to CPP macro expansion that a trailing
semi-colon is not necessary, but is it preferred?

fwd_align_merge (1);

Ryan


More information about the Libc-alpha mailing list