Skip to content

Commit df0fd3a

Browse files
[SLP]Try to vectorize small graph with extractelements, used in buildvector.
If the graph incudes only single "gather" node with only extractelements/undefs, which used only in insertelement-based buildvector sequences, it still might be profitable to vectorize it. Need to rely on the cost model, not throw this graph away immediately. Reviewers: RKSimon Reviewed By: RKSimon Pull Request: llvm#83581
1 parent ce95a56 commit df0fd3a

File tree

6 files changed

+413
-387
lines changed

6 files changed

+413
-387
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8985,6 +8985,20 @@ bool BoUpSLP::isTreeTinyAndNotFullyVectorizable(bool ForReduction) const {
89858985
if (isFullyVectorizableTinyTree(ForReduction))
89868986
return false;
89878987

8988+
// Check if any of the gather node forms an insertelement buildvector
8989+
// somewhere.
8990+
if (any_of(VectorizableTree, [](const std::unique_ptr<TreeEntry> &TE) {
8991+
return TE->State == TreeEntry::NeedToGather &&
8992+
all_of(TE->Scalars, [](Value *V) {
8993+
return isa<ExtractElementInst, UndefValue>(V) ||
8994+
(!V->hasNUsesOrMore(UsesLimit) &&
8995+
any_of(V->users(), [](User *U) {
8996+
return isa<InsertElementInst>(U);
8997+
}));
8998+
});
8999+
}))
9000+
return false;
9001+
89889002
assert(VectorizableTree.empty()
89899003
? ExternalUses.empty()
89909004
: true && "We shouldn't have any external users");

0 commit comments

Comments
 (0)