[PATCH] D149973: [SLP][NFC]Add processBuildVector member function, NFC.
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 5 11:03:26 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2672c6e4dc61: [SLP][NFC]Add processBuildVector member function, NFC. (authored by ABataev).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149973/new/
https://reviews.llvm.org/D149973
Files:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -2455,6 +2455,12 @@
/// \p E.
Value *vectorizeOperand(TreeEntry *E, unsigned NodeIdx);
+ /// Create a new vector from a list of scalar values. Produces a sequence
+ /// which exploits values reused across lanes, and arranges the inserts
+ /// for ease of later optimization.
+ template <typename BVTy, typename ResTy, typename... Args>
+ ResTy processBuildVector(const TreeEntry *E, Args &...Params);
+
/// Create a new vector from a list of scalar values. Produces a sequence
/// which exploits values reused across lanes, and arranges the inserts
/// for ease of later optimization.
@@ -9603,7 +9609,8 @@
return vectorizeTree(I->get());
}
-Value *BoUpSLP::createBuildVector(const TreeEntry *E) {
+template <typename BVTy, typename ResTy, typename... Args>
+ResTy BoUpSLP::processBuildVector(const TreeEntry *E, Args &...Params) {
assert(E->State == TreeEntry::NeedToGather && "Expected gather node.");
unsigned VF = E->getVectorFactor();
@@ -9644,8 +9651,8 @@
std::fill(Mask.begin(), Mask.end(), I);
return true;
};
- ShuffleInstructionBuilder ShuffleBuilder(Builder, *this);
- Value *Vec = nullptr;
+ BVTy ShuffleBuilder(Params...);
+ ResTy Res = ResTy();
SmallVector<int> Mask;
SmallVector<int> ExtractMask;
std::optional<TargetTransformInfo::ShuffleKind> ExtractShuffle;
@@ -9702,8 +9709,8 @@
Mask[I] = Entries.front()->findLaneForValue(V);
}
ShuffleBuilder.add(Entries.front()->VectorizedValue, Mask);
- Vec = ShuffleBuilder.finalize(E->ReuseShuffleIndices);
- return Vec;
+ Res = ShuffleBuilder.finalize(E->ReuseShuffleIndices);
+ return Res;
}
if (!Resized) {
unsigned VF1 = Entries.front()->getVectorFactor();
@@ -9917,9 +9924,9 @@
(IsSingleShuffle && ((IsIdentityShuffle &&
IsNonPoisoned) || IsUsedInExpr) && isa<UndefValue>(V));
}))
- Vec = ShuffleBuilder.finalize(E->ReuseShuffleIndices);
+ Res = ShuffleBuilder.finalize(E->ReuseShuffleIndices);
else
- Vec = ShuffleBuilder.finalize(
+ Res = ShuffleBuilder.finalize(
E->ReuseShuffleIndices, E->Scalars.size(),
[&](Value *&Vec, SmallVectorImpl<int> &Mask) {
TryPackScalars(NonConstants, Mask, /*IsRootPoison=*/false);
@@ -9929,9 +9936,9 @@
// Gather unique scalars and all constants.
SmallVector<int> ReuseMask(GatheredScalars.size(), PoisonMaskElem);
TryPackScalars(GatheredScalars, ReuseMask, /*IsRootPoison=*/true);
- Vec = ShuffleBuilder.gather(GatheredScalars);
- ShuffleBuilder.add(Vec, ReuseMask);
- Vec = ShuffleBuilder.finalize(E->ReuseShuffleIndices);
+ Value *BV = ShuffleBuilder.gather(GatheredScalars);
+ ShuffleBuilder.add(BV, ReuseMask);
+ Res = ShuffleBuilder.finalize(E->ReuseShuffleIndices);
} else {
// Gather all constants.
SmallVector<int> Mask(E->Scalars.size(), PoisonMaskElem);
@@ -9939,14 +9946,19 @@
if (!isa<PoisonValue>(V))
Mask[I] = I;
}
- Vec = ShuffleBuilder.gather(E->Scalars);
- ShuffleBuilder.add(Vec, Mask);
- Vec = ShuffleBuilder.finalize(E->ReuseShuffleIndices);
+ Value *BV = ShuffleBuilder.gather(E->Scalars);
+ ShuffleBuilder.add(BV, Mask);
+ Res = ShuffleBuilder.finalize(E->ReuseShuffleIndices);
}
if (NeedFreeze)
- Vec = ShuffleBuilder.createFreeze(Vec);
- return Vec;
+ Res = ShuffleBuilder.createFreeze(Res);
+ return Res;
+}
+
+Value *BoUpSLP::createBuildVector(const TreeEntry *E) {
+ return processBuildVector<ShuffleInstructionBuilder, Value *>(E, Builder,
+ *this);
}
Value *BoUpSLP::vectorizeTree(TreeEntry *E) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149973.519928.patch
Type: text/x-patch
Size: 3978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230505/3c203e72/attachment.bin>
More information about the llvm-commits
mailing list