<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 - [LV] predicated strided loads vectorized as interleave-group without masking"
   href="https://bugs.llvm.org/show_bug.cgi?id=39099">39099</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[LV] predicated strided loads vectorized as interleave-group without masking
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </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>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dorit.nuzman@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20933" name="attach_20933" title="testcase">attachment 20933</a> <a href="attachment.cgi?id=20933&action=edit" title="testcase">[details]</a></span>
testcase

There’s a bug in how we currently handle predicated  strided loads -- we end up
vectorizing them without a mask... :

When strided loads are predicated, each of them will form an interleaved-group
(with gaps). However, subsequent stages of vectorization (planning and
transformation) assume that if a load is part of an Interleave-Group it is not
predicated, resulting in wrong code - unmasked wide loads are created.

Compiling the attached testcase with:
opt -loop-vectorize -enable-interleaved-mem-accesses -force-vector-width=8
-march=skx -S  predicated-interleaved-bug.ll

you'll see we happily generate unmasked wide-loads and shuffles:

vector.body:
...
  %wide.vec = load <16 x i8>, <16 x i8>* %5, align 1
  %strided.vec = shufflevector <16 x i8> %wide.vec, <16 x i8> undef, <8 x i32>
<i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14>
  %6 = or <8 x i32> %1, <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32
1>
...
  %wide.vec1 = load <16 x i8>, <16 x i8>* %10, align 1
  %strided.vec2 = shufflevector <16 x i8> %wide.vec1, <16 x i8> undef, <8 x
i32> <i32 0, i32 2, i32 4, i32 6, i32 8, i32 10, i32 12, i32 14>
...


The fix is simple - don’t allow analyzeInterleaving() open an interleave group
if the load/store is predicated. I'll upload the fix shortly.</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>