Skip to content

Commit 55e9afa

Browse files
authored
[SLP] NFC. Remove the useless check for alternate instruction. (#117293)
Only BinaryOperator and CastInst support alternate instruction. It always returns false for TreeEntry::isAltShuffle if an instruction is ExtractElementInst, ExtractValueInst, LoadInst, StoreInst or InsertElementInst.
1 parent 063a6f7 commit 55e9afa

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5477,11 +5477,13 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
54775477
// Try build correct order for extractelement instructions.
54785478
SmallVector<int> ReusedMask(TE.ReuseShuffleIndices.begin(),
54795479
TE.ReuseShuffleIndices.end());
5480-
if (TE.getOpcode() == Instruction::ExtractElement && !TE.isAltShuffle() &&
5480+
if (TE.getOpcode() == Instruction::ExtractElement &&
54815481
all_of(TE.Scalars, [Sz](Value *V) {
54825482
std::optional<unsigned> Idx = getExtractIndex(cast<Instruction>(V));
54835483
return Idx && *Idx < Sz;
54845484
})) {
5485+
assert(!TE.isAltShuffle() && "Alternate instructions are only supported "
5486+
"by BinaryOperator and CastInst.");
54855487
SmallVector<int> ReorderMask(Sz, PoisonMaskElem);
54865488
if (TE.ReorderIndices.empty())
54875489
std::iota(ReorderMask.begin(), ReorderMask.end(), 0);
@@ -5526,9 +5528,11 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
55265528
if ((TE.State == TreeEntry::Vectorize ||
55275529
TE.State == TreeEntry::StridedVectorize) &&
55285530
(isa<LoadInst, ExtractElementInst, ExtractValueInst>(TE.getMainOp()) ||
5529-
(TopToBottom && isa<StoreInst, InsertElementInst>(TE.getMainOp()))) &&
5530-
!TE.isAltShuffle())
5531+
(TopToBottom && isa<StoreInst, InsertElementInst>(TE.getMainOp())))) {
5532+
assert(!TE.isAltShuffle() && "Alternate instructions are only supported by "
5533+
"BinaryOperator and CastInst.");
55315534
return TE.ReorderIndices;
5535+
}
55325536
if (TE.State == TreeEntry::Vectorize && TE.getOpcode() == Instruction::PHI) {
55335537
if (!TE.ReorderIndices.empty())
55345538
return TE.ReorderIndices;
@@ -5924,8 +5928,11 @@ void BoUpSLP::reorderTopToBottom() {
59245928
continue;
59255929
}
59265930
// Stores actually store the mask, not the order, need to invert.
5927-
if (OpTE->State == TreeEntry::Vectorize && !OpTE->isAltShuffle() &&
5931+
if (OpTE->State == TreeEntry::Vectorize &&
59285932
OpTE->getOpcode() == Instruction::Store && !Order.empty()) {
5933+
assert(!OpTE->isAltShuffle() &&
5934+
"Alternate instructions are only supported by BinaryOperator "
5935+
"and CastInst.");
59295936
SmallVector<int> Mask;
59305937
inversePermutation(Order, Mask);
59315938
unsigned E = Order.size();
@@ -6188,8 +6195,11 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
61886195
return P.second == OpTE;
61896196
});
61906197
// Stores actually store the mask, not the order, need to invert.
6191-
if (OpTE->State == TreeEntry::Vectorize && !OpTE->isAltShuffle() &&
6198+
if (OpTE->State == TreeEntry::Vectorize &&
61926199
OpTE->getOpcode() == Instruction::Store && !Order.empty()) {
6200+
assert(!OpTE->isAltShuffle() &&
6201+
"Alternate instructions are only supported by BinaryOperator "
6202+
"and CastInst.");
61936203
SmallVector<int> Mask;
61946204
inversePermutation(Order, Mask);
61956205
unsigned E = Order.size();

0 commit comments

Comments
 (0)