Skip to content

Commit 06458ab

Browse files
committed
[SLP][REVEC] Make ShuffleCostEstimator::createShuffle support vector
instructions. The VF is relative to the number of elements in ScalarTy instead of the size of mask.
1 parent ba99d6f commit 06458ab

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8876,14 +8876,14 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
88768876
} else if (V1 && P2.isNull()) {
88778877
// Shuffle single vector.
88788878
ExtraCost += GetValueMinBWAffectedCost(V1);
8879-
CommonVF = cast<FixedVectorType>(V1->getType())->getNumElements();
8879+
CommonVF = getVF(V1);
88808880
assert(
88818881
all_of(Mask,
88828882
[=](int Idx) { return Idx < static_cast<int>(CommonVF); }) &&
88838883
"All elements in mask must be less than CommonVF.");
88848884
} else if (V1 && !V2) {
88858885
// Shuffle vector and tree node.
8886-
unsigned VF = cast<FixedVectorType>(V1->getType())->getNumElements();
8886+
unsigned VF = getVF(V1);
88878887
const TreeEntry *E2 = P2.get<const TreeEntry *>();
88888888
CommonVF = std::max(VF, E2->getVectorFactor());
88898889
assert(all_of(Mask,
@@ -8909,7 +8909,7 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
89098909
V2 = getAllOnesValue(*R.DL, getWidenedType(ScalarTy, CommonVF));
89108910
} else if (!V1 && V2) {
89118911
// Shuffle vector and tree node.
8912-
unsigned VF = cast<FixedVectorType>(V2->getType())->getNumElements();
8912+
unsigned VF = getVF(V2);
89138913
const TreeEntry *E1 = P1.get<const TreeEntry *>();
89148914
CommonVF = std::max(VF, E1->getVectorFactor());
89158915
assert(all_of(Mask,
@@ -8937,9 +8937,8 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
89378937
V2 = getAllOnesValue(*R.DL, getWidenedType(ScalarTy, CommonVF));
89388938
} else {
89398939
assert(V1 && V2 && "Expected both vectors.");
8940-
unsigned VF = cast<FixedVectorType>(V1->getType())->getNumElements();
8941-
CommonVF =
8942-
std::max(VF, cast<FixedVectorType>(V2->getType())->getNumElements());
8940+
unsigned VF = getVF(V1);
8941+
CommonVF = std::max(VF, getVF(V2));
89438942
assert(all_of(Mask,
89448943
[=](int Idx) {
89458944
return Idx < 2 * static_cast<int>(CommonVF);
@@ -8957,6 +8956,9 @@ class BoUpSLP::ShuffleCostEstimator : public BaseShuffleAnalysis {
89578956
V2 = getAllOnesValue(*R.DL, getWidenedType(ScalarTy, CommonVF));
89588957
}
89598958
}
8959+
if (auto *VecTy = dyn_cast<FixedVectorType>(ScalarTy))
8960+
transformScalarShuffleIndiciesToVector(VecTy->getNumElements(),
8961+
CommonMask);
89608962
InVectors.front() =
89618963
Constant::getNullValue(getWidenedType(ScalarTy, CommonMask.size()));
89628964
if (InVectors.size() == 2)

0 commit comments

Comments
 (0)