<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 - Assertion `SE->DT.dominates(ENT.ExitingBlock, Latch) && "We should only have known counts for exiting blocks that dominate " "latch!"' failed. with -iv-users -simple-loop-unswitch -indvars"
   href="https://bugs.llvm.org/show_bug.cgi?id=37651">37651</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion `SE->DT.dominates(ENT.ExitingBlock, Latch) && "We should only have known counts for exiting blocks that dominate " "latch!"' failed. with -iv-users -simple-loop-unswitch -indvars
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mikael.holmen@ericsson.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=20381" name="attach_20381" title="reduced reproducer">attachment 20381</a> <a href="attachment.cgi?id=20381&action=edit" title="reduced reproducer">[details]</a></span>
reduced reproducer

opt -iv-users -simple-loop-unswitch -indvars -S -o - bbi-14845.ll

gives

opt: ../lib/Analysis/ScalarEvolution.cpp:6728: const llvm::SCEV
*llvm::ScalarEvolution::BackedgeTakenInfo::getExact(const llvm::Loop *,
llvm::ScalarEvolution *, llvm::SCEVUnionPredicate *) const: Assertion
`SE->DT.dominates(ENT.ExitingBlock, Latch) && "We should only have known counts
for exiting blocks that dominate " "latch!"' failed.
Stack dump:
0.      Program arguments: build-all/bin/opt -iv-users -simple-loop-unswitch
-indvars -S -o - bbi-14845.ll 
1.      Running pass 'Function Pass Manager' on module 'bbi-14845.ll'.
2.      Running pass 'Loop Pass Manager' on function '@f1'
3.      Running pass 'Induction Variable Simplification' on basic block '%bb3'
#0 0x00000000021a48a4 PrintStackTraceSignalHandler(void*)
(build-all/bin/opt+0x21a48a4)
#1 0x00000000021a2b80 llvm::sys::RunSignalHandlers()
(build-all/bin/opt+0x21a2b80)
#2 0x00000000021a4c08 SignalHandler(int) (build-all/bin/opt+0x21a4c08)
#3 0x00007f44eec51330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007f44ed840c37 gsignal
/build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f44ed844028 abort
/build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f44ed839bf6 __assert_fail_base
/build/eglibc-ripdx6/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f44ed839ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x00000000017475b6
llvm::ScalarEvolution::BackedgeTakenInfo::getExact(llvm::Loop const*,
llvm::ScalarEvolution*, llvm::SCEVUnionPredicate*) const
(build-all/bin/opt+0x17475b6)
#9 0x0000000001f9ef1a (anonymous namespace)::IndVarSimplify::run(llvm::Loop*)
(build-all/bin/opt+0x1f9ef1a)
#10 0x0000000001fa44fc (anonymous
namespace)::IndVarSimplifyLegacyPass::runOnLoop(llvm::Loop*,
llvm::LPPassManager&) (build-all/bin/opt+0x1fa44fc)
#11 0x00000000016d0885 llvm::LPPassManager::runOnFunction(llvm::Function&)
(build-all/bin/opt+0x16d0885)
#12 0x0000000001c2567a llvm::FPPassManager::runOnFunction(llvm::Function&)
(build-all/bin/opt+0x1c2567a)
#13 0x0000000001c258d8 llvm::FPPassManager::runOnModule(llvm::Module&)
(build-all/bin/opt+0x1c258d8)
#14 0x0000000001c25e0d llvm::legacy::PassManagerImpl::run(llvm::Module&)
(build-all/bin/opt+0x1c25e0d)
#15 0x000000000077058c main (build-all/bin/opt+0x77058c)
#16 0x00007f44ed82bf45 __libc_start_main
/build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#17 0x0000000000759a5d _start (build-all/bin/opt+0x759a5d)
Abort

This started happening with commit r328611:

    [SCEV] Make exact taken count calculation more optimistic

    Currently, `getExact` fails if it sees two exit counts in different blocks.
There is
    no solid reason to do so, given that we only calculate exact non-taken
count
    for exiting blocks that dominate latch. Using this fact, we can simply take
min
    out of all exits of all blocks to get the exact taken count.

    This patch makes the calculation more optimistic with enforcing our
assumption
    with asserts. It allows us to calculate exact backedge taken count in
trivial loops
    like

      for (int i = 0; i < 100; i++) {
        if (i > 50) break;
        . . .
      }

    Differential Revision: <a href="https://reviews.llvm.org/D44676">https://reviews.llvm.org/D44676</a>
    Reviewed By: fhahn


    git-svn-id: <a href="https://llvm.org/svn/llvm-project/llvm/trunk@328611">https://llvm.org/svn/llvm-project/llvm/trunk@328611</a>
91177308-0d34-0410-b5e6-96231b3b80d8

Found when running random passes on random input. We don't normally use
-iv-users -simple-loop-unswitch.</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>