<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - [SLPVectorizer] Failure to vectorize extract from two vectors"
   href="https://bugs.llvm.org/show_bug.cgi?id=43882">43882</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[SLPVectorizer] Failure to vectorize extract from two vectors
          </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>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>lebedev.ri@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Stumbling into this while analyzing <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [SLPVectorizer] Vectorization of non-consecutive loads"
   href="show_bug.cgi?id=43844">https://bugs.llvm.org/show_bug.cgi?id=43844</a>

<a href="https://godbolt.org/z/a5HeXw">https://godbolt.org/z/a5HeXw</a>

  %3 = getelementptr inbounds %"struct.std::array", %"struct.std::array"* %0,
i64 0, i32 0, i64 0
  %4 = bitcast %"struct.std::array.0"* %1 to <4 x i32>*
  %5 = load <4 x i32>, <4 x i32>* %4, align 8, !tbaa !2
  %6 = extractelement <4 x i32> %5, i32 0
  store i32 %6, i32* %3, align 4, !tbaa !2
  %7 = getelementptr inbounds %"struct.std::array", %"struct.std::array"* %0,
i64 0, i32 0, i64 2
  %8 = extractelement <4 x i32> %5, i32 1
  store i32 %8, i32* %7, align 4, !tbaa !2
  %9 = getelementptr inbounds %"struct.std::array", %"struct.std::array"* %0,
i64 0, i32 0, i64 4
  %10 = extractelement <4 x i32> %5, i32 2
  store i32 %10, i32* %9, align 4, !tbaa !2
  %11 = getelementptr inbounds %"struct.std::array", %"struct.std::array"* %0,
i64 0, i32 0, i64 6
  %12 = extractelement <4 x i32> %5, i32 3
  store i32 %12, i32* %11, align 4, !tbaa !2
  %13 = getelementptr inbounds %"struct.std::array.0", %"struct.std::array.0"*
%1, i64 0, i32 0, i64 4
  %14 = getelementptr inbounds %"struct.std::array", %"struct.std::array"* %0,
i64 0, i32 0, i64 1
  %15 = bitcast i32* %13 to <4 x i32>*
  %16 = load <4 x i32>, <4 x i32>* %15, align 8, !tbaa !2
  %17 = extractelement <4 x i32> %16, i32 0
  store i32 %17, i32* %14, align 4, !tbaa !2
  %18 = getelementptr inbounds %"struct.std::array", %"struct.std::array"* %0,
i64 0, i32 0, i64 3
  %19 = extractelement <4 x i32> %16, i32 1
  store i32 %19, i32* %18, align 4, !tbaa !2
  %20 = getelementptr inbounds %"struct.std::array", %"struct.std::array"* %0,
i64 0, i32 0, i64 5
  %21 = extractelement <4 x i32> %16, i32 2
  store i32 %21, i32* %20, align 4, !tbaa !2
  %22 = getelementptr inbounds %"struct.std::array", %"struct.std::array"* %0,
i64 0, i32 0, i64 7
  %23 = extractelement <4 x i32> %16, i32 3
  store i32 %23, i32* %22, align 4, !tbaa !2


I.e. e.g. the stores are fed by:
  [  %6 = extractelement <4 x i32> %5, i32 0;  %17 = extractelement <4 x i32>
%16, i32 0;  %8 = extractelement <4 x i32> %5, i32 1;  %19 = extractelement <4
x i32> %16, i32 1]
and so on.

This can be represented as a shuffle:  <a href="https://godbolt.org/z/KfWvCe">https://godbolt.org/z/KfWvCe</a>

  %3 = bitcast %"struct.std::array.0"* %1 to <4 x i32>*
  %4 = load <4 x i32>, <4 x i32>* %3, align 8, !tbaa !2
  %5 = getelementptr inbounds %"struct.std::array", %"struct.std::array"* %0,
i64 0, i32 0, i64 4
  %6 = getelementptr inbounds %"struct.std::array.0", %"struct.std::array.0"*
%1, i64 0, i32 0, i64 4
  %7 = bitcast i32* %6 to <4 x i32>*
  %8 = load <4 x i32>, <4 x i32>* %7, align 8, !tbaa !2
  %9 = shufflevector <4 x i32> %4, <4 x i32> %8, <4 x i32> <i32 0, i32 4, i32
1, i32 5>
  %10 = bitcast %"struct.std::array"* %0 to <4 x i32>*
  store <4 x i32> %9, <4 x i32>* %10, align 4, !tbaa !2
  %11 = shufflevector <4 x i32> %4, <4 x i32> %8, <4 x i32> <i32 2, i32 6, i32
3, i32 7>
  %12 = bitcast i32* %5 to <4 x i32>*
  store <4 x i32> %11, <4 x i32>* %12, align 4, !tbaa !2</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>