@@ -1845,7 +1845,7 @@ class BoUpSLP {
18451845 InstructionsState S = getSameOpcode(Ops, TLI);
18461846 // Note: Only consider instructions with <= 2 operands to avoid
18471847 // complexity explosion.
1848- if (S.getOpcode () &&
1848+ if (S.getMainOp () &&
18491849 (S.getMainOp()->getNumOperands() <= 2 || !MainAltOps.empty() ||
18501850 !S.isAltShuffle()) &&
18511851 all_of(Ops, [&S](Value *V) {
@@ -2696,7 +2696,7 @@ class BoUpSLP {
26962696 OperandData &AltOp = getData(OpIdx, Lane);
26972697 InstructionsState OpS =
26982698 getSameOpcode({MainAltOps[OpIdx].front(), AltOp.V}, TLI);
2699- if (OpS.getOpcode () && OpS.isAltShuffle())
2699+ if (OpS.getMainOp () && OpS.isAltShuffle())
27002700 MainAltOps[OpIdx].push_back(AltOp.V);
27012701 }
27022702 }
@@ -8067,7 +8067,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
80678067 }
80688068
80698069 // Check if this is a duplicate of another entry.
8070- if (S.getOpcode ()) {
8070+ if (S.getMainOp ()) {
80718071 if (TreeEntry *E = getTreeEntry(S.getMainOp())) {
80728072 LLVM_DEBUG(dbgs() << "SLP: \tChecking bundle: " << *S.getMainOp()
80738073 << ".\n");
@@ -8144,15 +8144,14 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
81448144 }
81458145
81468146 // Don't handle scalable vectors
8147- if (S.getOpcode() == Instruction::ExtractElement &&
8148- isa<ScalableVectorType>(
8149- cast<ExtractElementInst>(S.getMainOp())->getVectorOperandType())) {
8150- LLVM_DEBUG(dbgs() << "SLP: Gathering due to scalable vector type.\n");
8151- if (TryToFindDuplicates(S))
8152- newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,
8153- ReuseShuffleIndices);
8154- return;
8155- }
8147+ if (auto *EE = dyn_cast_if_present<ExtractElementInst>(S.getMainOp()))
8148+ if (isa<ScalableVectorType>(EE->getVectorOperandType())) {
8149+ LLVM_DEBUG(dbgs() << "SLP: Gathering due to scalable vector type.\n");
8150+ if (TryToFindDuplicates(S))
8151+ newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,
8152+ ReuseShuffleIndices);
8153+ return;
8154+ }
81568155
81578156 // Don't handle vectors.
81588157 if (!SLPReVec && getValueType(VL.front())->isVectorTy()) {
@@ -8168,7 +8167,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
81688167 // vectorize.
81698168 auto &&NotProfitableForVectorization = [&S, this,
81708169 Depth](ArrayRef<Value *> VL) {
8171- if (!S.getOpcode () || !S.isAltShuffle() || VL.size() > 2)
8170+ if (!S.getMainOp () || !S.isAltShuffle() || VL.size() > 2)
81728171 return false;
81738172 if (VectorizableTree.size() < MinTreeSize)
81748173 return false;
@@ -8223,7 +8222,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
82238222 bool IsScatterVectorizeUserTE =
82248223 UserTreeIdx.UserTE &&
82258224 UserTreeIdx.UserTE->State == TreeEntry::ScatterVectorize;
8226- bool AreAllSameBlock = S.getOpcode () && allSameBlock(VL);
8225+ bool AreAllSameBlock = S.getMainOp () && allSameBlock(VL);
82278226 bool AreScatterAllGEPSameBlock =
82288227 (IsScatterVectorizeUserTE && VL.front()->getType()->isPointerTy() &&
82298228 VL.size() > 2 &&
@@ -8240,7 +8239,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
82408239 sortPtrAccesses(VL, UserTreeIdx.UserTE->getMainOp()->getType(), *DL, *SE,
82418240 SortedIndices));
82428241 bool AreAllSameInsts = AreAllSameBlock || AreScatterAllGEPSameBlock;
8243- if (!AreAllSameInsts || (!S.getOpcode () && allConstant(VL)) || isSplat(VL) ||
8242+ if (!AreAllSameInsts || (!S.getMainOp () && allConstant(VL)) || isSplat(VL) ||
82448243 (isa_and_present<InsertElementInst, ExtractValueInst, ExtractElementInst>(
82458244 S.getMainOp()) &&
82468245 !all_of(VL, isVectorLikeInstWithConstOps)) ||
@@ -8253,7 +8252,7 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
82538252 }
82548253
82558254 // Don't vectorize ephemeral values.
8256- if (S.getOpcode () && !EphValues.empty()) {
8255+ if (S.getMainOp () && !EphValues.empty()) {
82578256 for (Value *V : VL) {
82588257 if (EphValues.count(V)) {
82598258 LLVM_DEBUG(dbgs() << "SLP: The instruction (" << *V
@@ -9730,7 +9729,7 @@ void BoUpSLP::transformNodes() {
97309729 if (IsSplat)
97319730 continue;
97329731 InstructionsState S = getSameOpcode(Slice, *TLI);
9733- if (!S.getOpcode () || S.isAltShuffle() || !allSameBlock(Slice) ||
9732+ if (!S.getMainOp () || S.isAltShuffle() || !allSameBlock(Slice) ||
97349733 (S.getOpcode() == Instruction::Load &&
97359734 areKnownNonVectorizableLoads(Slice)) ||
97369735 (S.getOpcode() != Instruction::Load && !has_single_bit(VF)))
@@ -14394,12 +14393,12 @@ BoUpSLP::TreeEntry *BoUpSLP::getMatchedVectorizedOperand(const TreeEntry *E,
1439414393 ArrayRef<Value *> VL = E->getOperand(NodeIdx);
1439514394 InstructionsState S = getSameOpcode(VL, *TLI);
1439614395 // Special processing for GEPs bundle, which may include non-gep values.
14397- if (!S.getOpcode () && VL.front()->getType()->isPointerTy()) {
14396+ if (!S.getMainOp () && VL.front()->getType()->isPointerTy()) {
1439814397 const auto *It = find_if(VL, IsaPred<GetElementPtrInst>);
1439914398 if (It != VL.end())
1440014399 S = getSameOpcode(*It, *TLI);
1440114400 }
14402- if (!S.getOpcode ())
14401+ if (!S.getMainOp ())
1440314402 return nullptr;
1440414403 auto CheckSameVE = [&](const TreeEntry *VE) {
1440514404 return VE->isSame(VL) &&
@@ -18376,7 +18375,7 @@ SLPVectorizerPass::vectorizeStoreChain(ArrayRef<Value *> Chain, BoUpSLP &R,
1837618375 hasFullVectorsOrPowerOf2(*TTI, ValOps.front()->getType(),
1837718376 ValOps.size()) ||
1837818377 (VectorizeNonPowerOf2 && has_single_bit(ValOps.size() + 1));
18379- if ((!IsAllowedSize && S.getOpcode () &&
18378+ if ((!IsAllowedSize && S.getMainOp () &&
1838018379 S.getOpcode() != Instruction::Load &&
1838118380 (!S.getMainOp()->isSafeToRemove() ||
1838218381 any_of(ValOps.getArrayRef(),
@@ -18387,8 +18386,8 @@ SLPVectorizerPass::vectorizeStoreChain(ArrayRef<Value *> Chain, BoUpSLP &R,
1838718386 return !Stores.contains(U);
1838818387 }));
1838918388 }))) ||
18390- (ValOps.size() > Chain.size() / 2 && !S.getOpcode ())) {
18391- Size = (!IsAllowedSize && S.getOpcode ()) ? 1 : 2;
18389+ (ValOps.size() > Chain.size() / 2 && !S.getMainOp ())) {
18390+ Size = (!IsAllowedSize && S.getMainOp ()) ? 1 : 2;
1839218391 return false;
1839318392 }
1839418393 }
@@ -18912,7 +18911,7 @@ bool SLPVectorizerPass::tryToVectorizeList(ArrayRef<Value *> VL, BoUpSLP &R,
1891218911 // Check that all of the parts are instructions of the same type,
1891318912 // we permit an alternate opcode via InstructionsState.
1891418913 InstructionsState S = getSameOpcode(VL, *TLI);
18915- if (!S.getOpcode ())
18914+ if (!S.getMainOp ())
1891618915 return false;
1891718916
1891818917 Instruction *I0 = S.getMainOp();
@@ -19724,8 +19723,8 @@ class HorizontalReduction {
1972419723 // Also check if the instruction was folded to constant/other value.
1972519724 auto *Inst = dyn_cast<Instruction>(RdxVal);
1972619725 if ((Inst && isVectorLikeInstWithConstOps(Inst) &&
19727- (!S.getOpcode () || !S.isOpcodeOrAlt(Inst))) ||
19728- (S.getOpcode () && !Inst))
19726+ (!S.getMainOp () || !S.isOpcodeOrAlt(Inst))) ||
19727+ (S.getMainOp () && !Inst))
1972919728 continue;
1973019729 Candidates.push_back(RdxVal);
1973119730 TrackedToOrig.try_emplace(RdxVal, OrigReducedVals[Cnt]);
@@ -21128,7 +21127,7 @@ static bool compareCmp(Value *V, Value *V2, TargetLibraryInfo &TLI,
2112821127 return NodeI1->getDFSNumIn() < NodeI2->getDFSNumIn();
2112921128 }
2113021129 InstructionsState S = getSameOpcode({I1, I2}, TLI);
21131- if (S.getOpcode () && (IsCompatibility || !S.isAltShuffle()))
21130+ if (S.getMainOp () && (IsCompatibility || !S.isAltShuffle()))
2113221131 continue;
2113321132 if (IsCompatibility)
2113421133 return false;
@@ -21283,7 +21282,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
2128321282 if (NodeI1 != NodeI2)
2128421283 return NodeI1->getDFSNumIn() < NodeI2->getDFSNumIn();
2128521284 InstructionsState S = getSameOpcode({I1, I2}, *TLI);
21286- if (S.getOpcode () && !S.isAltShuffle())
21285+ if (S.getMainOp () && !S.isAltShuffle())
2128721286 continue;
2128821287 return I1->getOpcode() < I2->getOpcode();
2128921288 }
0 commit comments