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

    <tr>
        <th>Summary</th>
        <td>
            Assertion `EVL->contains(L) && "LCSSA breach detected!"' failed.
        </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: f00f894d5d8
Reproduce with:
```
llc -O1 -o /dev/null bbi-69670_x86.ll
```
[bbi-69670_x86.ll.gz](https://github.com/llvm/llvm-project/files/8707656/bbi-69670_x86.ll.gz)

Result:
```
llc: ../lib/Transforms/Utils/LoopUtils.cpp:1385: int llvm::rewriteLoopExitValues(llvm::Loop *, llvm::LoopInfo *, llvm::TargetLibraryInfo *, llvm::ScalarEvolution *, const llvm::TargetTransformInfo *, llvm::SCEVExpander &, llvm::DominatorTree *, llvm::ReplaceExitVal, SmallVector<llvm::WeakTrackingVH, 16> &): Assertion `EVL->contains(L) && "LCSSA breach detected!"' failed.
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/llc -O1 -o /dev/null bbi-69670_x86.ll
1.      Running pass 'Function Pass Manager' on module 'bbi-69670_x86.ll'.
2.      Running pass 'Loop Pass Manager' on function '@func_1'
3.      Running pass 'Loop Strength Reduction' on basic block '%for.cond6418'
 #0 0x0000000002abded3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/llc+0x2abded3)
 #1 0x0000000002abbb4e llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/llc+0x2abbb4e)
 #2 0x0000000002abe256 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fcb1f00e630 __restore_rt sigaction.c:0:0
 #4 0x00007fcb1c755387 raise (/lib64/libc.so.6+0x36387)
 #5 0x00007fcb1c756a78 abort (/lib64/libc.so.6+0x37a78)
 #6 0x00007fcb1c74e1a6 __assert_fail_base (/lib64/libc.so.6+0x2f1a6)
 #7 0x00007fcb1c74e252 (/lib64/libc.so.6+0x2f252)
 #8 0x0000000002b80be3 llvm::rewriteLoopExitValues(llvm::Loop*, llvm::LoopInfo*, llvm::TargetLibraryInfo*, llvm::ScalarEvolution*, llvm::TargetTransformInfo const*, llvm::SCEVExpander&, llvm::DominatorTree*, llvm::ReplaceExitVal, llvm::SmallVector<llvm::WeakTrackingVH, 16u>&) (../../main-github/llvm/build-all/bin/llc+0x2b80be3)
 #9 0x00000000024c0a1e ReduceLoopStrength(llvm::Loop*, llvm::IVUsers&, llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::MemorySSA*) LoopStrengthReduce.cpp:0:0
#10 0x00000000024ec121 (anonymous namespace)::LoopStrengthReduce::runOnLoop(llvm::Loop*, llvm::LPPassManager&) LoopStrengthReduce.cpp:0:0
#11 0x0000000001b2d17b llvm::LPPassManager::runOnFunction(llvm::Function&) (../../main-github/llvm/build-all/bin/llc+0x1b2d17b)
#12 0x000000000230895f llvm::FPPassManager::runOnFunction(llvm::Function&) (../../main-github/llvm/build-all/bin/llc+0x230895f)
#13 0x000000000230f398 llvm::FPPassManager::runOnModule(llvm::Module&) (../../main-github/llvm/build-all/bin/llc+0x230f398)
#14 0x0000000002308f2d llvm::legacy::PassManagerImpl::run(llvm::Module&) (../../main-github/llvm/build-all/bin/llc+0x2308f2d)
#15 0x000000000074a073 main (../../main-github/llvm/build-all/bin/llc+0x74a073)
#16 0x00007fcb1c741555 __libc_start_main (/lib64/libc.so.6+0x22555)
#17 0x0000000000747670 _start (../../main-github/llvm/build-all/bin/llc+0x747670)
Abort
```
Starts happening with 07005440ae1
```
[LSR] Optimize unused IVs to final values in the exit block

Loop Strength Reduce sometimes optimizes away all uses of an induction variable
from a loop but leaves the IV increments. When the only remaining use of the IV
is the PHI in the exit block, this patch will call rewriteLoopExitValues to
replace the exit block PHI with the final value of the IV to skip the updates
in each loop iteration.

Differential Revision: https://reviews.llvm.org/D118808
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFWNlu2zoQ_Rr7hbBBUfuDH9LEQQOkaBC37qNBSZTNW0oUSCrL_fo7pORFjp00TYsbJJbF5cyZhTOcZLJ4ngnxUKFcVhU3I_8ClRiXSRoUYZGM8NUIX9yzRsmizRl65GYDS7rhUYT7X_cqRI4mXz00kWhErgv2AJ91KwTKMj6J0ijGq6ckmgpxcvco_HS8brr-dxRejUiyMabRViy5ht81cGizKfCFF0u9f0yA5D8sN_BacsE0PJMYx1EYwbdT2CTtRfdK6laYV5SzpplOrTCewec3RWtdSlVZQd8NF_Z5K2Xjvk_zpoENnp-Edh-vDXJUAd6_UOxRccPs4vkTN0sqWks32a-wU2BF0PgSDUdv6lK-nPlG1ZqZW54pqp5PL1nkVFA1f5CiNVzW2wW5rLV5gbRT7gzW5Xw5f2poXTAFs9Fw9kpWvKZGqm-KsZebIZoEzVmvuZ1bVFSIJbhOqpF_uV_5g9GfwCT_yev18rNd6UUjf95JTK1dL7RmqlMnwvPl7QSmQSNDeW0NegvLutURPMjt5WJxgTLFaL5BBTMgkRUj4sHUiMSopBA2xbRz-N3t_GIxR7rN4FQgirJ2jRRrpDLISPTuiORaOx9fIzAahEMu2oIhs2EoV1RvUAZaGlCV9eIXBgZQ0VbNLiIxTKV3Sq4VrRB4qa1YbfQuKt1HBYpPOjp7KlnLRTEBE9vvvHYT7zqqnpV839Y1-AE1VGvYFV-3de4sf2cHvtCarpmyZoShCrKFsK6PXwCSuNeQnAJ1cX8CsNwKg_dRgO3ryrPfHZR_FmphFKvXZoPuGeQvi9ADZlTzHGVCgpUtDgkh2sGDdREFXrJDhjkfI_yEtz-EZgUr_INw1s-6-3K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