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

    <tr>
        <th>Summary</th>
        <td>
            Cached disposition of [...]  is incorrect: cached Variant, actual Invariant with indvars,loop-deletion and -verify-scev
        </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: 851669792f
Reproduce with: ```opt -verify-scev -passes="indvars,loop-deletion" bbi-74978.ll -S -o /dev/null```
Result:
```
Cached disposition of %reass.add15 for loop Loop at depth 2 containing: %for.body3<header><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 -verify-scev -passes=indvars,loop-deletion bbi-74978.ll -S -o /dev/null
 #0 0x0000000002e7a223 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x2e7a223)
 #1 0x0000000002e77f3e llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x2e77f3e)
 #2 0x0000000002e7a5a6 SignalHandler(int) (../../main-github/llvm/build-all/bin/opt+0x2e7a5a6)
 #3 0x00007f61c7145630 __restore_rt (/lib64/libpthread.so.0+0xf630)
 #4 0x00007f61c488c387 raise (/lib64/libc.so.6+0x36387)
 #5 0x00007f61c488da78 abort (/lib64/libc.so.6+0x37a78)
 #6 0x0000000001e9e39c llvm::ScalarEvolution::verify() const (../../main-github/llvm/build-all/bin/opt+0x1e9e39c)
 #7 0x000000000380e49b llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x380e49b)
 #8 0x00000000031e830d 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+0x31e830d)
 #9 0x00000000026586ac llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x26586ac)
#10 0x0000000000aec4fd 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+0xaec4fd)
#11 0x000000000265c98e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x265c98e)
#12 0x0000000000aec2dd 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+0xaec2dd)
#13 0x000000000265795c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x265795c)
#14 0x0000000000720d79 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+0x720d79)
#15 0x0000000000730241 main (../../main-github/llvm/build-all/bin/opt+0x730241)
#16 0x00007f61c4878555 __libc_start_main (/lib64/libc.so.6+0x22555)
#17 0x00000000007199e0 _start (../../main-github/llvm/build-all/bin/opt+0x7199e0)
Abort
```
[bbi-74978.ll.gz](https://github.com/llvm/llvm-project/files/9836009/bbi-74978.ll.gz)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlWNtu2zgQ_Rr5hbAgUfcHP7hJjA22xQZN0FeDEimbW1oUSMpt9ut3KMmJ6Nhpc1nszRBsSRzOnDlzNDJZSnq_EGK_Q5Xc7bjxoiXKkzBNi6zAtRdcesHyM2uVpF3F0DduttbCS4PhkK1B8z1TvL6f64rt0bwlWjPtRZcexryhe6K0hy-ElO2cMsEMlw2MoLLk8ywustwXAs1v0VwiD68o28N30wnxEOEAQXfCghsuj0YvSLVlFFGuW6m5DYFkDf4SxQCNTygNE1RLhSwM9NF-EYMoa80WYUi8MYQ3vNn0qeEELP0SeIm86GLLCGXKi67gXBBTbYdT9h3C2AlXAwLENeJNJZViVc9hNUD6QhQnjQEGEKlMRwS6bvbjvX7izcer5e0V0l0J5COCym6DFGulMshItDWm1TZrvIJjA-x3pQ-Fggtbs_FnDuX53cbFK651B-zjFSINtYhERxkyW4YqRfQWlaT6ahSpmD-EvzVwA9Fu1z5wG8BQcaPkRpEdImrT7VhjLAjk--C4_9oBX_MBziOUsuOCzgnUDs45VHn1jDrOSOPHuhjo9nAUoOB7cPhglhGMI9RDgUyipb7Xw8mN4o3p87yziXs4fzRS5NtaagMygQRSWyVui1WA__w12Xr4Q_B9xAJuHsGGR2CzOmKnwH7umlu-aYj4BeonmCUofwc8NpyDBx-Tl5AUOZEh4jtxAa6d2NEYO6vTsMrCOEmhluu1YtpIxdag_D7pleBlGg-_8KBCjaivpR_0fmuY4ziNp07jPK-iPEOKcM2eequsn7T3E6Vg5zhKjhxRkuWIlPIUrKmjDOwcR-mU4pAVLCqqSclvKyKIutpL0fU9sb85PCtjzaEvaf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