<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] Vectorize loops that have phi uses outside a read-only loop"
   href="https://bugs.llvm.org/show_bug.cgi?id=38410">38410</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[LV] Vectorize loops that have phi uses outside a read-only 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>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>anna@azul.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Today we fail vectorization when we have a phi that's not one of the following:
1. reduction PHI
2. induction PHI
3. first order recurrence

Basically, such phis have uses outside the loop and it's hard to identify
*which* iteration out of the vectorization-factor number of iterations is the
one we're interested in. 

Loop characteristics which allow us to handle phis used outside the loop:
1. read-only loop
2. only exiting block is the latch block
3. phis used outside the loop are generated in the latch block

Given these conditions (each of which is needed for legally doing the transform
I'm describing!), we can teach the loop vectorizer to vectorize the read-only
loop and extract the last element from the <PHI1, PHI2,..PHI VF> for use
outside the loop. Note that we'll need to handle the case where the loop trip
count is not exact multiple of VF, but I believe that's details we can chalk
out: the post loop for handling extra iterations (tripCount mod VF) also needs
the phi use to be handled.

There might be a problem if we were to "over-vectorize" the loop because it's a
read-only loop, i.e. the element to be extracted from the phi-vector need not
be the last one, but the last one where the loop termination condition was
true. I think this is about generating the right set of vector instructions.</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>