<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 --- - Missed forced vectorization due to llvm.mem.parallel_loop_access getting lost"
   href="https://llvm.org/bugs/show_bug.cgi?id=28981">28981</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missed forced vectorization due to llvm.mem.parallel_loop_access getting lost
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>opt
          </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>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=16953" name="attach_16953" title="Example loop with #pragma clang loop vectorize(assume_safety)">attachment 16953</a> <a href="attachment.cgi?id=16953&action=edit" title="Example loop with #pragma clang loop vectorize(assume_safety)">[details]</a></span>
Example loop with #pragma clang loop vectorize(assume_safety)

The following loop does not get vectorized because we lose some of the
information that is implied by "#pragma clang loop vectorize(assume_safety)":

void test(Complex *out, long size)
{
    long m = size / 2;
    #pragma clang loop vectorize(assume_safety)
    for (long offset = 0; offset < m; ++offset) {
      Complex t0 = out[offset];
      Complex t1 = out[offset+m];
      out[offset] = t0 + t1;
      out[offset+m] = t0 - t1;
    }
}

clang++ -S force-vect-test1.cpp -g -m64 -Ofast -funroll-loops -static
-mfpmath=sse -march=core-avx2 -Rpass-analysis=loop-vectorize
force-vect-test1.cpp:29:5: remark: loop not vectorized: cannot check memory
dependencies at runtime [-Rpass-analysis]
    for (long offset = 0; offset < m; ++offset) {
    ^
force-vect-test1.cpp:29:5: warning: loop not vectorized: failed explicitly
specified loop vectorization [-Wpass-failed]


By the time this loop reaches the vectorizer, some of the memory operations in
the loop don't have the llvm.mem.parallel_loop_access metadata, because:

1) clang does not annotate the memcpy that it creates in the loop with the
llvm.mem.parallel_loop_access metadata (this is PR28980)

2) Even if we annotate the memcpy manually, InstCombine later replaces it with
a ld/st and does not copy over the llvm.mem.parallel_loop_access metadata (this
is D23499)

3) later SROA does not preserve the llvm.mem.parallel_loop_access metadata
during its transformations (will upload a proposed patch 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>