This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] x86-64: Optimize strlen/strnlen/wcslen/wcsnlen with AVX2


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]