Skip to content

[SLP] NFC. Remove the useless check for alternate instruction. #117293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5477,11 +5477,13 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
// Try build correct order for extractelement instructions.
SmallVector<int> ReusedMask(TE.ReuseShuffleIndices.begin(),
TE.ReuseShuffleIndices.end());
if (TE.getOpcode() == Instruction::ExtractElement && !TE.isAltShuffle() &&
if (TE.getOpcode() == Instruction::ExtractElement &&
all_of(TE.Scalars, [Sz](Value *V) {
std::optional<unsigned> Idx = getExtractIndex(cast<Instruction>(V));
return Idx && *Idx < Sz;
})) {
assert(!TE.isAltShuffle() && "Alternate instructions are only supported "
"by BinaryOperator and CastInst.");
SmallVector<int> ReorderMask(Sz, PoisonMaskElem);
if (TE.ReorderIndices.empty())
std::iota(ReorderMask.begin(), ReorderMask.end(), 0);
Expand Down Expand Up @@ -5526,9 +5528,11 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom) {
if ((TE.State == TreeEntry::Vectorize ||
TE.State == TreeEntry::StridedVectorize) &&
(isa<LoadInst, ExtractElementInst, ExtractValueInst>(TE.getMainOp()) ||
(TopToBottom && isa<StoreInst, InsertElementInst>(TE.getMainOp()))) &&
!TE.isAltShuffle())
(TopToBottom && isa<StoreInst, InsertElementInst>(TE.getMainOp())))) {
assert(!TE.isAltShuffle() && "Alternate instructions are only supported by "
"BinaryOperator and CastInst.");
return TE.ReorderIndices;
}
if (TE.State == TreeEntry::Vectorize && TE.getOpcode() == Instruction::PHI) {
if (!TE.ReorderIndices.empty())
return TE.ReorderIndices;
Expand Down Expand Up @@ -5924,8 +5928,11 @@ void BoUpSLP::reorderTopToBottom() {
continue;
}
// Stores actually store the mask, not the order, need to invert.
if (OpTE->State == TreeEntry::Vectorize && !OpTE->isAltShuffle() &&
if (OpTE->State == TreeEntry::Vectorize &&
OpTE->getOpcode() == Instruction::Store && !Order.empty()) {
assert(!OpTE->isAltShuffle() &&
"Alternate instructions are only supported by BinaryOperator "
"and CastInst.");
SmallVector<int> Mask;
inversePermutation(Order, Mask);
unsigned E = Order.size();
Expand Down Expand Up @@ -6188,8 +6195,11 @@ void BoUpSLP::reorderBottomToTop(bool IgnoreReorder) {
return P.second == OpTE;
});
// Stores actually store the mask, not the order, need to invert.
if (OpTE->State == TreeEntry::Vectorize && !OpTE->isAltShuffle() &&
if (OpTE->State == TreeEntry::Vectorize &&
OpTE->getOpcode() == Instruction::Store && !Order.empty()) {
assert(!OpTE->isAltShuffle() &&
"Alternate instructions are only supported by BinaryOperator "
"and CastInst.");
SmallVector<int> Mask;
inversePermutation(Order, Mask);
unsigned E = Order.size();
Expand Down
Loading