[PATCH] x86-64: Optimize strlen/strnlen/wcslen/wcsnlen with AVX2
H.J. Lu
hjl.tools@gmail.com
Fri Jun 2 19:48:00 GMT 2017
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.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-x86-64-Optimize-strlen-strnlen-wcslen-wcsnlen-with-A.patch
Type: text/x-patch
Size: 26364 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170602/ad2a1cff/attachment.bin>
More information about the Libc-alpha
mailing list