]> git.ipfire.org Git - thirdparty/glibc.git/commit
x86-64: Improve EVEX strcmp with masked load
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 29 Oct 2021 19:40:20 +0000 (12:40 -0700)
committerSunil K Pandey <skpgkp2@gmail.com>
Mon, 2 May 2022 20:01:21 +0000 (13:01 -0700)
commit1a7af4e140f0e8e4633a5938a804d429e9a82d52
treee0094cefb6b9dab9d4af949321cda5e833f56e0c
parent4df7e006ecc4a64a3af81b4ed7361124ec4a097f
x86-64: Improve EVEX strcmp with masked load

In strcmp-evex.S, to compare 2 32-byte strings, replace

        VMOVU   (%rdi, %rdx), %YMM0
        VMOVU   (%rsi, %rdx), %YMM1
        /* Each bit in K0 represents a mismatch in YMM0 and YMM1.  */
        VPCMP   $4, %YMM0, %YMM1, %k0
        VPCMP   $0, %YMMZERO, %YMM0, %k1
        VPCMP   $0, %YMMZERO, %YMM1, %k2
        /* Each bit in K1 represents a NULL in YMM0 or YMM1.  */
        kord    %k1, %k2, %k1
        /* Each bit in K1 represents a NULL or a mismatch.  */
        kord    %k0, %k1, %k1
        kmovd   %k1, %ecx
        testl   %ecx, %ecx
        jne     L(last_vector)

with

        VMOVU   (%rdi, %rdx), %YMM0
        VPTESTM %YMM0, %YMM0, %k2
        /* Each bit cleared in K1 represents a mismatch or a null CHAR
           in YMM0 and 32 bytes at (%rsi, %rdx).  */
        VPCMP   $0, (%rsi, %rdx), %YMM0, %k1{%k2}
        kmovd   %k1, %ecx
        incl    %ecx
        jne     L(last_vector)

It makes EVEX strcmp faster than AVX2 strcmp by up to 40% on Tiger Lake
and Ice Lake.

Co-Authored-By: Noah Goldstein <goldstein.w.n@gmail.com>
(cherry picked from commit c46e9afb2df5fc9e39ff4d13777e4b4c26e04e55)
sysdeps/x86_64/multiarch/strcmp-evex.S