<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 vectorizer causes crash when compiler -"
   href="https://bugs.llvm.org/show_bug.cgi?id=47308">47308</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Loop vectorizer causes crash when compiler -
          </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>normal
          </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>praharen@ualberta.ca
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>compile command:

./clang -Os -mllvm -force-vector-width=4 bug_test.c -S -emit-llvm -o bug_os.ll


source: 

bug_test.c

include <stdio.h>

int a;

int main(void) {

    int d = -1;

#pragma clang loop vectorize(assume_safety)
    for (int i = 0; i < 49; ++i) {
        a |= d;
        d = i;
    }

    return 0;
}


The issue is in LoopVectorize.cpp in
LoopVectorizationPlanner::collectTriviallyDeadInstructions. The induction phi
for variable 'c' is marked as dead code here as it is the only use of induction
phi 'd'. Maybe a fix would add a check to ensure the use is not a phi of a
different induction variable. The phi statement being marked as dead code means
it does not get a vectorization recipe and the vector loop body ends up
referring to the original scalar induction variable %c in the vector loop body.
But %c is not defined yet. This causes the assertion in
InnerLoopVectorizer::fixupIVUsers to fail: "Expected LCSSA form".</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>