<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107037>107037</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SLPVectorizer] Assertion `Val && "isa<> used on a null pointer"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:SLPVectorizer,
crash-on-valid
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
dtcxzyw
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dtcxzyw
</td>
</tr>
</table>
<pre>
Reproducer: https://godbolt.org/z/14Ea4as18
```
; bin/opt -passes=slp-vectorizer test.ll -S
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define i8 @test() {
entry:
%0 = trunc i32 0 to i8
%1 = add i8 %0, 0
%2 = add i8 %0, 0
%3 = add i8 %0, 0
%4 = add i8 %0, 0
%5 = trunc i32 0 to i8
%6 = or i8 %5, %0
%7 = or i8 %6, %2
%8 = or i8 %7, %3
%9 = or i8 %8, %0
%10 = or i8 %9, %4
%conv223.us.us.us.i.us.us.22.i.us.4 = or i8 %10, %1
%11 = trunc i32 0 to i8
%12 = add i8 %11, 0
%conv223.us.us.us.peel.i.i.us.5 = or i8 %conv223.us.us.us.i.us.us.22.i.us.4, %12
%13 = add i8 %11, 0
%14 = add i8 %11, 0
%15 = add i8 %11, 0
%16 = trunc i32 0 to i8
%17 = or i8 %13, %16
%18 = or i8 %17, %14
%19 = or i8 %18, %11
%20 = or i8 %19, %15
%conv223.us.us.us.i.us.us.22.i.us.5 = or i8 %20, %conv223.us.us.us.peel.i.i.us.5
%21 = trunc i32 0 to i8
%conv223.us.us.us.i.us.us.22.i.us.6 = or i8 %21, %conv223.us.us.us.i.us.us.22.i.us.5
ret i8 %conv223.us.us.us.i.us.us.22.i.us.6
}
```
```
opt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/include/llvm/Support/Casting.h:109: static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = llvm::MetadataAsValue; From = llvm::Value]: Assertion `Val && "isa<> used on a null pointer"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: bin/opt -passes=slp-vectorizer reduced.ll -S
1. Running pass "function(slp-vectorizer)" on module "reduced.ll"
2. Running pass "slp-vectorizer" on function "test"
#0 0x00007adbd8e12c32 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x212c32)
#1 0x00007adbd8e0faff llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x20faff)
#2 0x00007adbd8e0fc45 SignalHandler(int) Signals.cpp:0:0
#3 0x00007adbd8842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007adbd88969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007adbd88969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007adbd88969fc pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007adbd8842476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007adbd88287f3 abort ./stdlib/abort.c:81:7
#9 0x00007adbd882871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007adbd8839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00007adbd1f02fbb isGuaranteedNotToBeUndefOrPoison(llvm::Value const*, llvm::AssumptionCache*, llvm::Instruction const*, llvm::DominatorTree const*, unsigned int, UndefPoisonKind) ValueTracking.cpp:0:0
#12 0x00007adbd1f0313f isGuaranteedNotToBeUndefOrPoison(llvm::Value const*, llvm::AssumptionCache*, llvm::Instruction const*, llvm::DominatorTree const*, unsigned int, UndefPoisonKind) ValueTracking.cpp:0:0
#13 0x00007adbd3b3aad9 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&)::'lambda2'(llvm::Value*, llvm::Value*)::operator()(llvm::Value*, llvm::Value*) const SLPVectorizer.cpp:0:0
#14 0x00007adbd3bbcaa0 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0
#15 0x00007adbd3bbf18a llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1bf18a)
#16 0x00007adbd3bc3788 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1c3788)
#17 0x00007adbd3bc799e llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1c799e)
#18 0x00007adbd3bce3cf llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1ce3cf)
#19 0x00007adbd3bcf036 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1cf036)
#20 0x00007adbd44d3fb5 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.20.0git+0xd3fb5)
#21 0x00007adbd1751d0d llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x351d0d)
#22 0x00007adbd7ad7f85 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.20.0git+0xd7f85)
#23 0x00007adbd1750876 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x350876)
#24 0x00007adbd7ad8945 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.20.0git+0xd8945)
#25 0x00007adbd174e83a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x34e83a)
#26 0x00007adbd90fefc7 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) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x2cfc7)
#27 0x00007adbd910a962 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x38962)
#28 0x00007adbd8829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#29 0x00007adbd8829e40 call_init ./csu/../csu/libc-start.c:128:20
#30 0x00007adbd8829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#31 0x0000556f487ba095 _start (bin/opt+0x1095)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1z46jS_jXkhrJLQt8XuXCceGfqTXZSSTb73rmQQA4nCFSAMpP59adAsi1kTz7mzJ6dsx8160ioedT9dDcNAqw12whKT0FyBhAipvry9fkzQAgk5ye4Mw9SnQ6NJ6Ukz6c3tFWSdBVVIFrAB2NaDaIFQCuAVhtJSsnNXKoNQKuvAK3C-ALHWIc5CM5BsABpMPzrb6MzWDIB0Eq2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