[LLVMbugs] [Bug 23510] New: cost model of slp vectorizer needs to be architecture aware

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 12 18:52:35 PDT 2015


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

            Bug ID: 23510
           Summary: cost model of slp vectorizer needs to be architecture
                    aware
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: wmi at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 14318
  --> https://llvm.org/bugs/attachment.cgi?id=14318&action=edit
testcase 1.cc

For the testcase 1.cc attached, on x86, 

~/workarea/llvm-r236609/build/bin/clang++ -O2 -std=c++11
-fno-omit-frame-pointer  -fno-exceptions -fno-omit-frame-pointer
-fno-strict-aliasing -funsigned-char -S 1.cc

In func _Z8DistanceIlLi5EEvPfiPmS0_:
Without slp:
        movq    $5, (%rdx)
        movslq  %esi, %rax
        leaq    (%rdi,%rax,4), %r8
        movss   20(%rdi,%rax,4), %xmm0  # xmm0 = mem[0],zero,zero,zero
        addss   12(%rcx), %xmm0
        movss   %xmm0, 12(%rcx)
        movq    (%rdx), %rdi
        movq    %rdi, %rsi
        shrq    $5, %rdi
        movq    %rdi, (%rdx)
        shrq    $5, 8(%rdx)
        shrq    $5, 16(%rdx)
        shrq    $3, %rsi
        shrq    $5, 24(%rdx)
        leaq    (%r8,%rax,4), %rax
        andl    $20, %esi
        movss   (%rsi,%rax), %xmm0      # xmm0 = mem[0],zero,zero,zero
        addss   (%rcx), %xmm0
        movss   %xmm0, (%rcx)
        retq

With slp:
        movq    $5, (%rdx)
        movslq  %esi, %rax
        leaq    (%rdi,%rax,4), %r8
        movss   20(%rdi,%rax,4), %xmm0  # xmm0 = mem[0],zero,zero,zero
        addss   12(%rcx), %xmm0
        movss   %xmm0, 12(%rcx)
        movq    (%rdx), %rdi
        movq    %rdi, %rsi
        shrq    $3, %rsi
        shrq    $5, %rdi
        movq    %rdi, (%rdx)
        movdqu  8(%rdx), %xmm0
        psrlq   $5, %xmm0
        movdqu  %xmm0, 8(%rdx)
        shrq    $5, 24(%rdx)
        leaq    (%r8,%rax,4), %rax
        andl    $20, %esi
        movss   (%rsi,%rax), %xmm0      # xmm0 = mem[0],zero,zero,zero
        addss   (%rcx), %xmm0
        movss   %xmm0, (%rcx)
        retq

slp vectorizer convert the following 
        shrq    $5, 8(%rdx)
        shrq    $5, 16(%rdx)
to:
        movdqu  8(%rdx), %xmm0
        psrlq   $5, %xmm0
        movdqu  %xmm0, 8(%rdx)

The cost of latter is higher than the former. psrlq does't support the form:
psrlq $5, 8(%rdx) but slp cost model is not aware of it.

Turning off slp vectorizer improved a benchmark by 10%.

-- 
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/20150513/a22f9960/attachment.html>


More information about the llvm-bugs mailing list