<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116375>116375</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
opt -passes="loop-vectorize" -pass-remarks-output=tmp.opts crashes with 'Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' 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: 10b048c8922d
Reproduce with: ```opt -passes="loop-vectorize" bbi-101140.ll -o /dev/null -pass-remarks-output=tmp.opts```
Result:
```
opt: ../include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From *) [To = llvm::VectorType, From = llvm::Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: build-all/bin/opt -passes=loop-vectorize bbi-101140.ll -o /dev/null -pass-remarks-output=tmp.opts
1. Running pass "function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)" on module "bbi-101140.ll"
2. Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "main"
#0 0x000055b814f24938 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (build-all/bin/opt+0x4435938)
#1 0x000055b814f223fe llvm::sys::RunSignalHandlers() (build-all/bin/opt+0x44333fe)
#2 0x000055b814f2516d SignalHandler(int) Signals.cpp:0:0
#3 0x00007f5d1b5dbcf0 __restore_rt (/lib64/libpthread.so.0+0x12cf0)
#4 0x00007f5d19194acf raise (/lib64/libc.so.6+0x4eacf)
#5 0x00007f5d19167ea5 abort (/lib64/libc.so.6+0x21ea5)
#6 0x00007f5d19167d79 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d79)
#7 0x00007f5d1918d426 (/lib64/libc.so.6+0x47426)
#8 0x000055b816474525 llvm::VPFirstOrderRecurrencePHIRecipe::computeCost(llvm::ElementCount, llvm::VPCostContext&) const (build-all/bin/opt+0x5985525)
#9 0x000055b816461f4c llvm::VPRecipeBase::cost(llvm::ElementCount, llvm::VPCostContext&) (build-all/bin/opt+0x5972f4c)
#10 0x000055b8163faa3a llvm::LoopVectorizationPlanner::emitInvalidCostRemarks(llvm::OptimizationRemarkEmitter*) (build-all/bin/opt+0x590ba3a)
#11 0x000055b816427189 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (build-all/bin/opt+0x5938189)
#12 0x000055b81642cd0b llvm::LoopVectorizePass::runImpl(llvm::Function&) (build-all/bin/opt+0x593dd0b)
#13 0x000055b81642d568 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build-all/bin/opt+0x593e568)
#14 0x000055b8162e33dd llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0
#15 0x000055b81512d317 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build-all/bin/opt+0x463e317)
#16 0x000055b8162dcf6d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilderPipelines.cpp:0:0
#17 0x000055b815131ea6 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build-all/bin/opt+0x4642ea6)
#18 0x000055b8162d6a0d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilderPipelines.cpp:0:0
#19 0x000055b81512c047 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build-all/bin/opt+0x463d047)
#20 0x000055b81627ab63 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (build-all/bin/opt+0x578bb63)
#21 0x000055b814eebd0a optMain (build-all/bin/opt+0x43fcd0a)
#22 0x00007f5d19180d85 __libc_start_main (/lib64/libc.so.6+0x3ad85)
#23 0x000055b814ee5b2e _start (build-all/bin/opt+0x43f6b2e)
Abort (core dumped)
```
[bbi-101140.ll.gz](https://github.com/user-attachments/files/17774956/bbi-101140.ll.gz)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWN1u27rSfRr6hrAhkfq98IXj1NjF16JBGvTWoMiRza8UKZBU2uynP6DkJKbrJO7PPmcDLtRoyDVrZpZG4jDn5E4DLFF-hfLrGRv83thlJ78yUHujOtCzxoiHpVL3Heam66RHdIXTpEmyilc1IQIl1yhZ3UJvjRg44G_S78MaVCTTz_Qez3vmHDhErxEhyph-fg_cGyv_BkQIbho5T5M0zZKFUnhuMCIbAfeIbPQQboTdcwsds1_d3Ay-Hzyi177rF6b37snTIxU3qEBz-vPEavoxgsUCkY3UXA0CENmE-BDZfB763liPyGbNnJd6twih5GUVtgjgyj_0gEjFBm8QqfG4ja4QXXHmPCLVxpoOI7IKRpRf3RmM6PXRsi9j1HcjyhpPq6MFoym_Dv5WzoH10uiQSukYous7g-g7RKovTI0eSIFIgREho3u6vnuY7MHI7G7oQHtsWiw1N13PvGwU4CmGFBGCSIlbJhWIxZScmw_vVp_fY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