[PATCH] x86-64: Add memcmp/wmemcmp optimized with AVX2

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


On Thu, Jun 1, 2017 at 11:17 PM, Florian Weimer <fweimer@redhat.com> wrote:
> On 06/02/2017 12:29 AM, H.J. Lu wrote:
>> +     /* Use overlapping loads and bswap to avoid branches.  */
>
> This comment is outdated.  I think the commit message needs a bit of
> rewording, too.

Here is the patch with the updated comments and commit message.

> Have you benchmarked this version against the original one?
>
>> +     HAS_ARCH_FEATURE (Prefer_No_VZEROUPPER)
>> +     jnz     1f
>> +     HAS_ARCH_FEATURE (AVX2_Usable)
>> +     jz      1f
>> +     HAS_CPU_FEATURE (MOVBE)
>> +     jz      1f
>> +     HAS_ARCH_FEATURE (AVX_Fast_Unaligned_Load)
>> +     jz      1f
>> +     leaq    __memcmp_avx2_movbe(%rip), %rax
>> +     ret
>
> Do the IFUNC resolvers have to check for the BMI feature, too?
>

No.  It is't needed 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.


-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-x86-64-Optimize-memcmp-wmemcmp-with-AVX2-and-MOVBE.patch
Type: text/x-patch
Size: 16766 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170602/cf41efd0/attachment.bin>


More information about the Libc-alpha mailing list