Skip to content

Commit a6b2d48

Browse files
committed
[SLP] NFC. ShuffleInstructionBuilder::add V1->getType() is always a
FixedVectorType. castToScalarTyElem has a cast<VectorType>(V->getType()).
1 parent 74e51e3 commit a6b2d48

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12042,6 +12042,9 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
1204212042
/// Adds 2 input vectors and the mask for their shuffling.
1204312043
void add(Value *V1, Value *V2, ArrayRef<int> Mask) {
1204412044
assert(V1 && V2 && !Mask.empty() && "Expected non-empty input vectors.");
12045+
assert(isa<FixedVectorType>(V1->getType()) &&
12046+
isa<FixedVectorType>(V2->getType()) &&
12047+
"castToScalarTyElem expect V1 and V2 to be FixedVectorType");
1204512048
V1 = castToScalarTyElem(V1);
1204612049
V2 = castToScalarTyElem(V2);
1204712050
if (InVectors.empty()) {
@@ -12071,22 +12074,18 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
1207112074
}
1207212075
/// Adds another one input vector and the mask for the shuffling.
1207312076
void add(Value *V1, ArrayRef<int> Mask, bool = false) {
12077+
assert(isa<FixedVectorType>(V1->getType()) &&
12078+
"castToScalarTyElem expect V1 to be FixedVectorType");
1207412079
V1 = castToScalarTyElem(V1);
1207512080
if (InVectors.empty()) {
12076-
if (!isa<FixedVectorType>(V1->getType())) {
12077-
V1 = createShuffle(V1, nullptr, CommonMask);
12078-
CommonMask.assign(Mask.size(), PoisonMaskElem);
12079-
transformMaskAfterShuffle(CommonMask, Mask);
12080-
}
1208112081
InVectors.push_back(V1);
1208212082
CommonMask.assign(Mask.begin(), Mask.end());
1208312083
return;
1208412084
}
1208512085
const auto *It = find(InVectors, V1);
1208612086
if (It == InVectors.end()) {
1208712087
if (InVectors.size() == 2 ||
12088-
InVectors.front()->getType() != V1->getType() ||
12089-
!isa<FixedVectorType>(V1->getType())) {
12088+
InVectors.front()->getType() != V1->getType()) {
1209012089
Value *V = InVectors.front();
1209112090
if (InVectors.size() == 2) {
1209212091
V = createShuffle(InVectors.front(), InVectors.back(), CommonMask);
@@ -12120,9 +12119,7 @@ class BoUpSLP::ShuffleInstructionBuilder final : public BaseShuffleAnalysis {
1212012119
break;
1212112120
}
1212212121
}
12123-
int VF = CommonMask.size();
12124-
if (auto *FTy = dyn_cast<FixedVectorType>(V1->getType()))
12125-
VF = FTy->getNumElements();
12122+
int VF = cast<FixedVectorType>(V1->getType())->getNumElements();
1212612123
for (unsigned Idx = 0, Sz = CommonMask.size(); Idx < Sz; ++Idx)
1212712124
if (Mask[Idx] != PoisonMaskElem && CommonMask[Idx] == PoisonMaskElem)
1212812125
CommonMask[Idx] = Mask[Idx] + (It == InVectors.begin() ? 0 : VF);

0 commit comments

Comments
 (0)