Issue 202463
Summary Assertion in the SLP Vectorizer : Assertion `UnscheduledDeps >= 0 && "Expected valid number of unscheduled deps"
Labels
Assignees
Reporter chrisj-quic
    
The below reduced test is hitting an assert in SLP. It shows up recently after commit https://github.com/llvm/llvm-project/pull/202032

Reproducer link: https://godbolt.org/z/YqErcs6vM

Reduced test for SLP:

```
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
target triple = "aarch64-unknown-linux-gnu"

define i32 @foo() {
entry:
 %add8.i1467 = fadd double 0.000000e+00, 0.000000e+00
  %add.i1453 = fadd double 0.000000e+00, 0.000000e+00
  %add8.i1457 = fadd double %add.i1453, 0.000000e+00
  %mul213 = fmul double %add8.i1457, 0.000000e+00
  %mul.i1597 = fmul double %mul213, 0.000000e+00
  %mul427.neg = fmul double %mul.i1597, 0.000000e+00
  %mul547 = fmul double 0.000000e+00, 0.000000e+00
  %add548 = fadd double %mul427.neg, %mul547
  %sub317 = fadd double 0.000000e+00, 0.000000e+00
  %add552 = fadd double %add548, %sub317
  %add556 = fadd double %add552, 0.000000e+00
  %mul219 = fmul double %add8.i1467, 0.000000e+00
  %mul.i1607 = fmul double %mul219, %mul219
  %sub564 = fsub double %add556, %mul.i1607
  %arrayidx565 = getelementptr i8, ptr poison, i64 56
  store double %sub564, ptr %arrayidx565, align 8
  %mul592 = fmul double %mul219, 0.000000e+00
  %add3271 = fadd double 0.000000e+00, 0.000000e+00
  %mul328 = fmul double %add3271, 0.000000e+00
 %reass.mul2071 = fmul double %mul592, %mul328
  %mul474 = fmul double 0.000000e+00, 0.000000e+00
  %mul475 = fmul double %mul219, %mul474
 %add590 = fadd double %reass.mul2071, %mul475
  %add593 = fadd double %add590, 0.000000e+00
  %mul576 = fmul double %sub317, 0.000000e+00
  %0 = fadd double %mul576, %mul328
  %sub596 = fsub double %add593, %0
 %arrayidx597 = getelementptr i8, ptr poison, i64 64
  store double %sub596, ptr %arrayidx597, align 8
  ret i32 0
}
```


Command:
`opt -passes=slp-vectorizer test.ll`

Assertion signature:
```

opt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:5234: int llvm::slpvectorizer::BoUpSLP::ScheduleData::incrementUnscheduledDeps(int): Assertion `UnscheduledDeps >= 0 && "Expected valid number of unscheduled deps"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>
1.	Running pass "function(slp-vectorizer)" on module "<source>"
2.	Running pass "slp-vectorizer" on function "foo"
 #0 0x0000000005a7ea58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5a7ea58)
 #1 0x0000000005a7b894 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5a7b894)
 #2 0x0000000005a7ba0a SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007e0328e45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #4 0x00007e0328e9eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
 #5 0x00007e0328e4527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #6 0x00007e0328e288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #7 0x00007e0328e2881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #8 0x00007e0328e3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
 #9 0x000000000379b204 auto void llvm::slpvectorizer::BoUpSLP::BlockScheduling::schedule<std::set<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::slpvectorizer::BoUpSLP::scheduleBlock(llvm::slpvectorizer::BoUpSLP const&, llvm::slpvectorizer::BoUpSLP::BlockScheduling*)::ScheduleDataCompare, std::allocator<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*>>>(llvm::slpvectorizer::BoUpSLP const&, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, std::set<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::slpvectorizer::BoUpSLP::scheduleBlock(llvm::slpvectorizer::BoUpSLP const&, llvm::slpvectorizer::BoUpSLP::BlockScheduling*)::ScheduleDataCompare, std::allocator<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*>>&)::'lambda'(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>)::operator()(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>) const::'lambda'(std::set<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::slpvectorizer::BoUpSLP::scheduleBlock(llvm::slpvectorizer::BoUpSLP const&, llvm::slpvectorizer::BoUpSLP::BlockScheduling*)::ScheduleDataCompare, std::allocator<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*>>*, bool)::operator()<llvm::slpvectorizer::BoUpSLP::ScheduleData>(std::set<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::slpvectorizer::BoUpSLP::scheduleBlock(llvm::slpvectorizer::BoUpSLP const&, llvm::slpvectorizer::BoUpSLP::BlockScheduling*)::ScheduleDataCompare, std::allocator<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*>>*, bool) const SLPVectorizer.cpp:0:0
#10 0x000000000387ed28 void llvm::slpvectorizer::BoUpSLP::BlockScheduling::schedule<std::set<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::slpvectorizer::BoUpSLP::scheduleBlock(llvm::slpvectorizer::BoUpSLP const&, llvm::slpvectorizer::BoUpSLP::BlockScheduling*)::ScheduleDataCompare, std::allocator<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*>>>(llvm::slpvectorizer::BoUpSLP const&, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, std::set<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::slpvectorizer::BoUpSLP::scheduleBlock(llvm::slpvectorizer::BoUpSLP const&, llvm::slpvectorizer::BoUpSLP::BlockScheduling*)::ScheduleDataCompare, std::allocator<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*>>&)::'lambda'(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>)::operator()(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>) const SLPVectorizer.cpp:0:0
#11 0x0000000003882d48 llvm::slpvectorizer::BoUpSLP::scheduleBlock(llvm::slpvectorizer::BoUpSLP const&, llvm::slpvectorizer::BoUpSLP::BlockScheduling*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3882d48)
#12 0x000000000389e22a llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::SmallDenseSet<llvm::Value*, 4u, llvm::DenseMapInfo<llvm::Value*, void>> const&, llvm::Instruction*, llvm::ArrayRef<std::tuple<llvm::WeakTrackingVH, unsigned int, bool, bool>>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x389e22a)
#13 0x00000000038a2cbd llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x38a2cbd)
#14 0x00000000038cdc36 llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x38cdc36)
#15 0x00000000038ced35 (anonymous namespace)::StoreChainContext::vectorizeOneVF(llvm::TargetTransformInfo const&, unsigned int, llvm::SmallPtrSet<llvm::Value*, 16u>&, bool&, llvm::function_ref<std::optional<bool> (llvm::ArrayRef<llvm::Value*>, unsigned int, unsigned int, unsigned int&)>) (.constprop.0) SLPVectorizer.cpp:0:0
#16 0x00000000038d0cff llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x38d0cff)
#17 0x00000000038d1eec llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x38d1eec)
#18 0x00000000038d2e71 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0
#19 0x00000000038d3a7f llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x38d3a7f)
#20 0x00000000030ab8be llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x30ab8be)
#21 0x00000000057e32d7 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57e32d7)
#22 0x0000000000f3e41e 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+0xf3e41e)
#23 0x00000000057e1e46 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57e1e46)
#24 0x000000000098bcce 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+0x98bcce)
#25 0x00000000057e1477 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x57e1477)
#26 0x0000000000996289 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, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x996289)
#27 0x0000000000989aab optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x989aab)
#28 0x00007e0328e2a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to