<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/105713>105713</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assertion `BestFactor.Width == LegacyVF.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>
TatyanaDoubts
</td>
</tr>
</table>
<pre>
To reproduce run the test below with -passes=loop-vectorize
```
; ModuleID = './reduced.ll'
source_filename = "/home/ec2-user/fuzzer/builds/zvm-dev-4531/lib/server/boilerplate.ll"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32-ni:1-p2:32:8:8:32-ni:2"
target triple = "aarch64-none-linux-gnu"
; Function Attrs: uwtable
define noundef i32 @wombat() #0 gc "statepoint-example" {
bb:
%load = load i32, ptr addrspace(1) null, align 4, !range !60
%load1 = load i32, ptr addrspace(1) null, align 4, !range !60
br label %bb10
bb2: ; preds = %bb10
%phi = phi i8 [ %add19, %bb10 ]
%phi3 = phi i32 [ %add20, %bb10 ]
ret i32 0
bb4: ; preds = %bb10
%phi5 = phi i32 [ %add20, %bb10 ]
%add = add nuw nsw i64 %phi12, 3
%trunc = trunc i64 %add to i32
%icmp = icmp ugt i32 %load, %trunc
%add6 = add nuw nsw i64 %phi11, 3
%trunc7 = trunc i64 %add6 to i32
%icmp8 = icmp ugt i32 %load1, %trunc7
%and = and i1 %icmp, %icmp8
br i1 %and, label %bb10, label %bb9
bb9: ; preds = %bb4
ret i32 0
bb10: ; preds = %bb4, %bb
%phi11 = phi i64 [ 0, %bb ], [ %add6, %bb4 ]
%phi12 = phi i64 [ 0, %bb ], [ %add, %bb4 ]
%phi13 = phi i32 [ 0, %bb ], [ %add15, %bb4 ]
%phi14 = phi i32 [ 0, %bb ], [ %phi5, %bb4 ]
%add15 = add i32 %phi13, 1
%getelementptr = getelementptr inbounds double, ptr addrspace(1) null, i64 %phi12
store double 0.000000e+00, ptr addrspace(1) %getelementptr, align 8, !tbaa !61
%getelementptr16 = getelementptr inbounds i64, ptr addrspace(1) null, i64 %phi11
%load17 = load i64, ptr addrspace(1) %getelementptr16, align 8, !tbaa !64
%add18 = add i64 %load17, 1
store i64 %add18, ptr addrspace(1) %getelementptr16, align 8, !tbaa !64
%add19 = add i8 0, 0
%add20 = add nsw i32 %phi14, 3
%icmp21 = icmp slt i32 %phi14, 115
br i1 %icmp21, label %bb4, label %bb2
}
declare i32 @llvm.experimental.deoptimize.i32(...) #1
!60 = !{i32 0, i32 2147483646}
!61 = !{!62, !62, i64 0}
!62 = !{!"double.array", !63}
!63 = !{!"dolphin-tbaa-access-type"}
!64 = !{!65, !65, i64 0}
!65 = !{!"long.array", !63}
```
Reproducer: https://godbolt.org/z/Yzs8McbnK
```
opt: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7288: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `BestFactor.Width == LegacyVF.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: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>
1. Running pass "function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)" on module "<source>"
2. Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "wombat"
#0 0x0000000004f90548 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f90548)
#1 0x0000000004f8dcbc SignalHandler(int) Signals.cpp:0:0
#2 0x00007b8528242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007b85282969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007b8528242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007b85282287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x00007b852822871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x00007b8528239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x0000000003fdf468 llvm::LoopVectorizationPlanner::computeBestVF() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fdf468)
#9 0x0000000003ffa76a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ffa76a)
#10 0x0000000003ffd429 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ffd429)
#11 0x0000000003ffdab3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ffdab3)
#12 0x0000000002ec3f4e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2ec3f4e)
#13 0x0000000004d8d638 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d8d638)
#14 0x0000000000def2ee llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdef2ee)
#15 0x0000000004d8c03e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d8c03e)
#16 0x0000000000deebde llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdeebde)
#17 0x0000000004d8a1d0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d8a1d0)
#18 0x00000000008e6d92 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) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e6d92)
#19 0x00000000008d9c6c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d9c6c)
#20 0x00007b8528229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x00007b8528229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#22 0x00000000008d16fe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d16fe)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWl1v27jS_jXMDSFDIvXli1w4Sb1vsS3eYlP04FwFlEjLPKVJgaTy0V9_MJRsi46TbXazOIsNmloSZ5555kOjoRzmnOy0EJeouELFzQUb_NbYy6_MPzHNbszQeHfRGP50-dVgK3pr-NAKbAeN_VZgL5zHjVDmAT9Iv8VJz5wTDtEbZUyf3IvWGyt_CJTeoHSFyn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