[llvm] [VPlan] Compute cost of more replicating loads/stores in ::computeCost. (PR #160053)
Michał Górny via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 30 11:55:28 PDT 2025
mgorny wrote:
Looks like this change broke building compiler-rt for me, on Gentoo/amd64:
```
clang++: /var/tmp/portage/llvm-core/llvm-22.0.0.9999/work/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7079: llvm::VectorizationFact
or llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || BestPlan.hasEarlyExit() || planCo
ntainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop, BestFactor.Width) || planContainsAdditionalSimplificat
ions( getPlanFor(LegacyVF.Width), CostCtx, OrigLoop, 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, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt_build/lib/llvm/22/bin/clang++ -O2 -pipe -march=native --config=/etc/clang/22/gentoo-rtlib.cfg --config=/etc/clang/22/gentoo-stdlib.cfg --config=/etc/clang/22/gentoo-linker.cfg -Wall -Wno-unused-parameter -Wno-unknown-warning-option -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -I/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt/include -g -Wno-covered-switch-default -Wno-suggest-override -DGTEST_NO_LLVM_SUPPORT=1 -DGTEST_HAS_RTTI=0 -I/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt/../third-party/unittest/googletest/include -I/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt/../third-party/unittest/googletest -I/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt/include -I/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt/lib -I/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt/lib/asan -I/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt/lib/sanitizer_common/tests -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS -fno-rtti -O2 -Wno-format -Werror=sign-compare -Wno-variadic-macros -gline-tables-only -DASAN_HAS_IGNORELIST=1 -DASAN_HAS_EXCEPTIONS=1 -DASAN_UAR=0 -m32 -c -o ASAN_NOINST_TEST_OBJECTS.gtest-all.cc.i386-calls.o /var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/third-party/unittest/googletest/src/gtest-all.cc
1. <eof> parser at end of file
2. Optimizer
3. Running pass "function<eager-inv>(drop-unnecessary-assumes,float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/third-party/unittest/googletest/src/gtest-all.cc"
4. Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "_ZN7testing8internal13edit_distance21CalculateOptimalEditsERKSt6vectorIjSaIjEES6_"
#0 0x00007f06855ca3d3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0xdca3d3)
#1 0x00007f06855c6d74 llvm::sys::RunSignalHandlers() (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0xdc6d74)
#2 0x00007f06854b0478 (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0xcb0478)
#3 0x00007f068aa64910 (/usr/lib64/libc.so.6+0x3d910)
#4 0x00007f068aabccbc (/usr/lib64/libc.so.6+0x95cbc)
#5 0x00007f068aa647e6 raise (/usr/lib64/libc.so.6+0x3d7e6)
#6 0x00007f068aa4c30b abort (/usr/lib64/libc.so.6+0x2530b)
#7 0x00007f068aa4c275 __assert_perror_fail (/usr/lib64/libc.so.6+0x25275)
#8 0x00007f06850bb420 (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0x8bb420)
#9 0x00007f0687274154 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0x2a74154)
#10 0x00007f068727786f llvm::LoopVectorizePass::runImpl(llvm::Function&) (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0x2a7786f)
#11 0x00007f0687277dd9 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0x2a77dd9)
#12 0x00007f068897c343 (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0x417c343)
#13 0x00007f06857e7b4b llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0xfe7b4b)
#14 0x00007f06883b37f3 (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0x3bb37f3)
#15 0x00007f06857e80eb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0xfe80eb)
#16 0x00007f06883b44d3 (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0x3bb44d3)
#17 0x00007f06857e935f llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git98766d28+0xfe935f)
#18 0x00007f068cf60576 (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0git98766d28+0x2360576)
#19 0x00007f068cf648c7 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0git98766d28+0x23648c7)
#20 0x00007f068d30f0a0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0gi
t98766d28+0x270f0a0)
#21 0x00007f068b8edbdc clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0git98766d28+0xcedbdc)
#22 0x00007f068dc96e65 clang::FrontendAction::Execute() (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0git98766d28+0x3096e65)
#23 0x00007f068dc21f5e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0git98
766d28+0x3021f5e)
#24 0x00007f068dd316d5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0git98766d28+0x31316d5)
#25 0x000055a5d82abeff cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers
-22.0.0.9999/work/compiler-rt_build/lib/llvm/22/bin/clang+++0x19eff)
#26 0x000055a5d82a3bf3 (/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt_build/lib/llvm/22/bin/clang+
++0x11bf3)
#27 0x000055a5d82a4773 (/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt_build/lib/llvm/22/bin/clang+
++0x12773)
#28 0x00007f068d7df16d (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0git98766d28+0x2bdf16d)
#29 0x00007f06854b05de llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm/22/lib64/libLLVM.so.22.0git987
66d28+0xcb05de)
#30 0x00007f068d7e1a0f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<ch
ar, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0git98766d28+0x2be1a0f)
#31 0x00007f068d79c0c0 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool)
const (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0git98766d28+0x2b9c0c0)
#32 0x00007f068d79c4a7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clan
g::driver::Command const*>>&, bool) const (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0git98766d28+0x2b9c4a7)
#33 0x00007f068d7ac074 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clan
g::driver::Command const*>>&) (/usr/lib/llvm/22/lib64/libclang-cpp.so.22.0git98766d28+0x2bac074)
#34 0x000055a5d82a6334 clang_main(int, char**, llvm::ToolContext const&) (/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.
9999/work/compiler-rt_build/lib/llvm/22/bin/clang+++0x14334)
#35 0x000055a5d82a1f78 main (/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt_build/lib/llvm/22/bin/c
lang+++0xff78)
#36 0x00007f068aa4e3ae (/usr/lib64/libc.so.6+0x273ae)
#37 0x00007f068aa4e469 __libc_start_main (/usr/lib64/libc.so.6+0x27469)
#38 0x000055a5d82a1fe5 _start (/var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt_build/lib/llvm/22/bin
/clang+++0xffe5)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 22.0.0git98766d28
Target: i386-pc-linux-gnu
Thread model: posix
InstalledDir: /var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/work/compiler-rt_build/lib/llvm/22/bin
Build config: +assertions
Configuration file: /etc/clang/22/i386-pc-linux-gnu-clang++.cfg
Configuration file: /etc/clang/22/gentoo-rtlib.cfg
Configuration file: /etc/clang/22/gentoo-stdlib.cfg
Configuration file: /etc/clang/22/gentoo-linker.cfg
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg: /var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/temp/gtest-all-2ae0f1.cpp
clang++: note: diagnostic msg: /var/tmp/portage/llvm-runtimes/compiler-rt-sanitizers-22.0.0.9999/temp/gtest-all-2ae0f1.sh
clang++: note: diagnostic msg:
********************
```
The reproducer (2M, unpacks to 20M): [repro.tar.gz](https://github.com/user-attachments/files/22625542/repro.tar.gz)
https://github.com/llvm/llvm-project/pull/160053
More information about the llvm-commits
mailing list