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

    <tr>
        <th>Summary</th>
        <td>
            Cached disposition of [...] is incorrect: cached Variant, actual Invariant with opt -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: 36b13eb8bb9d
Reproduce with:```opt -passes="loop-mssa(loop-idiom,loop-rotate),loop-simplifycfg" bbi-74541.ll -o /dev/null -verify-scev```
Result:
```
Cached disposition of (2 * %0) for loop Loop at depth 1 containing: %for.cond<header><exiting>,%for.end<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=loop-mssa(loop-idiom,loop-rotate),loop-simplifycfg bbi-74541.ll -o /dev/null -verify-scev
 #0 0x0000000002e5dc03 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x2e5dc03)
 #1 0x0000000002e5b91e llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x2e5b91e)
 #2 0x0000000002e5df86 SignalHandler(int) (../../main-github/llvm/build-all/bin/opt+0x2e5df86)
 #3 0x00007fbfd7a66630 __restore_rt (/lib64/libpthread.so.0+0xf630)
 #4 0x00007fbfd51ad387 raise (/lib64/libc.so.6+0x36387)
 #5 0x00007fbfd51aea78 abort (/lib64/libc.so.6+0x37a78)
 #6 0x0000000001e8dbbd llvm::ScalarEvolution::verify() const (../../main-github/llvm/build-all/bin/opt+0x1e8dbbd)
 #7 0x00000000037eaf5b llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x37eaf5b)
 #8 0x00000000031c834d 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+0x31c834d)
 #9 0x000000000264392c llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x264392c)
#10 0x0000000000ae9d4d 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+0xae9d4d)
#11 0x0000000002647c0e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x2647c0e)
#12 0x0000000000ae9b2d 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+0xae9b2d)
#13 0x0000000002642bdc llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x2642bdc)
#14 0x000000000071fea9 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+0x71fea9)
#15 0x0000000000731c51 main (../../main-github/llvm/build-all/bin/opt+0x731c51)
#16 0x00007fbfd5199555 __libc_start_main (/lib64/libc.so.6+0x22555)
#17 0x0000000000718bf0 _start (../../main-github/llvm/build-all/bin/opt+0x718bf0)
Abort
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlWNtu2zgQ_Rr5hbAhUfcHP7hpjC22xQZN0FeDN9nc0qJAUmnz9zuU5MR0nG6aZLG3XGSZHM6cOTMcaUg1v1sqdbtHTO_30kXpCqUFTVJBK0prHsXvo3j1WXRG854J9E26HchERTz-6c6heUesFTZK30cYK627-d5aEuFquJdc6n2EL4YvRjviRITrw4CV-07J5o41W1iMKJXzMsuzZKEUmmsU4TUXt3Btez9wKwzIzi2DsQOCA0LbK49-_Hoye0HYTnDEpe20lU7qFukGlFcYLiv4z2PAhBptkEeFPvoLcYiLzu1QAty0jshWtlvPD4iD5AIGeZRe7AThwkTpJdyL76DcC12Cf5OYGKQUcWznxwc8SFokW6aNEWygnI0AvxAjSetgMSLM9UShD-3tNDYsvPp4ubq-RLanECtEEO23yIhOG4ecRjvnOus5wGv420Koegowgf21D_H0MYdY_u7t4rW0tofA4TUiLfeIVM8FcjuBmCF2hyhhX50hTCxG89cOBhDv99090zFM1VdGbw3ZI2K2_V60zoNAiwUoHi574G4-wnmAQnup-Jwo5e9lC9cwl16eSD-TRWM4IpzGKP4eH36wyDmLUzRABU_Tlb2z482Vka0beLjxxHhw90KGfNto64wggLPwUZQ-mLXPtJewEeF38fcJi3f1HmxyApbWiTgH9nPfXsttS9QvEF8lDIS6egM83lyAB5-S11QFCiyDxTfiAlQHttPJdtnQhpekKAqI5WZjhHXaiA3sjMHptZK0yMZP2NQQI76wehEPehtYEyjNjpXmCeFpVSJDpBWPtTGvpxj0pAXIBYryE0WClBUiVJ-DdayoBLlAUXFMcSIqTik_Cvk1I4qYy1utel_exsEx0aeY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