Skip to content

Commit 5ff5980

Browse files
mstorsjomahesh-attarde
authored andcommitted
Revert "[SLP] Check if the user node has state before trying getting main instruction/opcode"
This reverts commit c9cea24. This is being reverted as it is intermixed with another commit (898bba3) that needs to be reverted.
1 parent 5cf8ff3 commit 5ff5980

File tree

2 files changed

+33
-93
lines changed

2 files changed

+33
-93
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6861,7 +6861,7 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom,
68616861
return std::move(ResOrder);
68626862
}
68636863
if (TE.State == TreeEntry::StridedVectorize && !TopToBottom &&
6864-
(!TE.UserTreeIndex || !TE.UserTreeIndex.UserTE->hasState() ||
6864+
(!TE.UserTreeIndex ||
68656865
!Instruction::isBinaryOp(TE.UserTreeIndex.UserTE->getOpcode())) &&
68666866
(TE.ReorderIndices.empty() || isReverseOrder(TE.ReorderIndices)))
68676867
return std::nullopt;
@@ -15704,8 +15704,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1570415704
const BasicBlock *TEInsertBlock = nullptr;
1570515705
// Main node of PHI entries keeps the correct order of operands/incoming
1570615706
// blocks.
15707-
if (auto *PHI = dyn_cast_or_null<PHINode>(
15708-
TEUseEI.UserTE->hasState() ? TEUseEI.UserTE->getMainOp() : nullptr);
15707+
if (auto *PHI = dyn_cast<PHINode>(TEUseEI.UserTE->getMainOp());
1570915708
PHI && TEUseEI.UserTE->State != TreeEntry::SplitVectorize) {
1571015709
TEInsertBlock = PHI->getIncomingBlock(TEUseEI.EdgeIdx);
1571115710
TEInsertPt = TEInsertBlock->getTerminator();
@@ -15804,8 +15803,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1580415803
"Expected only single user of a gather node.");
1580515804
const EdgeInfo &UseEI = TEPtr->UserTreeIndex;
1580615805

15807-
PHINode *UserPHI = (UseEI.UserTE->State != TreeEntry::SplitVectorize &&
15808-
UseEI.UserTE->hasState())
15806+
PHINode *UserPHI = UseEI.UserTE->State != TreeEntry::SplitVectorize
1580915807
? dyn_cast<PHINode>(UseEI.UserTE->getMainOp())
1581015808
: nullptr;
1581115809
Instruction *InsertPt =
@@ -15818,8 +15816,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1581815816
TEUseEI.UserTE->isAltShuffle()) &&
1581915817
all_of(TEUseEI.UserTE->Scalars, isUsedOutsideBlock)) {
1582015818
if (UseEI.UserTE->State != TreeEntry::Vectorize ||
15821-
(UseEI.UserTE->hasState() &&
15822-
UseEI.UserTE->getOpcode() == Instruction::PHI &&
15819+
(UseEI.UserTE->getOpcode() == Instruction::PHI &&
1582315820
!UseEI.UserTE->isAltShuffle()) ||
1582415821
!all_of(UseEI.UserTE->Scalars, isUsedOutsideBlock))
1582515822
continue;
@@ -16441,31 +16438,24 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
1644116438
// Get the basic block this bundle is in. All instructions in the bundle
1644216439
// should be in this block (except for extractelement-like instructions with
1644316440
// constant indices or gathered loads or copyables).
16444-
Instruction *Front;
16445-
unsigned Opcode;
16446-
if (E->hasState()) {
16447-
Front = E->getMainOp();
16448-
Opcode = E->getOpcode();
16449-
} else {
16450-
Front = cast<Instruction>(*find_if(E->Scalars, IsaPred<Instruction>));
16451-
Opcode = Front->getOpcode();
16452-
}
16441+
auto *Front = E->getMainOp();
1645316442
auto *BB = Front->getParent();
16454-
assert(
16455-
((GatheredLoadsEntriesFirst.has_value() && Opcode == Instruction::Load &&
16456-
E->isGather() && E->Idx < *GatheredLoadsEntriesFirst) ||
16457-
E->State == TreeEntry::SplitVectorize || E->hasCopyableElements() ||
16458-
all_of(E->Scalars,
16459-
[=](Value *V) -> bool {
16460-
if (Opcode == Instruction::GetElementPtr &&
16461-
!isa<GetElementPtrInst>(V))
16462-
return true;
16463-
auto *I = dyn_cast<Instruction>(V);
16464-
return !I || !E->getMatchingMainOpOrAltOp(I) ||
16465-
I->getParent() == BB || isVectorLikeInstWithConstOps(I);
16466-
})) &&
16467-
"Expected gathered loads or GEPs or instructions from same basic "
16468-
"block.");
16443+
assert(((GatheredLoadsEntriesFirst.has_value() &&
16444+
E->getOpcode() == Instruction::Load && E->isGather() &&
16445+
E->Idx < *GatheredLoadsEntriesFirst) ||
16446+
E->State == TreeEntry::SplitVectorize || E->hasCopyableElements() ||
16447+
all_of(E->Scalars,
16448+
[=](Value *V) -> bool {
16449+
if (E->getOpcode() == Instruction::GetElementPtr &&
16450+
!isa<GetElementPtrInst>(V))
16451+
return true;
16452+
auto *I = dyn_cast<Instruction>(V);
16453+
return !I || !E->getMatchingMainOpOrAltOp(I) ||
16454+
I->getParent() == BB ||
16455+
isVectorLikeInstWithConstOps(I);
16456+
})) &&
16457+
"Expected gathered loads or GEPs or instructions from same basic "
16458+
"block.");
1646916459

1647016460
auto FindLastInst = [&]() {
1647116461
Instruction *LastInst = Front;
@@ -16480,13 +16470,13 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
1648016470
LastInst = I;
1648116471
continue;
1648216472
}
16483-
assert(((Opcode == Instruction::GetElementPtr &&
16473+
assert(((E->getOpcode() == Instruction::GetElementPtr &&
1648416474
!isa<GetElementPtrInst>(I)) ||
1648516475
E->State == TreeEntry::SplitVectorize ||
1648616476
(isVectorLikeInstWithConstOps(LastInst) &&
1648716477
isVectorLikeInstWithConstOps(I)) ||
1648816478
(GatheredLoadsEntriesFirst.has_value() &&
16489-
Opcode == Instruction::Load && E->isGather() &&
16479+
E->getOpcode() == Instruction::Load && E->isGather() &&
1649016480
E->Idx < *GatheredLoadsEntriesFirst)) &&
1649116481
"Expected vector-like or non-GEP in GEP node insts only.");
1649216482
if (!DT->isReachableFromEntry(LastInst->getParent())) {
@@ -16522,11 +16512,11 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
1652216512
FirstInst = I;
1652316513
continue;
1652416514
}
16525-
assert(((Opcode == Instruction::GetElementPtr &&
16526-
!isa<GetElementPtrInst>(I)) ||
16527-
(isVectorLikeInstWithConstOps(FirstInst) &&
16528-
isVectorLikeInstWithConstOps(I))) &&
16529-
"Expected vector-like or non-GEP in GEP node insts only.");
16515+
assert(((E->getOpcode() == Instruction::GetElementPtr &&
16516+
!isa<GetElementPtrInst>(I)) ||
16517+
(isVectorLikeInstWithConstOps(FirstInst) &&
16518+
isVectorLikeInstWithConstOps(I))) &&
16519+
"Expected vector-like or non-GEP in GEP node insts only.");
1653016520
if (!DT->isReachableFromEntry(FirstInst->getParent())) {
1653116521
FirstInst = I;
1653216522
continue;
@@ -16564,7 +16554,7 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
1656416554
// Set insertpoint for gathered loads to the very first load.
1656516555
if (GatheredLoadsEntriesFirst.has_value() &&
1656616556
E->Idx >= *GatheredLoadsEntriesFirst && !E->isGather() &&
16567-
Opcode == Instruction::Load) {
16557+
E->getOpcode() == Instruction::Load) {
1656816558
Res = FindFirstInst();
1656916559
EntryToLastInstruction.try_emplace(E, Res);
1657016560
return *Res;
@@ -16596,7 +16586,7 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
1659616586
};
1659716587
const ScheduleBundle *Bundle = FindScheduleBundle(E);
1659816588
if (!E->isGather() && !Bundle) {
16599-
if ((Opcode == Instruction::GetElementPtr &&
16589+
if ((E->getOpcode() == Instruction::GetElementPtr &&
1660016590
any_of(E->Scalars,
1660116591
[](Value *V) {
1660216592
return !isa<GetElementPtrInst>(V) && isa<Instruction>(V);
@@ -21011,10 +21001,9 @@ void BoUpSLP::computeMinimumValueSizes() {
2101121001
if (!isa<CastInst, BinaryOperator, FreezeInst, PHINode,
2101221002
SelectInst>(U) ||
2101321003
isa<SIToFPInst, UIToFPInst>(U) ||
21014-
(UserTE->hasState() &&
21015-
(!isa<CastInst, BinaryOperator, FreezeInst, PHINode,
21016-
SelectInst>(UserTE->getMainOp()) ||
21017-
isa<SIToFPInst, UIToFPInst>(UserTE->getMainOp()))))
21004+
!isa<CastInst, BinaryOperator, FreezeInst, PHINode,
21005+
SelectInst>(UserTE->getMainOp()) ||
21006+
isa<SIToFPInst, UIToFPInst>(UserTE->getMainOp()))
2101821007
return true;
2101921008
unsigned UserTESz = DL->getTypeSizeInBits(
2102021009
UserTE->Scalars.front()->getType());
@@ -21264,7 +21253,6 @@ void BoUpSLP::computeMinimumValueSizes() {
2126421253
NodeIdx < VectorizableTree.size() &&
2126521254
VectorizableTree[NodeIdx]->UserTreeIndex &&
2126621255
VectorizableTree[NodeIdx]->UserTreeIndex.EdgeIdx == 0 &&
21267-
VectorizableTree[NodeIdx]->UserTreeIndex.UserTE->hasState() &&
2126821256
VectorizableTree[NodeIdx]->UserTreeIndex.UserTE->getOpcode() ==
2126921257
Instruction::Trunc &&
2127021258
!VectorizableTree[NodeIdx]->UserTreeIndex.UserTE->isAltShuffle();

llvm/test/Transforms/SLPVectorizer/X86/user-node-no-state.ll

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)