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

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

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    llvm commit: 38389f3109e8
Reproduce with: ```opt -passes="loop(loop-interchange),loop-mssa(simple-loop-unswitch<nontrivial>)" bbi-75037.ll -S -o /dev/null -verify-scev```
Result:
```
Cached disposition of {null,+,8}<nuw><%for.body787.i> for loop Loop at depth 3 containing: %cont517.i<header>,%handler.pointer_overflow519.i,%cont520.i<latch><exiting>
 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=loop(loop-interchange),loop-mssa(simple-loop-unswitch<nontrivial>) bbi-75037.ll -S -o /dev/null -verify-scev
 #0 0x0000000002e68c43 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x2e68c43)
 #1 0x0000000002e6695e llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x2e6695e)
 #2 0x0000000002e68fc6 SignalHandler(int) (../../main-github/llvm/build-all/bin/opt+0x2e68fc6)
 #3 0x00007f4bd2d0b630 __restore_rt (/lib64/libpthread.so.0+0xf630)
 #4 0x00007f4bd0452387 raise (/lib64/libc.so.6+0x36387)
 #5 0x00007f4bd0453a78 abort (/lib64/libc.so.6+0x37a78)
 #6 0x0000000001e9fecc llvm::ScalarEvolution::verify() const (../../main-github/llvm/build-all/bin/opt+0x1e9fecc)
 #7 0x000000000381036b llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x381036b)
 #8 0x00000000031d6dfd llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x31d6dfd)
 #9 0x000000000265a96c llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x265a96c)
#10 0x0000000000aec92d 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>&) (../../main-github/llvm/build-all/bin/opt+0xaec92d)
#11 0x000000000265ec4e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x265ec4e)
#12 0x0000000000aec70d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0xaec70d)
#13 0x0000000002659c1c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x2659c1c)
#14 0x0000000000720919 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+0x720919)
#15 0x000000000072fde1 main (../../main-github/llvm/build-all/bin/opt+0x72fde1)
#16 0x00007f4bd043e555 __libc_start_main (/lib64/libc.so.6+0x22555)
#17 0x0000000000719580 _start (../../main-github/llvm/build-all/bin/opt+0x719580)
Abort
```
[bbi-75037.ll.gz](https://github.com/llvm/llvm-project/files/9849510/bbi-75037.ll.gz)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlWNtu4zYQ_Rr5hbBAUaIuD35wnBhddBcNNsG-GpREyWxp0SApZ9Ov75CyE8txtrkVvQWBZJPDmTNnjkYmS1Xfz6TcbVClNhthg3iO4jzOiyaOcMHzAF8GeP6Vb7Wq-4qjO2HXziZI8fCvthZNt8wYboL4MiBEKrUNSO5uU9FZrqs161oekCIgCz-6MYaBhRGbreRTP9R3BjxX4HrRqc5qsRNMBvGVX0VQWYppRnGchVKi6Q2aKhSQZc13cO16N7bjWjT3U1PB2AHaAbvppctr-Hoyu2DVmteoFmarjLBCdUg1KMgunFsAHJALuOZBdumg9XcOUwyjtFE6LIG8LM9CAaMIBpDLBX12F2ZRzbd2jWIgtrNMdKJrPXGEugEa-WWLNWc11z5T5xWoqiXX4VZ56lYK8mqkuqNRAebexK8m2K-WzHPmIPHvgN6FuBoSQ8Ig0VVKa175qlZDpt-YFqyz4AuxyvZMok_dbj_mF15_vprfXCHTlyAHxFDZt0jzrdIWWYXW1m6NI5Ms4b8FNfRlCNKBL05F-9sU5PKri0uWwpgepEGWCFJziGRfc2TXHFWamTUqWfWb1azi4RD-xsIAqvvN9qFkGKaKa61azTaI6bbf8M46ECgMwbG_bIDh6QDnEUrZC1lPmSvkshQdXMdq_WipvlKnQ50CEmOEv-PDH-FpXiUx8jkABfHc3Jvhw7UGlJ6gW8eYg_5gpNndShmrOYPMU1de4apcgP_8LTSB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