[llvm-bugs] [Bug 30986] New: [X86][SSE] Failure to split vector loads for scalarized operations

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 11 08:35:14 PST 2016


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: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: llvm-bugs at lists.llvm.org, mkuper at google.com,
                    spatel+llvm at rotateright.com, zvi.rackover at intel.com
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161111/5b1e5ddd/attachment.html>


More information about the llvm-bugs mailing list