<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 - [LICM] loads hoisted out of vectorized loop but not from scalar loop."
   href="https://bugs.llvm.org/show_bug.cgi?id=39989">39989</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[LICM]  loads hoisted out of vectorized loop but not from scalar loop.
          </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>Loop Optimizer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>paulsson@linux.vnet.ibm.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=21218" name="attach_21218" title="reduced testcase">attachment 21218</a> <a href="attachment.cgi?id=21218&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase

I found a few cases of a loop with loads from loop-invariant addresses that get
vectorized. I am not sure why, but the loads in the vectorized loop get hoisted
by LICM, while those in the scalar loop remain inside the loop.

I wonder why that is - is this a known issue/behaviour or is this something to
be fixed in LICM?

Attached is a reduced test case which is not perfect, but at least has this
behaviour well exhibited in vector.body and (the original scalar) bb27.us.i
loops.

clang -cc1 -triple s390x-ibm-linux -S -save-temps=cwd -fmath-errno -target-cpu
z13 -v -O3 -w -vectorize-loops -vectorize-slp -o out.ll -emit-llvm
tc_licm_vec_scal.ll -mllvm -unroll-count=1</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>