[llvm-bugs] [Bug 31116] New: SLP Vectorizer too aggressive with simple stores

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 22 10:15:21 PST 2016


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

            Bug ID: 31116
           Summary: SLP Vectorizer too aggressive with simple stores
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: matze at braunis.de
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

In a situation like the following (modeled after what happens in a C++
constructor with two base classes), the SLP vectorizer seems too aggressive:

struct C {
  char *BaseA;
  char *BaseB;
};
extern char VTab[];
void initC(C *c) {
  c->BaseA = VTab + 48;
  c->BaseB = VTab + 16;
}

The SLP Vectorizer transforms:

  %BaseA = getelementptr inbounds %struct.C, %struct.C* %c, i64 0, i32 0
  store i8* getelementptr inbounds ([0 x i8], [0 x i8]* @VTab, i64 0, i64 48),
i8** %BaseA, align 8, !tbaa !2
  %BaseB = getelementptr inbounds %struct.C, %struct.C* %c, i64 0, i32 1
  store i8* getelementptr inbounds ([0 x i8], [0 x i8]* @VTab, i64 0, i64 16),
i8** %BaseB, align 8, !tbaa !7

into:

  %BaseA = getelementptr inbounds %struct.C, %struct.C* %c, i64 0, i32 0
  %BaseB = getelementptr inbounds %struct.C, %struct.C* %c, i64 0, i32 1
  %0 = bitcast i8** %BaseA to <2 x i8*>*
  store <2 x i8*> <i8* getelementptr inbounds ([0 x i8], [0 x i8]* @VTab, i64
0, i64 48), i8* getelementptr inbounds ([0 x i8], [0 x i8]* @VTab, i64 0, i64
16)>, <2 x i8*>* %0, align 8, !tbaa !2
  ret void

which results in this code on X86:

      movq    _VTab at GOTPCREL(%rip), %rax
    leaq    16(%rax), %rcx
    movd    %rcx, %xmm0
    addq    $48, %rax
    movd    %rax, %xmm1
    punpcklqdq    %xmm0, %xmm1    ## xmm1 = xmm1[0],xmm0[0]
    movdqu    %xmm1, (%rdi)

while it can be this if the SLP Vectorizer doesn't do anything:

    movq    _VTab at GOTPCREL(%rip), %rax
    leaq    48(%rax), %rcx
    movq    %rcx, (%rdi)
    addq    $16, %rax
    movq    %rax, 8(%rdi)

-- 
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/20161122/98e21fb7/attachment.html>


More information about the llvm-bugs mailing list