@@ -836,6 +836,8 @@ class InstructionsState {
836836 return getOpcode() == CheckedOpcode || getAltOpcode() == CheckedOpcode;
837837 }
838838
839+ bool valid() const { return MainOp != nullptr; }
840+
839841 InstructionsState() = delete;
840842 InstructionsState(Instruction *MainOp, Instruction *AltOp)
841843 : MainOp(MainOp), AltOp(AltOp) {}
@@ -868,8 +870,8 @@ static bool areCompatibleCmpOps(Value *BaseOp0, Value *BaseOp1, Value *Op0,
868870 (!isa<Instruction>(BaseOp0) && !isa<Instruction>(Op0) &&
869871 !isa<Instruction>(BaseOp1) && !isa<Instruction>(Op1)) ||
870872 BaseOp0 == Op0 || BaseOp1 == Op1 ||
871- getSameOpcode({BaseOp0, Op0}, TLI).getMainOp () ||
872- getSameOpcode({BaseOp1, Op1}, TLI).getMainOp ();
873+ getSameOpcode({BaseOp0, Op0}, TLI).valid () ||
874+ getSameOpcode({BaseOp1, Op1}, TLI).valid ();
873875}
874876
875877/// \returns true if a compare instruction \p CI has similar "look" and
@@ -2380,7 +2382,7 @@ class BoUpSLP {
23802382 // Use Boyer-Moore majority voting for finding the majority opcode and
23812383 // the number of times it occurs.
23822384 if (auto *I = dyn_cast<Instruction>(OpData.V)) {
2383- if (!OpcodeI || !getSameOpcode({OpcodeI, I}, TLI).getMainOp () ||
2385+ if (!OpcodeI || !getSameOpcode({OpcodeI, I}, TLI).valid () ||
23842386 I->getParent() != Parent) {
23852387 if (NumOpsWithSameOpcodeParent == 0) {
23862388 NumOpsWithSameOpcodeParent = 1;
@@ -2500,7 +2502,7 @@ class BoUpSLP {
25002502 // next lane does not build same opcode sequence.
25012503 (Lns == 2 &&
25022504 !getSameOpcode({Op, getValue((OpI + 1) % OpE, Ln)}, TLI)
2503- .getMainOp () &&
2505+ .valid () &&
25042506 isa<Constant>(Data.V)))) ||
25052507 // 3. The operand in the current lane is loop invariant (can be
25062508 // hoisted out) and another operand is also a loop invariant
@@ -2509,7 +2511,7 @@ class BoUpSLP {
25092511 // FIXME: need to teach the cost model about this case for better
25102512 // estimation.
25112513 (IsInvariant && !isa<Constant>(Data.V) &&
2512- !getSameOpcode({Op, Data.V}, TLI).getMainOp () &&
2514+ !getSameOpcode({Op, Data.V}, TLI).valid () &&
25132515 L->isLoopInvariant(Data.V))) {
25142516 FoundCandidate = true;
25152517 Data.IsUsed = Data.V == Op;
@@ -2539,7 +2541,7 @@ class BoUpSLP {
25392541 return true;
25402542 Value *OpILn = getValue(OpI, Ln);
25412543 return (L && L->isLoopInvariant(OpILn)) ||
2542- (getSameOpcode({Op, OpILn}, TLI).getMainOp () &&
2544+ (getSameOpcode({Op, OpILn}, TLI).valid () &&
25432545 allSameBlock({Op, OpILn}));
25442546 }))
25452547 return true;
@@ -4766,7 +4768,7 @@ static bool arePointersCompatible(Value *Ptr1, Value *Ptr2,
47664768 !CompareOpcodes ||
47674769 (GEP1 && GEP2 &&
47684770 getSameOpcode({GEP1->getOperand(1), GEP2->getOperand(1)}, TLI)
4769- .getMainOp ()));
4771+ .valid ()));
47704772}
47714773
47724774/// Calculates minimal alignment as a common alignment.
@@ -7488,7 +7490,7 @@ bool BoUpSLP::areAltOperandsProfitable(const InstructionsState &S,
74887490 [&](ArrayRef<Value *> Op) {
74897491 if (allConstant(Op) ||
74907492 (!isSplat(Op) && allSameBlock(Op) && allSameType(Op) &&
7491- getSameOpcode(Op, *TLI).getMainOp ()))
7493+ getSameOpcode(Op, *TLI).valid ()))
74927494 return false;
74937495 DenseMap<Value *, unsigned> Uniques;
74947496 for (Value *V : Op) {
@@ -13223,7 +13225,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1322313225 Value *In1 = PHI1->getIncomingValue(I);
1322413226 if (isConstant(In) && isConstant(In1))
1322513227 continue;
13226- if (!getSameOpcode({In, In1}, *TLI).getMainOp ())
13228+ if (!getSameOpcode({In, In1}, *TLI).valid ())
1322713229 return false;
1322813230 if (cast<Instruction>(In)->getParent() !=
1322913231 cast<Instruction>(In1)->getParent())
@@ -13251,7 +13253,7 @@ BoUpSLP::isGatherShuffledSingleRegisterEntry(
1325113253 if (It != UsedValuesEntry.end())
1325213254 UsedInSameVTE = It->second == UsedValuesEntry.find(V)->second;
1325313255 return V != V1 && MightBeIgnored(V1) && !UsedInSameVTE &&
13254- getSameOpcode({V, V1}, *TLI).getMainOp () &&
13256+ getSameOpcode({V, V1}, *TLI).valid () &&
1325513257 cast<Instruction>(V)->getParent() ==
1325613258 cast<Instruction>(V1)->getParent() &&
1325713259 (!isa<PHINode>(V1) || AreCompatiblePHIs(V, V1));
@@ -21346,7 +21348,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
2134621348 return false;
2134721349 if (I1->getParent() != I2->getParent())
2134821350 return false;
21349- if (getSameOpcode({I1, I2}, *TLI).getMainOp ())
21351+ if (getSameOpcode({I1, I2}, *TLI).valid ())
2135021352 continue;
2135121353 return false;
2135221354 }
@@ -21700,7 +21702,7 @@ bool SLPVectorizerPass::vectorizeStoreChains(BoUpSLP &R) {
2170021702 "Different nodes should have different DFS numbers");
2170121703 if (NodeI1 != NodeI2)
2170221704 return NodeI1->getDFSNumIn() < NodeI2->getDFSNumIn();
21703- if (getSameOpcode({I1, I2}, *TLI).getMainOp ())
21705+ if (getSameOpcode({I1, I2}, *TLI).valid ())
2170421706 return false;
2170521707 return I1->getOpcode() < I2->getOpcode();
2170621708 }
@@ -21726,7 +21728,7 @@ bool SLPVectorizerPass::vectorizeStoreChains(BoUpSLP &R) {
2172621728 if (auto *I2 = dyn_cast<Instruction>(V2->getValueOperand())) {
2172721729 if (I1->getParent() != I2->getParent())
2172821730 return false;
21729- return getSameOpcode({I1, I2}, *TLI).getMainOp() != nullptr ;
21731+ return getSameOpcode({I1, I2}, *TLI).valid() ;
2173021732 }
2173121733 if (isa<Constant>(V1->getValueOperand()) &&
2173221734 isa<Constant>(V2->getValueOperand()))
0 commit comments