<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 asserts trying to insert instructions at a catchswitch"
   href="https://llvm.org/bugs/show_bug.cgi?id=26373">26373</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LSR asserts trying to insert instructions at a catchswitch
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>andrew.kaylor@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=15753" name="attach_15753" title="small reproducer">attachment 15753</a> <a href="attachment.cgi?id=15753&action=edit" title="small reproducer">[details]</a></span>
small reproducer

I've come across a case where an assertion fires in the loop strength reduction
pass because the instruction selected for an insertion point is a catchswitch
statement.  In the failing test case, LSR is trying to replace a PHI node
(which happens to be in a catchswitch statement) and two of the incoming blocks
for this PHI node are catchswitch blocks.  LSR does not currently attempt to
handle this case.

LSRInstance::RewriteForPHI() selects PN->getIncomingBlock(i)->getTerminator()
-- a catchswitch statement in the failing case -- as the insertion point and
calls LSRInstance::Expand() which in turn calls
LSRInstance::AdjustInsertPositionForExpand(), which is where the assertion
occurs.

  assert(!isa<PHINode>(LowestIP) && !LowestIP->isEHPad()
         && !isa<DbgInfoIntrinsic>(LowestIP) &&
         "Insertion point must be a normal instruction");

[at LoopStrengthReduce.cpp, line 4419 in r255921 of that file]

I used bugpoint to reduce the failing case and have attached the resulting IR
file.  You should be able to reproduce the problem by running:

  opt -loop-reduce lsr-catchswitch-insert.ll</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>