<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58666>58666</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
nontrivial SimpleLoopUnswitch crashes on partial unswitch assertion
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yrouban
</td>
</tr>
</table>
<pre>
I found an IR that causes SimpleLoopUnswitch to crash as follows:
```
$ opt -passes=simple-loop-unswitch'<nontrivial>' simple-loop-unswitch-crash.ll --disable-output
opt: /home/yrouban/work/llvm-project/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:2113: void unswitchNontrivialInvariants(llvm::Loop&, llvm::Instruction&,
llvm::ArrayRef<llvm::Value*>, llvm::IVConditionInfo&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::AssumptionCache&, llvm::function_ref<void(bool, bool, llvm::A
rrayRef<llvm::Loop*>)>, llvm::ScalarEvolution*, llvm::MemorySSAUpdater*, llvm::function_ref<void(llvm::Loop&, llvm::StringRef)>): Assertion `((match(Cond, m_Log
icalAnd()) ^ match(Cond, m_LogicalOr())) || PartiallyInvariant) && "Only `or`, `and`, an `select`, partially invariant instructions " "can combine invariants be
ing unswitched."' failed.
```
[simple-loop-unswitch-crash.ll.txt](https://github.com/llvm/llvm-project/files/9888544/simple-loop-unswitch-crash.ll.txt)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVF1vmzAU_TXwYgUREwg88MCSVorUrVPT9rUyYII3YyN_pMu_37XJR6tEqyaR-Ov63HOOfV3L9lBuUCetaBERaPOETE8MaojVVKMtG0ZOH6QcX4R-Z6bpkZGoUUT3iGjYxrl810FSBfE6iKsgi4_fNMQLJEeDZiPRgBYka-3xZhwAZ_aIGOBlkKyEFEaxPSM8SO5gCt0KnfnMEedoNmuZJjUESGtGa6aEkAy4oADf93Kg0ByUtDUR0HuX6jc0nO-H2ajkL9qY49A1rIb_Z0WE7qQaNAy2DeFEuc6VBVEzjpAGz-eJy7aXrEUnhj_OMjZiTxQjwgBa7vOAS0nlgAKcBXiFLpMboY2yjWFSTGuTnEtApRQ5PNEOjLpMvhJuQWTlDfsE97qSomUObiM6eZVuLQcmiJHqWVF6teoY3txWaW2H0aGuSNNfb-ys8BLelCfqfAHptZTcxZ3aD3iTylvSJpcmZcWVvuls7vaS28my6vP6dzpIddhuq5exJYaqq4DbTL84pC0crNg5pkdKhTt9MIUqh4Xctcc5fAPxtzp3h-AghrcHuZu0MmBeudncbccFCtI7dDPeRT6qc6CPXa7gQz8J5COcH843zC86uhk0-FHwgyMjlWe0cn0CyNOAeKKaclcA09R4AkTshAi9843UDtT9GtjbyKFmgl4iNarpUZvYncuAthFscGXcEcbd6Ob7MP2n3_5Z65H5Y4J0DVb0xoz-scH38O2Y6W0dAaMPhfy5vDvI7Yq5yPM8XSyg93Um8NrTCmk5z7KsyOZpGodtmbRFUpDQMMNpeXmtbj2RHg9eT7gUR2_PxiByvi-hVbz8b0kMitBrSnNgF_ZlERdFgnG6SEnXZnm7zJusoQVNi6Zr4-Ui5KSmXJdgM7gYshLHGM9jnM9xipM4apa46_BiXicJBZeaYBHTAQ4tcokjqXahKj2H2u40LHKmjb4sgh62E5Se8Ik1vVTl8eENPd3Sc_0LhQcKMA">