This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] x86-64: Optimize strlen/strnlen/wcslen/wcsnlen with 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:32:41 -0700
- Subject: Re: [PATCH] x86-64: Optimize strlen/strnlen/wcslen/wcsnlen with AVX2
- Authentication-results: sourceware.org; auth=none
- References: <20170601181242.GA28627@lucon.org> <CAMe9rOqk9YJxVAmbZN3x2=DoJB1BuMJ=XW-beUO0y_ORdPd3zA@mail.gmail.com>
On Fri, Jun 2, 2017 at 12:48 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Jun 1, 2017 at 11:12 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>> Optimize strlen/strnlen/wcslen/wcsnlen with AVX2 to check 32 bytes with
>> a single vector compare instruction. It is as fast as SSE2 versions for
>> size <= 16 bytes and up to 1X faster for or size > 16 bytes on Haswell.
>> Select AVX2 version on AVX2 machines where vzeroupper is preferred and
>> AVX unaligned load is fast.
>>
>> NB: It uses TZCNT instead of BSF since TZCNT produces the same result
>> as BSF for non-zero input. TZCNT is faster than BSF and is executed
>> as BSF if machine doesn't support TZCNT.
>>
>> Any comments?
>>
>> H.J.
>> ---
>> * sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
>> strlen-avx2, strnlen-avx2 and wcslen-avx2 and wcsnlen-avx2.
>> * sysdeps/x86_64/multiarch/ifunc-impl-list.c
>> (__libc_ifunc_impl_list): Add tests for __strlen_avx2,
>> __strlen_sse2, __strnlen_avx2, __strnlen_sse2, __wcslen_avx2,
>> __wcslen_sse2, __wcsnlen_avx2 and __wcsnlen_sse2.
>> * sysdeps/x86_64/multiarch/strlen-avx2.S: New file.
>> * sysdeps/x86_64/multiarch/strlen.S: Likewise.
>> * sysdeps/x86_64/multiarch/strnlen-avx2.S: Likewise.
>> * sysdeps/x86_64/multiarch/strnlen.S: Likewise.
>> * sysdeps/x86_64/multiarch/wcslen-avx2.S: Likewise.
>> * sysdeps/x86_64/multiarch/wcslen.S: Likewise.
>> * sysdeps/x86_64/multiarch/wcsnlen-avx2.S: Likewise.
>> * sysdeps/x86_64/multiarch/wcsnlen.S: Likewise.
>
> Updated patch with IFUNC selector in C.
>
>
I will check it in.
--
H.J.