<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57447>57447</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[SLPVectorizer] Assertion `!getTreeEntry(V) && "Scalar already in tree!"' failed
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:SLPVectorizer,
llvm:crash
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nikic
</td>
</tr>
</table>
<pre>
```
; RUN: opt -S -slp-vectorizer < %s
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @test(i1 %c, ptr %arg) #0 {
br i1 %c, label %if, label %else
if:
%i2.0 = load i64, ptr %arg, align 8
%arg2.1 = getelementptr inbounds i8, ptr %arg, i64 8
%i2.1 = load i64, ptr %arg2.1, align 8
%arg2.2 = getelementptr inbounds i8, ptr %arg, i64 24
%i2.2 = load i64, ptr %arg2.2, align 8
%arg2.3 = getelementptr inbounds i8, ptr %arg, i64 32
%i2.3 = load i64, ptr %arg2.3, align 8
br label %join
else:
%i.0 = load i64, ptr %arg, align 8
%arg.1 = getelementptr inbounds i8, ptr %arg, i64 8
%i.1 = load i64, ptr %arg.1, align 8
%arg.2 = getelementptr inbounds i8, ptr %arg, i64 24
%i.2 = load i64, ptr %arg.2, align 8
%arg.3 = getelementptr inbounds i8, ptr %arg, i64 32
%i.3 = load i64, ptr %arg.3, align 8
br label %join
join:
%phi.3 = phi i64 [ %i2.3, %if ], [ %i.3, %else ]
%phi.2 = phi i64 [ %i2.2, %if ], [ %i.2, %else ]
%phi.1 = phi i64 [ %i2.1, %if ], [ %i.1, %else ]
%phi.0 = phi i64 [ %i2.0, %if ], [ %i.0, %else ]
ret void
}
attributes #0 = { "target-cpu"="skylake" }
```
```
opt: /home/npopov/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:2562: llvm::slpvectorizer::BoUpSLP::TreeEntry* llvm::slpvectorizer::BoUpSLP::newTreeEntry(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP::TreeEntry::EntryState, llvm::Optional<llvm::slpvectorizer::BoUpSLP::ScheduleData*>, const {anonymous}::InstructionsState&, const llvm::slpvectorizer::BoUpSLP::EdgeInfo&, llvm::ArrayRef<int>, llvm::ArrayRef<unsigned int>): Assertion `!getTreeEntry(V) && "Scalar already in tree!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: build/bin/opt -S -slp-vectorizer
#0 0x00000000032bfc31 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x00000000032bd4b4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f32146dfdc0 __restore_rt (/lib64/libc.so.6+0x54dc0)
#3 0x00007f321472c56c __pthread_kill_implementation (/lib64/libc.so.6+0xa156c)
#4 0x00007f32146dfd16 gsignal (/lib64/libc.so.6+0x54d16)
#5 0x00007f32146b37f3 abort (/lib64/libc.so.6+0x287f3)
#6 0x00007f32146b371b _nl_load_domain.cold (/lib64/libc.so.6+0x2871b)
#7 0x00007f32146d8c66 (/lib64/libc.so.6+0x4dc66)
#8 0x00000000035787d5 llvm::slpvectorizer::BoUpSLP::newTreeEntry(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP::TreeEntry::EntryState, llvm::Optional<llvm::slpvectorizer::BoUpSLP::ScheduleData*>, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, llvm::ArrayRef<int>, llvm::ArrayRef<unsigned int>) (.isra.0) SLPVectorizer.cpp:0:0
#9 0x00000000035a02f9 llvm::slpvectorizer::BoUpSLP::buildTree_rec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) (build/bin/opt+0x35a02f9)
#10 0x000000000359e281 llvm::slpvectorizer::BoUpSLP::buildTree_rec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) (build/bin/opt+0x359e281)
#11 0x000000000359fed3 llvm::slpvectorizer::BoUpSLP::buildTree_rec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) (build/bin/opt+0x359fed3)
#12 0x00000000035b3609 llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (build/bin/opt+0x35b3609)
#13 0x00000000035b7256 bool tryToVectorizeSequence<llvm::Value>(llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<unsigned int (llvm::Value*)>, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::Value*>, bool)>, bool) (.constprop.0) SLPVectorizer.cpp:0:0
#14 0x00000000035b882d llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (build/bin/opt+0x35b882d)
#15 0x00000000035bd137 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
#16 0x00000000035bdef0 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build/bin/opt+0x35bdef0)
```
cc @alexey-bataev
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWF2P2jgU_TXhxQIlDgnhgQcYGO1Is7ujMu0rchIDLo6dtZPp0F-_105gMF_z0VZaVVtNwY59z_X1PTm-JpX5duTFfvv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