<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96328>96328</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LoopVectorize][VPlan] Assertion `VF.Width == Width && "VPlan cost model and legacy cost model disagreed"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
patrick-rivos
</td>
</tr>
</table>
<pre>
Reduced LLVM IR:
```llvm ir
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"
target triple = "riscv64-unknown-linux-gnu"
define i32 @main(ptr %e) #0 {
entry:
br label %for.body
for.body: ; preds = %for.body, %entry
%phi.0 = phi i64 [ %phi.0.next, %for.body ], [ 1, %entry ]
%mul.0 = mul i64 %phi.0, 5
%arr.idx = getelementptr [5 x i16], ptr %e, i64 0, i64 %mul.0
%load.0 = load i16, ptr %arr.idx, align 2
%phi.0.next = add i64 %phi.0, 1
%exitcond = icmp ne i64 %phi.0.next, 24
br i1 %exitcond, label %for.body, label %for.loopexit
for.loopexit: ; preds = %for.body
ret i32 0
}
attributes #0 = { "target-features"="+64bit,+v,+zvl128b,+zvl256b" }
```
Command/backtrace:
```bash
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll
WARNING: You're attempting to print out a bitcode file.
This is inadvisable as it may cause display problems. If
you REALLY want to taste LLVM bitcode first-hand, you
can force output with the `-f' option.
opt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10360: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == Width && "VPlan cost model and legacy cost model disagreed"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll
#0 0x0000600d4f81dd50 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e5fd50)
#1 0x0000600d4f81b15f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e5d15f)
#2 0x0000600d4f81b2b5 SignalHandler(int) Signals.cpp:0:0
#3 0x00007f70a8a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f70a8a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007f70a8a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007f70a8a969fc pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007f70a8a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007f70a8a287f3 abort ./stdlib/abort.c:81:7
#9 0x00007f70a8a2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f70a8a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x0000600d4e8538b6 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1e958b6)
#12 0x0000600d4e855e1e llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1e97e1e)
#13 0x0000600d4e856f40 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1e98f40)
#14 0x0000600d4d70e776 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd50776)
#15 0x0000600d4f6399e1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2c7b9e1)
#16 0x0000600d4d711906 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd53906)
#17 0x0000600d4f6386eb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2c7a6eb)
#18 0x0000600d4d70dfc6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xd4ffc6)
#19 0x0000600d4f636521 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2c78521)
#20 0x0000600d4cf652a6 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) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5a72a6)
#21 0x0000600d4cf56f71 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x598f71)
#22 0x00007f70a8a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#23 0x00007f70a8a29e40 call_init ./csu/../csu/libc-start.c:128:20
#24 0x00007f70a8a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#25 0x0000600d4cf4cdb5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x58edb5)
zsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt
```
Godbolt: https://godbolt.org/z/habqYfPxq
Found via fuzzer.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWV1v47bS_jXMDWFDor4vcmEncd_Fm7RBEmzRK4MSRzZPKFIlKW-cX39ASrElx9vu7mkDFF1kbZnkPJx55sNjkhrDNxLgEiVLlFxf0M5ulb5sqdW8ep5pvlPmolRsf_kArKuA4dvbz3f40wOKFii4RsECpUH_J8SuwVz3o5bqDVjMqKWC7lVnMYquMSIEZg2KFjBrUbRIY_8y44eHkOQoWoQkn8mI9GOPboyQCazVvBXwBqm5qXZpPOvks1Rf5Exw2b3MNrI7iPWvDGouAfOIYBQHDeUSkby1GiOSACIFRiQKMMqW_XKQVu8PZmJcaixoCcItr5WeO1bG8IexaIFRtMStBmYGH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