[PATCH] x86-64: Add memchr/rawmemchr/wmemchr optimized with SSE2/AVX2

H.J. Lu hjl.tools@gmail.com
Fri Jun 2 19:47:00 GMT 2017


On Thu, Jun 1, 2017 at 8:44 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> SSE2 memchr is extended to support wmemchr.  AVX2 memchr/rawmemchr/wmemchr
> are added to search 32 bytes with a single vector compare instruction.
> AVX2 memchr/rawmemchr/wmemchr are as fast as SSE2 memchr/rawmemchr/wmemchr
> for small sizes and up to 1.5X faster for larger sizes on Haswell and
> Skylake.  Select AVX2 memchr/rawmemchr/wmemchr on AVX2 machines where
> vzeroupper is preferred and AVX unaligned load is fast.
>
> Any comments?
>
> H.J.
> ---
>         * sysdeps/x86_64/memchr.S (MEMCHR): New.  Depending on if
>         USE_AS_WMEMCHR is defined.
>         (PCMPEQ): Likewise.
>         (memchr): Renamed to ...
>         (MEMCHR): This.  Support wmemchr if USE_AS_WMEMCHR is defined.
>         Replace pcmpeqb with PCMPEQ.
>         * sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
>         memchr-avx2, rawmemchr-avx2 and wmemchr-avx2.
>         * sysdeps/x86_64/multiarch/ifunc-impl-list.c
>         (__libc_ifunc_impl_list): Test __memchr_avx2, __memchr_sse2,
>         __rawmemchr_avx2, __rawmemchr_sse2, __wmemchr_avx2 and
>         __wmemchr_sse2.
>         * sysdeps/x86_64/multiarch/memchr-avx2.S: New file.
>         * sysdeps/x86_64/multiarch/memchr.S: Likewise.
>         * sysdeps/x86_64/multiarch/rawmemchr-avx2.S: Likewise.
>         * sysdeps/x86_64/multiarch/rawmemchr.S: Likewise.
>         * sysdeps/x86_64/multiarch/wmemchr-avx2.S: Likewise.
>         * sysdeps/x86_64/multiarch/wmemchr.S: Likewise.
>         * sysdeps/x86_64/wmemchr.S: Likewise.

Updated patch to implement IFUNC selector in C.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-x86-64-Optimize-memchr-rawmemchr-wmemchr-with-SSE2-A.patch
Type: text/x-patch
Size: 29104 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170602/3260ab43/attachment.bin>


More information about the Libc-alpha mailing list