This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] powerpc: Optimize memchr for power8
- From: "Tulio Magno Quites Machado Filho" <tuliom at linux dot vnet dot ibm dot com>
- To: Rajalakshmi Srinivasaraghavan <raji at linux dot vnet dot ibm dot com>, libc-alpha at sourceware dot org
- Cc:
- Date: Mon, 19 Jun 2017 11:07:13 -0300
- Subject: Re: [PATCH] powerpc: Optimize memchr for power8
- Authentication-results: sourceware.org; auth=none
- References: <1496992621-7323-1-git-send-email-raji@linux.vnet.ibm.com>
Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com> writes:
> Vectorized loops are used for sizes greater than 32B to improve
> performance over power7 optimiztion.
> Tested on powerpc64 and powerpc64le.
>
> 2017-06-09 Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
>
> * sysdeps/powerpc/powerpc64/multiarch/Makefile
> (sysdep_routines): Add memchr_power8.
> * sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
> (memchr): Add __memchr_power8 to list of memchr functions.
> * sysdeps/powerpc/powerpc64/multiarch/memchr-power8.S: New file.
> * sysdeps/powerpc/powerpc64/multiarch/memchr.c
> (memchr): Add __memchr_power8 to ifunc list.
> * sysdeps/powerpc/powerpc64/power8/memchr.S: New file.
Looks good to me, but...
> diff --git a/sysdeps/powerpc/powerpc64/power8/memchr.S b/sysdeps/powerpc/powerpc64/power8/memchr.S
> new file mode 100644
> index 0000000..fdefa43
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/power8/memchr.S
> @@ -0,0 +1,335 @@
> +/* Optimized memchr implementation for POWER8.
> + Copyright (C) 2017 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +#include <sysdep.h>
> +
> +/* void *[r3] memchr (const void *s [r3], int c [r4], size_t n [r5]) */
> +
> +/* TODO: change these to the actual instructions when the minimum required
> + binutils allows it. */
> +#define MTVRD(v, r) .long (0x7c000167 | ((v)<<(32-11)) | ((r)<<(32-16)))
> +#define MFVRD(r, v) .long (0x7c000067 | ((v)<<(32-11)) | ((r)<<(32-16)))
> +#define VBPERMQ(t, a, b) .long (0x1000054c \
> + | ((t)<<(32-11)) \
> + | ((a)<<(32-16)) \
> + | ((b)<<(32-21)) )
> +
> +#ifndef MEMCHR
> +# define MEMCHR __memchr
> +#endif
> +/* TODO: change this to .machine power8 when the minimum required binutils
> + allows it. */
> + .machine power7
> +ENTRY (MEMCHR)
... I think this function is a candidate for the new ENTRY_TOCLESS.
--
Tulio Magno