<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 - [SLP] Failure to vectorize interleaving of elements from two vector loads"
   href="https://bugs.llvm.org/show_bug.cgi?id=45077">45077</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[SLP] Failure to vectorize interleaving of elements from two vector loads
          </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>#include <array>

std::array<uint16_t, 16>
zz(const uint16_t*const row0, const uint16_t*const row1) {
    std::array<uint16_t, 16> baseline;

    // Preload the entire block from last two rows.
    std::array<std::array<uint16_t, 16>, 2> prev;
    for (int c = 0; c < 16; ++c)
      prev[1][c] = row0[c];
    for (int c = 0; c < 16; ++c)
      prev[0][c] = row1[c];

    // The differences are specified as compared to the pixels of the previous
    // row for even pixels, or to pixels from two rows above for odd pixels.
    for (int c = 0; c < 16; ++c)
      baseline[c] = prev[c & 1][c];

    return baseline;
}

Currently results in rather scalar code, however i believe this should
vectorize into *something* like

define <16 x i16> @zz(<16 x i16>* %line0, <16 x i16>* %line1) {
    %l0data = load <16 x i16>, <16 x i16>* %line0
    %l1data = load <16 x i16>, <16 x i16>* %line1
    %res = shufflevector <16 x i16> %l0data, <16 x i16> %l1data,
                         <16 x i32> <i32 0, i32 17, i32 2, i32 19, i32 4, i32
21, i32 6, i32 23, i32 8, i32 25, i32 10, i32 27, i32 12, i32 29, i32 14, i32
31>
    ret <16 x i16> %res
}

<a href="https://godbolt.org/z/Pj7XkH">https://godbolt.org/z/Pj7XkH</a></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>