<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - SLP Vectorizer too aggressive with simple stores"
   href="https://llvm.org/bugs/show_bug.cgi?id=31116">31116</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SLP Vectorizer too aggressive with simple stores
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>matze@braunis.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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@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@GOTPCREL(%rip), %rax
    leaq    48(%rax), %rcx
    movq    %rcx, (%rdi)
    addq    $16, %rax
    movq    %rax, 8(%rdi)</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>