[llvm] [SLP]Vectorize unique scalars of splat gather nodes as separate subtrees (PR #218250)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 07:10:31 PDT 2026


alexey-bataev wrote:

> @alexey-bataev we (at google) still see a crash after the latest recommit. Please take a look.
> 
> `/tmp/repro.ll`:
> 
> ```llvm
> target triple = "aarch64-unknown-linux-gnu"
> 
> define double @widget() {
> bbl:
>   %select = select i1 false, i64 0, i64 0
>   %and = and i64 %select, 0
>   %icmp = icmp eq i64 %and, 0
>   %select1 = select i1 %icmp, double 0.000000e+00, double 0.000000e+00
>   %bitcast = bitcast double %select1 to i64
>   %xor = xor i64 %select, %bitcast
>   %bitcast2 = bitcast i64 %xor to double
>   %select3 = select i1 %icmp, double 0.000000e+00, double 0.000000e+00
>   %select4 = select i1 false, i64 0, i64 0
>   %icmp5 = icmp eq i64 %select4, 0
>   %select6 = select i1 %icmp5, double 0.000000e+00, double 0.000000e+00
>   %bitcast7 = bitcast double %select6 to i64
>   %xor8 = xor i64 %select4, %bitcast7
>   %bitcast9 = bitcast i64 %xor8 to double
>   %select10 = select i1 %icmp5, double 0.000000e+00, double 0.000000e+00
>   %bitcast11 = bitcast double %select10 to i64
>   %select12 = select i1 false, i64 0, i64 0
>   %icmp13 = icmp eq i64 %select12, 0
>   %select14 = select i1 %icmp13, double 0.000000e+00, double 0.000000e+00
>   %bitcast15 = bitcast double %select14 to i64
>   %xor16 = xor i64 %select12, %bitcast15
>   %select17 = select i1 %icmp13, double 0.000000e+00, double 0.000000e+00
>   %bitcast18 = bitcast double %select17 to i64
>   %bitcast19 = bitcast double %select3 to i64
>   %xor20 = xor i64 %select, %bitcast19
>   %bitcast21 = bitcast i64 %xor20 to double
>   %xor22 = xor i64 %select4, %bitcast11
>   %bitcast23 = bitcast i64 %xor22 to double
>   %fmul = fmul double %bitcast21, %bitcast23
>   %xor24 = xor i64 %select12, %bitcast18
>   %bitcast25 = bitcast i64 %xor24 to double
>   %fmul26 = fmul double %fmul, %bitcast25
>   %fmul27 = fmul double %bitcast2, %bitcast9
>   %bitcast28 = bitcast i64 %xor16 to double
>   %fmul29 = fmul double %fmul27, %bitcast28
>   %fadd = fadd double %fmul26, %fmul29
>   ret double %fadd
> }
> ```
> 
> Repro command:
> 
> ```shell
> # Before this, build `opt` after the latest recommit.
> $ opt -passes=slp-vectorizer /tmp/repro.ll -o /dev/null
> ```
> 
> LATER UPDATE: The stack I'm getting is:
> 
> ```
> 0  opt             0x00005587c100833c llvm::sys::RunSignalHandlers() + 300
> 1  opt             0x00005587c100be50
> 2  libpthread.so.0 0x00007f3aae661c60
> 3  opt             0x00005587bfe64015
> 4  opt             0x00005587bfe5f699 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) + 6281
> 5  opt             0x00005587bfe6ad34 llvm::slpvectorizer::BoUpSLP::calculateTreeCostAndTrimNonProfitable(llvm::ArrayRef<llvm::Value*>, llvm::Instruction*) + 1220
> 6  opt             0x00005587bfeec4f2
> 7  opt             0x00005587bfeb150b
> 8  opt             0x00005587bfeb0d44 llvm::SLPVectorizerPass::tryToVectorize(llvm::Instruction*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallSetVector<llvm::Instruction*, 8u>&, bool) + 1284
> 9  opt             0x00005587bfeb1742 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::SmallSetVector<llvm::Instruction*, 8u>&) + 146
> 10 opt             0x00005587bfea6c23 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) + 4195
> 11 opt             0x00005587bfea3f94 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) + 964
> 12 opt             0x00005587bfea3adf llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) + 399
> 13 opt             0x00005587c0ddf66c llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) + 428
> 14 opt             0x00005587c0de3810 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 432
> 15 opt             0x00005587c0dde989 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 425
> 16 opt             0x00005587bdb7c7cc 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::__u::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool, bool) + 15708
> 17 opt             0x00005587bdb73327 optMain + 11079
> 18 opt             0x00005587bdb70204 main + 68
> 19 libc.so.6       0x00007f3aae504f12 __libc_start_main + 242
> 20 opt             0x00005587bdb7016a _start + 42
> ```
> 
> I tested this code to tip-of-tree and is still reproducible.

Thanks, will fix ASAP

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


More information about the llvm-commits mailing list