Skip to content

Commit 5624823

Browse files
committed
[SLP] NFC. Use getMainOp if users just want to know whether VL has
same opcode.
1 parent b3d2548 commit 5624823

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -868,8 +868,8 @@ static bool areCompatibleCmpOps(Value *BaseOp0, Value *BaseOp1, Value *Op0,
868868
(!isa<Instruction>(BaseOp0) && !isa<Instruction>(Op0) &&
869869
!isa<Instruction>(BaseOp1) && !isa<Instruction>(Op1)) ||
870870
BaseOp0 == Op0 || BaseOp1 == Op1 ||
871-
getSameOpcode({BaseOp0, Op0}, TLI).getOpcode() ||
872-
getSameOpcode({BaseOp1, Op1}, TLI).getOpcode();
871+
getSameOpcode({BaseOp0, Op0}, TLI).getMainOp() ||
872+
getSameOpcode({BaseOp1, Op1}, TLI).getMainOp();
873873
}
874874

875875
/// \returns true if a compare instruction \p CI has similar "look" and
@@ -2380,7 +2380,7 @@ class BoUpSLP {
23802380
// Use Boyer-Moore majority voting for finding the majority opcode and
23812381
// the number of times it occurs.
23822382
if (auto *I = dyn_cast<Instruction>(OpData.V)) {
2383-
if (!OpcodeI || !getSameOpcode({OpcodeI, I}, TLI).getOpcode() ||
2383+
if (!OpcodeI || !getSameOpcode({OpcodeI, I}, TLI).getMainOp() ||
23842384
I->getParent() != Parent) {
23852385
if (NumOpsWithSameOpcodeParent == 0) {
23862386
NumOpsWithSameOpcodeParent = 1;
@@ -2500,7 +2500,7 @@ class BoUpSLP {
25002500
// next lane does not build same opcode sequence.
25012501
(Lns == 2 &&
25022502
!getSameOpcode({Op, getValue((OpI + 1) % OpE, Ln)}, TLI)
2503-
.getOpcode() &&
2503+
.getMainOp() &&
25042504
isa<Constant>(Data.V)))) ||
25052505
// 3. The operand in the current lane is loop invariant (can be
25062506
// hoisted out) and another operand is also a loop invariant
@@ -2509,7 +2509,7 @@ class BoUpSLP {
25092509
// FIXME: need to teach the cost model about this case for better
25102510
// estimation.
25112511
(IsInvariant && !isa<Constant>(Data.V) &&
2512-
!getSameOpcode({Op, Data.V}, TLI).getOpcode() &&
2512+
!getSameOpcode({Op, Data.V}, TLI).getMainOp() &&
25132513
L->isLoopInvariant(Data.V))) {
25142514
FoundCandidate = true;
25152515
Data.IsUsed = Data.V == Op;
@@ -2539,7 +2539,7 @@ class BoUpSLP {
25392539
return true;
25402540
Value *OpILn = getValue(OpI, Ln);
25412541
return (L && L->isLoopInvariant(OpILn)) ||
2542-
(getSameOpcode({Op, OpILn}, TLI).getOpcode() &&
2542+
(getSameOpcode({Op, OpILn}, TLI).getMainOp() &&
25432543
allSameBlock({Op, OpILn}));
25442544
}))
25452545
return true;
@@ -4766,7 +4766,7 @@ static bool arePointersCompatible(Value *Ptr1, Value *Ptr2,
47664766
!CompareOpcodes ||
47674767
(GEP1 && GEP2 &&
47684768
getSameOpcode({GEP1->getOperand(1), GEP2->getOperand(1)}, TLI)
4769-
.getOpcode()));
4769+
.getMainOp()));
47704770
}
47714771

47724772
/// Calculates minimal alignment as a common alignment.
@@ -13223,7 +13223,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1322313223
Value *In1 = PHI1->getIncomingValue(I);
1322413224
if (isConstant(In) && isConstant(In1))
1322513225
continue;
13226-
if (!getSameOpcode({In, In1}, *TLI).getOpcode())
13226+
if (!getSameOpcode({In, In1}, *TLI).getMainOp())
1322713227
return false;
1322813228
if (cast<Instruction>(In)->getParent() !=
1322913229
cast<Instruction>(In1)->getParent())
@@ -13251,7 +13251,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1325113251
if (It != UsedValuesEntry.end())
1325213252
UsedInSameVTE = It->second == UsedValuesEntry.find(V)->second;
1325313253
return V != V1 && MightBeIgnored(V1) && !UsedInSameVTE &&
13254-
getSameOpcode({V, V1}, *TLI).getOpcode() &&
13254+
getSameOpcode({V, V1}, *TLI).getMainOp() &&
1325513255
cast<Instruction>(V)->getParent() ==
1325613256
cast<Instruction>(V1)->getParent() &&
1325713257
(!isa<PHINode>(V1) || AreCompatiblePHIs(V, V1));
@@ -21346,8 +21346,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
2134621346
return false;
2134721347
if (I1->getParent() != I2->getParent())
2134821348
return false;
21349-
InstructionsState S = getSameOpcode({I1, I2}, *TLI);
21350-
if (S.getOpcode())
21349+
if (getSameOpcode({I1, I2}, *TLI).getMainOp())
2135121350
continue;
2135221351
return false;
2135321352
}
@@ -21701,8 +21700,7 @@ bool SLPVectorizerPass::vectorizeStoreChains(BoUpSLP &R) {
2170121700
"Different nodes should have different DFS numbers");
2170221701
if (NodeI1 != NodeI2)
2170321702
return NodeI1->getDFSNumIn() < NodeI2->getDFSNumIn();
21704-
InstructionsState S = getSameOpcode({I1, I2}, *TLI);
21705-
if (S.getOpcode())
21703+
if (getSameOpcode({I1, I2}, *TLI).getMainOp())
2170621704
return false;
2170721705
return I1->getOpcode() < I2->getOpcode();
2170821706
}
@@ -21728,8 +21726,7 @@ bool SLPVectorizerPass::vectorizeStoreChains(BoUpSLP &R) {
2172821726
if (auto *I2 = dyn_cast<Instruction>(V2->getValueOperand())) {
2172921727
if (I1->getParent() != I2->getParent())
2173021728
return false;
21731-
InstructionsState S = getSameOpcode({I1, I2}, *TLI);
21732-
return S.getOpcode() > 0;
21729+
return getSameOpcode({I1, I2}, *TLI).getMainOp() != nullptr;
2173321730
}
2173421731
if (isa<Constant>(V1->getValueOperand()) &&
2173521732
isa<Constant>(V2->getValueOperand()))

0 commit comments

Comments
 (0)