<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 - LoopVersioning asserts when a runtime check is not necessary"
   href="https://bugs.llvm.org/show_bug.cgi?id=52426">52426</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LoopVersioning asserts when a runtime check is not necessary
          </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>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>chang-sun.lin.jr@intel.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=25427" name="attach_25427" title="reproducer">attachment 25427</a> <a href="attachment.cgi?id=25427&action=edit" title="reproducer">[details]</a></span>
reproducer

In the attached testcase, LoopLoadElim unconditionally asks LoopVersioning to
add a runtime check, assuming that the check is optional. Unfortunately,
LoopVersioning will assert if the check is not needed. Should the assert just
be changed to return silently?

opt -loop-load-elim fail.ll

opt: llvm/llvm/lib/Transforms/Utils/LoopVersioning.cpp:88: void
llvm::LoopVersioning::versionLoop(const
llvm::SmallVectorImpl<llvm::Instruction*>&): Assertion `RuntimeCheck && "called
even though we don't need " "any runtime checks"' failed.
...
10 0x00007f989b41a607 llvm::LoopVersioning::versionLoop()
llvm/llvm/include/llvm/Transforms/Utils/LoopVersioning.h:63:0
#11 0x00007f989b416441 (anonymous
namespace)::LoadEliminationForLoop::processLoop()
llvm/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp:575:0
#12 0x00007f989b416899 eliminateLoadsAcrossLoops(llvm::Function&,
llvm::LoopInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*,
llvm::ProfileSummaryInfo*, llvm::ScalarEvolution*, llvm::AssumptionCache*,
llvm::function_ref<llvm::LoopAccessInfo const& (llvm::Loop&)>)
llvm/llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp:637:0</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>