[llvm-bugs] [Bug 40716] New: Missed opportunity vectorization with __uint128_t

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 13 04:26:16 PST 2019


            Bug ID: 40716
           Summary: Missed opportunity vectorization with __uint128_t
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: gchatelet at google.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Bitwise operations on __uint128_t do not take advantage of vector operations:

__uint128_t xor_512_128(const __uint128_t* a, const __uint128_t* b) {
    return (a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]);

xor_512_128(unsigned __int128 const*, unsigned __int128 const*):
        mov     rax, qword ptr [rsi]
        mov     rdx, qword ptr [rsi + 8]
        xor     rdx, qword ptr [rdi + 8]
        xor     rax, qword ptr [rdi]
        mov     r8, qword ptr [rsi + 16]
        mov     rcx, qword ptr [rsi + 24]
        xor     rcx, qword ptr [rdi + 24]
        or      rcx, rdx
        xor     r8, qword ptr [rdi + 16]
        or      r8, rax
        mov     r9, qword ptr [rsi + 40]
        mov     r10, qword ptr [rsi + 32]
        xor     r10, qword ptr [rdi + 32]
        xor     r9, qword ptr [rdi + 40]
        mov     rax, qword ptr [rsi + 48]
        mov     rdx, qword ptr [rsi + 56]
        xor     rdx, qword ptr [rdi + 56]
        or      rdx, r9
        or      rdx, rcx
        xor     rax, qword ptr [rdi + 48]
        or      rax, r10
        or      rax, r8

Whereas uint64_t do vectorize

__uint128_t xor_512_64(const uint64_t* a, const uint64_t* b) {
    return (a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
           (a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7]);

xor_512_64(unsigned long const*, unsigned long const*):
        vmovdqu ymm0, ymmword ptr [rsi]
        vmovdqu ymm1, ymmword ptr [rsi + 32]
        vpxor   ymm1, ymm1, ymmword ptr [rdi + 32]
        vpxor   ymm0, ymm0, ymmword ptr [rdi]
        vpor    ymm0, ymm0, ymm1
        vextracti128    xmm1, ymm0, 1
        vpor    xmm0, xmm0, xmm1
        vpshufd xmm1, xmm0, 78          # xmm1 = xmm0[2,3,0,1]
        vpor    xmm0, xmm0, xmm1
        vmovq   rax, xmm0
        xor     edx, edx


You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190213/c090159b/attachment.html>

More information about the llvm-bugs mailing list