<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62493>62493</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[simple-loop-unswitch<nontrivial>] Assertion `isa<Instruction>(skipTrivialSelect(BI->getCondition())) && "Partial unswitching requires an instruction as the condition!"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
TatyanaDoubts
</td>
</tr>
</table>
<pre>
The bug was found by FuzzGen IR test generator
Run opt with Run opt with -passes='simple-loop-unswitch<nontrivial>'
https://godbolt.org/z/q5qj9KG83
Stack dump:
```console
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=simple-loop-unswitch<nontrivial> <source>
#0 0x0000560013615c5f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3604c5f)
#1 0x0000560013613384 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f7dc3293420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f7dc2d6000b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f7dc2d3f859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f7dc2d3f729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f7dc2d50fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x00005600134a9737 unswitchNontrivialInvariants(llvm::Loop&, llvm::Instruction&, llvm::ArrayRef<llvm::Value*>, llvm::IVConditionInfo&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::AssumptionCache&, llvm::function_ref<void (bool, bool, llvm::ArrayRef<llvm::Loop*>)>, llvm::ScalarEvolution*, llvm::MemorySSAUpdater*, llvm::function_ref<void (llvm::Loop&, llvm::StringRef)>) SimpleLoopUnswitch.cpp:0:0
#8 0x00005600134aa426 unswitchBestCondition(llvm::Loop&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::AssumptionCache&, llvm::AAResults&, llvm::TargetTransformInfo&, llvm::function_ref<void (bool, bool, llvm::ArrayRef<llvm::Loop*>)>, llvm::ScalarEvolution*, llvm::MemorySSAUpdater*, llvm::function_ref<void (llvm::Loop&, llvm::StringRef)>) SimpleLoopUnswitch.cpp:0:0
#9 0x00005600134ac764 unswitchLoop(llvm::Loop&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::AssumptionCache&, llvm::AAResults&, llvm::TargetTransformInfo&, bool, bool, llvm::function_ref<void (bool, bool, llvm::ArrayRef<llvm::Loop*>)>, llvm::ScalarEvolution*, llvm::MemorySSAUpdater*, llvm::ProfileSummaryInfo*, llvm::BlockFrequencyInfo*, llvm::function_ref<void (llvm::Loop&, llvm::StringRef)>) SimpleLoopUnswitch.cpp:0:0
#10 0x00005600134ad13e llvm::SimpleLoopUnswitchPass::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x349c13e)
#11 0x0000560013838926 llvm::detail::PassModel<llvm::Loop, llvm::SimpleLoopUnswitchPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3827926)
#12 0x000056001434d67f std::optional<llvm::PreservedAnalyses> llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runSinglePass<llvm::Loop, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>>(llvm::Loop&, std::unique_ptr<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, std::default_delete<llvm::detail::PassConcept<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, llvm::PassInstrumentation&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x433c67f)
#13 0x000056001434d926 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithoutLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x433c926)
#14 0x000056001434ed3d llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x433dd3d)
#15 0x000056001434ff42 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x433ef42)
#16 0x0000560013835876 llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3824876)
#17 0x0000560010e4800d 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>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe3700d)
#18 0x0000560012f1244d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f0144d)
#19 0x0000560010e2dbd6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe1cbd6)
#20 0x0000560012f103dd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2eff3dd)
#21 0x000056001099c735 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x98b735)
#22 0x00005600108b1d56 main (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8a0d56)
#23 0x00007f7dc2d41083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#24 0x000056001098fd0e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x97ed0e)
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWt9z2rgW_muUFw2MLPnnAw-UlL2Z3ezNlGzvIyNbx6CtkFxJTpv-9XdsE8CGtGSW3Wm7maElWDqfzvnOp2NZFndOrjTABEVvUHR9xWu_NnZyz_0j1_za1Ll3V7kRj5P7NeC8XuFP3OHS1Frg_BHP6y9ffgGNb95hD87jFWiw3BuLyDUi0-7_d7XGpvL4k_Rr3Psxqrhz4BC7RjRxclMpGCljqlGt3SfpizViM220t_JBcoXYW0STQ-S195VDbIroHNH5yojcKD82doXo_Aui84_Rxz-zX39J2aHRwvPiAxb1pmosu4aYdJ_CaGcUdFfJGJHszpqV5RvM7aregPbNcBjRuak8ovPCbCqpwI7gc6WMBdtcU1yvRk1g1kuj3cjbWn9AdJ5L3RnikWkgeFU1v2tf1X7s8GhxwMc5ZGDEZs7UtoCGmdZljCgjmHwmhJAoJiRgcRAVUYmVetg04bKpe3TdH3dWat-ScW95AYim-06Wf1oa5y3wDaIxojMstUc0w4imfzF4RN-QzywmYRGViGZ7v4OB34ylIV7IlebqP1wL1eCnWze6y25cVE0SSftvB0S3QEmZiILRjIWU4OXSgvPGwtL6bRRK5ojOP6fxMg5HSur682il666h8msLXIydGZPW4yAMKen5yw6HoSImhOTYcungDPyiQY5b5JARkveQwz4yK9Mowzw3Z3l-gExpGmU95GiInOxyejZmQvuYcR8zIqWIX4bJWCniHmbS00LIs4Ql-Gke_L6bBDf6gVvJm1l5qN7fjKm2st1fvNHO27poVHnUNrWWP76DErHZ_uJ7rmpAdNqWnR7S-5nRQjZIN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