<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 - [LSR] Assert in InsertFormula"
   href="https://bugs.llvm.org/show_bug.cgi?id=43480">43480</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[LSR] Assert in InsertFormula
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>sjoerd.meijer@arm.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=22590" name="attach_22590" title="reproducer">attachment 22590</a> <a href="attachment.cgi?id=22590&action=edit" title="reproducer">[details]</a></span>
reproducer

LSR is running in this assert:

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:3372: bool
{anonymous}::LSRInstance::InsertFormula({anonymous}::LSRUse&, unsigned int,
const {anonymous}::Formula&): Assertion `isLegalUse(TTI, LU.MinOffset,
LU.MaxOffset, LU.Kind, LU.AccessTy, F) && "Formula is illegal"' failed.
Stack dump:
0.      Program arguments: /data/monorepo/llvm-project/build/bin/llc sjoerd.ll 
1.      Running pass 'Function Pass Manager' on module 'sjoerd.ll'.
2.      Running pass 'Loop Pass Manager' on function '@fn1'
3.      Running pass 'Loop Strength Reduction' on basic block '%for.cond'



Running llc on the attached .ll file is enough to reproduce this.



Just for completeness, this .ll file corresponds to this creduced input file:

__fp16 *a;
void fn1() {
  for (int i; ; i++)
    foo(a[i]);
}</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>