https://llvm.org/bugs/show_bug.cgi?id=30986

            Bug ID: 30986
           Summary: [X86][SSE] Failure to split vector loads for
                    scalarized operations
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]
    Classification: Unclassified

As discussed on https://reviews.llvm.org/D26521.

Scalarized cases fail to split any vector loads, resulting in a lot of extra
(potentially very slow) vector -> gpr traffic:

clang -S -O3 -march=btver2

#include <x86intrin.h>

__m128i popcnt1(__m128i *in) {
  return (__m128i) {
    __builtin_popcountll(in[0][0]),
    __builtin_popcountll(in[0][1]) };
}

popcnt1(long long __vector(2)*):
        vmovdqu (%rdi), %xmm0
        vmovq   %xmm0, %rax
        vpextrq $1, %xmm0, %rcx
        popcntq %rax, %rax
        popcntq %rcx, %rcx
        vmovq   %rcx, %xmm0
        vmovq   %rax, %xmm1
        vpunpcklqdq     %xmm0, %xmm1, %xmm0 # xmm0 = xmm1[0],xmm0[0]
        retq

It would be better as:

popcnt1(long long __vector(2)*):
        popcntq (%rdi), %rax
        popcntq 8(%rdi), %rcx
        vmovq   %rcx, %xmm0
        vmovq   %rax, %xmm1
        vpunpcklqdq     %xmm0, %xmm1, %xmm0 # xmm0 = xmm1[0],xmm0[0]
        retq

Something similar happens when the source vector is spilled - it is first
restored to a vector register and then transferred to gprs. In some cases after
the results are transferred back to the vector register and then spilled again
- we could have spilled the scalar values in vector order directly...

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to