This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] x86-64: Add memchr/rawmemchr/wmemchr optimized with SSE2/AVX2
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Fri, 9 Jun 2017 04:31:57 -0700
- Subject: Re: [PATCH] x86-64: Add memchr/rawmemchr/wmemchr optimized with SSE2/AVX2
- Authentication-results: sourceware.org; auth=none
- References: <20170601154423.GA14526@lucon.org> <CAMe9rOrFsJ+Nzo-UW_gNr_meXJ6GagoFqb5P8TeQMqKW5iG=bw@mail.gmail.com>
On Fri, Jun 2, 2017 at 12:47 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> 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.
I will check it in.
--
H.J.