[llvm] [LV] Enable auto-vectorisation of loops with uncountable exits (PR #133099)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 10 08:29:39 PDT 2025


bgra8 wrote:

@david-arm please note that we have bisected a bunch of `clang` crashes at this revision:

```
Stack dump:
0.      Program arguments: /bin/clang --target=x86_64-unknown-linux-gnu -O3 -c -x ir -mllvm -force-vector-interleave=2 -o /dev/null reduced.ll
1.      Optimizer
2.      Running pass "function<eager-inv>(float2int,lower-constant-intrinsics,chr,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<O3>,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 "reduced.ll"
3.      Running pass "loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>" on function "barney"
 #0 0x000055888889874a llvm::sys::RunSignalHandlers() (/bin/clang+0x889874a)
 #1 0x000055888885d828 CrashRecoverySignalHandler(int) (/bin/clang+0x885d828)
 #2 0x00007ff9ded99e80 __restore_rt (/lib64/libpthread.so.0+0x14e80)
 #3 0x00005588886f037d llvm::FunctionType::get(llvm::Type*, llvm::ArrayRef<llvm::Type*>, bool) (/bin/clang+0x86f037d)
 #4 0x000055888868706b llvm::Intrinsic::getType(llvm::LLVMContext&, unsigned int, llvm::ArrayRef<llvm::Type*>) (/bin/clang+0x868706b)
 #5 0x000055888868dc45 llvm::Intrinsic::getOrInsertDeclaration(llvm::Module*, unsigned int, llvm::ArrayRef<llvm::Type*>) (/bin/clang+0x868dc45)
 #6 0x0000558888667b00 llvm::IRBuilderBase::getReductionIntrinsic(unsigned int, llvm::Value*) (/bin/clang+0x8667b00)
 #7 0x0000558887bf44ac llvm::VPInstruction::generate(llvm::VPTransformState&) (/bin/clang+0x7bf44ac)
 #8 0x0000558887bf5b35 llvm::VPInstruction::execute(llvm::VPTransformState&) (/bin/clang+0x7bf5b35)
 #9 0x0000558887bd47de llvm::VPBasicBlock::execute(llvm::VPTransformState*) (/bin/clang+0x7bd47de)
#10 0x0000558887bd830e llvm::VPlan::execute(llvm::VPTransformState*) (/bin/clang+0x7bd830e)
#11 0x0000558887abd126 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool) (/bin/clang+0x7abd126)
#12 0x0000558887acab00 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/bin/clang+0x7acab00)
#13 0x0000558887ad0515 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/bin/clang+0x7ad0515)
#14 0x0000558887ad0a5e llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/bin/clang+0x7ad0a5e)
#15 0x0000558886dc5f72 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/bin/clang+0x6dc5f72)
#16 0x00005588886d9669 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/bin/clang+0x86d9669)
#17 0x000055888399a3f2 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/bin/clang+0x399a3f2)
#18 0x00005588886dcb10 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/bin/clang+0x86dcb10)
#19 0x00005588839968f2 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/bin/clang+0x39968f2)
#20 0x00005588886d89e9 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/bin/clang+0x86d89e9)
#21 0x0000558883993a52 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::__u::unique_ptr<llvm::raw_pwrite_stream, std::__u::default_delete<llvm::raw_pwrite_stream>>&, std::__u::unique_ptr<llvm::ToolOutputFile, std::__u::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) (/bin/clang+0x3993a52)
#22 0x000055888398ba80 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__u::unique_ptr<llvm::raw_pwrite_stream, std::__u::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/bin/clang+0x398ba80)
#23 0x000055888370719b clang::CodeGenAction::ExecuteAction() (/bin/clang+0x370719b)
#24 0x00005588841b4f41 clang::FrontendAction::Execute() (/bin/clang+0x41b4f41)
#25 0x000055888412b404 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/bin/clang+0x412b404)
#26 0x0000558883701056 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/bin/clang+0x3701056)
#27 0x00005588836f62ce cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/bin/clang+0x36f62ce)
#28 0x00005588836f31c6 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/bin/clang+0x36f31c6)
#29 0x00005588842cf51e void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__u::optional<llvm::StringRef>>, std::__u::basic_string<char, std::__u::char_traits<char>, std::__u::allocator<char>>*, bool*) const::$_0>(long) (/bin/clang+0x42cf51e)
#30 0x000055888885d576 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/bin/clang+0x885d576)
#31 0x00005588842cebfa clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__u::optional<llvm::StringRef>>, std::__u::basic_string<char, std::__u::char_traits<char>, std::__u::allocator<char>>*, bool*) const (/bin/clang+0x42cebfa)
#32 0x000055888428a066 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/bin/clang+0x428a066)
#33 0x000055888428a24f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__u::pair<int, clang::driver::Command const*>>&, bool) const (/bin/clang+0x428a24f)
#34 0x00005588842ad530 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__u::pair<int, clang::driver::Command const*>>&) (/bin/clang+0x42ad530)
#35 0x00005588836f25ac clang_main(int, char**, llvm::ToolContext const&) (/bin/clang+0x36f25ac)
#36 0x00005588836f0c34 main (/bin/clang+0x36f0c34)
#37 0x00007ff9dec2a3d4 __libc_start_main (/lib64/libc.so.6+0x613d4)
#38 0x00005588836f0b6a _start (/bin/clang+0x36f0b6a)
```

Reproducer:  [reduced.ll.zip](https://github.com/user-attachments/files/21166234/reduced.ll.zip)
Repro command:

```
$ clang --target=x86_64-grtev4-linux-gnu \
  -O3 -c -x ir \
  -mllvm -force-vector-interleave=2 \
  -o /dev/null \
  /tmp/reduced.ll
```

Can you please take a look?




https://github.com/llvm/llvm-project/pull/133099


More information about the llvm-commits mailing list