<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58314>58314</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Cached disposition of [...] is incorrect: cached Variant, actual Invariant with -verify-scev and loop-deletion
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mikaelholmen
      </td>
    </tr>
</table>

<pre>
    llvm commit:
Reproduce with:```opt -passes="indvars,loop-deletion" bbi-74655.ll -o /dev/null -verify-scev```
Result:
```
Cached disposition of (true + %tobool2) for loop Loop at depth 2 containing: %for.cond1<header>,%if.then<exiting>,%for.cond1thread-pre-split<latch>
 is incorrect: cached Variant, actual Invariant
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: ../../main-github/llvm/build-all/bin/opt -passes=indvars,loop-deletion bbi-74655.ll -o /dev/null -verify-scev
 #0 0x0000000002e636e3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x2e636e3)
 #1 0x0000000002e613fe llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x2e613fe)
 #2 0x0000000002e63a66 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fa9b815f630 __restore_rt sigaction.c:0:0
 #4 0x00007fa9b58a6387 raise (/lib64/libc.so.6+0x36387)
 #5 0x00007fa9b58a7a78 abort (/lib64/libc.so.6+0x37a78)
 #6 0x0000000001e8f7dc llvm::ScalarEvolution::verify() const (../../main-github/llvm/build-all/bin/opt+0x1e8f7dc)
 #7 0x00000000037f1cdb llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x37f1cdb)
 #8 0x00000000031ceb0d llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) crtstuff.c:0:0
 #9 0x00000000026487dc llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x26487dc)
#10 0x0000000000ae93bd llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) crtstuff.c:0:0
#11 0x000000000264cabe llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x264cabe)
#12 0x0000000000ae919d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) crtstuff.c:0:0
#13 0x0000000002647a8c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x2647a8c)
#14 0x000000000071ffa9 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool) (../../main-github/llvm/build-all/bin/opt+0x71ffa9)
#15 0x0000000000730751 main (../../main-github/llvm/build-all/bin/opt+0x730751)
#16 0x00007fa9b5892555 __libc_start_main (/lib64/libc.so.6+0x22555)
#17 0x0000000000718cf0 _start (../../main-github/llvm/build-all/bin/opt+0x718cf0)
Abort
```
[bbi-74655.ll.gz](https://github.com/llvm/llvm-project/files/9764618/bbi-74655.ll.gz)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdWF1v4jgU_TXhxSLKB4mTBx6YtmhHO9VW02pekeM4wTsmjmyHaffX73USCqbQnZaOdrUVJeCPe8899_hiu5Dl01yI7QZRudlw48ULL7j2gsVX1ipZdpShH9ysbXMaDC_ZGjRtidZMe_G1F0W8KbdEaS-6ElK205IJZrhsoAcVBZ_iWZokvhBoKpEXLUu2hfemsw1bpnj1NNUU2nbmd-51J_ZojnqvCF2zEpVct1Jz6wzJCoxnRnUMnp_gPzGykFJEXpSjSipksaEv9o0YVLLWrFEEQTeG8IY3Nbiyk2CkD41l6MVXa0ZKprz4BiKDLl75Zs0a6GCP4NNOGXueJ5m1gjnTVrGpboVl80oQQ9d2ZA8ccY14Q6VSjNroEB0i-UYUJ40Bc4hQ0xGBPjfbsa2fePflZnF_g3RXQJIQQUVXI8VaqQwyEq2NabUlK1rCq4aEdQUg2sAXm9vxAbjkn9ZvtORad5C-aIlIU1pEoisZgvAQVUSvUUHod6MIZf7g_t5AAyq7TfuckgC68jsla0U2iKi627DGWBDI98Fw_7YBbqcDnD2UouOinBIh7GcOMlm6ijojp7doaeDai-IABY_B7i9iaZyyGPU4IIx4oZ_08OFO8cb0QT7YqEFJ-0GK_FhJbSCzgD61KeI2U7nV23tCBXkGjyMWMLMHGx6BDeOKnQL7tWvued0Q8RskTzBLVfYBeKw7B090TB5JU-R4Bo8jF0Oz9mlrFRL0_8-G4tEQrkheZGFSpZCY1UoxbaRiK9Cw5jXoHrLs05fTZ4fTk4ykcYaRIlzbpZ7Z6HiRzoYn9bX00z6k2I5zAkqODGGCM0QKu4heNWTHOYbSQ2ZCllW4pAeZuqdEEHWzlaLrC2HfOOhzTBVUC20uStjo1YGFD2HFuAppWRzAWnZNz_GDtGX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