<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 - [loop vectorize] failure to vectorize after GVN load-pre"
   href="https://bugs.llvm.org/show_bug.cgi?id=39235">39235</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[loop vectorize] failure to vectorize after GVN load-pre
          </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>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>mpfergu@gmail.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=20981" name="attach_20981" title="test showing the problem">attachment 20981</a> <a href="attachment.cgi?id=20981&action=edit" title="test showing the problem">[details]</a></span>
test showing the problem

I'm seeing an issue where adding !noalias metadata seems to prevents loop
vectorization from occurring. The issue seems to be that GVN does a PRE of a
load and this prevents the loop vectorizer from functioning.

See the attached .ll file. Supposing it's named opt-me.ll, to reproduce you can
do this:

 opt -O3 -loop-vectorize -force-vector-width=4 -force-vector-interleave=1
opt-me.ll -S 

Result:

 remark: <unknown>:0:0: loop not vectorized: value that could not be identified
as reduction is used outside the loop
remark: <unknown>:0:0: loop not vectorized: value that could not be identified
as reduction is used outside the loop
 -> loop not vectorized

Compare with

opt -O3 -loop-vectorize -force-vector-width=4 -force-vector-interleave=1
-enable-load-pre=false opt-me.ll -S

 -> loop is vectorized, I see 4 x i32, extractelements, and no loop not
vectorized remarks.

If you remove the !noalias metadata from opt-me.ll, vectorization occurs
whether or not -enable-load-pre=false is passed. This seems unfortunate, as
front-ends would like to provide !noalias metadata where possible to improve
(and not hinder!) optimization.

I believe this problem is present in LLVM 6 as well as master.</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>