@@ -5477,11 +5477,13 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
5477
5477
// Try build correct order for extractelement instructions.
5478
5478
SmallVector<int> ReusedMask(TE.ReuseShuffleIndices.begin(),
5479
5479
TE.ReuseShuffleIndices.end());
5480
- if (TE.getOpcode() == Instruction::ExtractElement && !TE.isAltShuffle() &&
5480
+ if (TE.getOpcode() == Instruction::ExtractElement &&
5481
5481
all_of(TE.Scalars, [Sz](Value *V) {
5482
5482
std::optional<unsigned> Idx = getExtractIndex(cast<Instruction>(V));
5483
5483
return Idx && *Idx < Sz;
5484
5484
})) {
5485
+ assert(!TE.isAltShuffle() && "Alternate instructions are only supported "
5486
+ "by BinaryOperator and CastInst.");
5485
5487
SmallVector<int> ReorderMask(Sz, PoisonMaskElem);
5486
5488
if (TE.ReorderIndices.empty())
5487
5489
std::iota(ReorderMask.begin(), ReorderMask.end(), 0);
@@ -5526,9 +5528,11 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
5526
5528
if ((TE.State == TreeEntry::Vectorize ||
5527
5529
TE.State == TreeEntry::StridedVectorize) &&
5528
5530
(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.");
5531
5534
return TE.ReorderIndices;
5535
+ }
5532
5536
if (TE.State == TreeEntry::Vectorize && TE.getOpcode() == Instruction::PHI) {
5533
5537
if (!TE.ReorderIndices.empty())
5534
5538
return TE.ReorderIndices;
@@ -5924,8 +5928,11 @@ void BoUpSLP::reorderTopToBottom() {
5924
5928
continue;
5925
5929
}
5926
5930
// 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 &&
5928
5932
OpTE->getOpcode() == Instruction::Store && !Order.empty()) {
5933
+ assert(!OpTE->isAltShuffle() &&
5934
+ "Alternate instructions are only supported by BinaryOperator "
5935
+ "and CastInst.");
5929
5936
SmallVector<int> Mask;
5930
5937
inversePermutation(Order, Mask);
5931
5938
unsigned E = Order.size();
@@ -6188,8 +6195,11 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
6188
6195
return P.second == OpTE;
6189
6196
});
6190
6197
// 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 &&
6192
6199
OpTE->getOpcode() == Instruction::Store && !Order.empty()) {
6200
+ assert(!OpTE->isAltShuffle() &&
6201
+ "Alternate instructions are only supported by BinaryOperator "
6202
+ "and CastInst.");
6193
6203
SmallVector<int> Mask;
6194
6204
inversePermutation(Order, Mask);
6195
6205
unsigned E = Order.size();
0 commit comments