From: Alexey Bataev Date: Mon, 15 Aug 2022 18:30:11 +0000 (-0700) Subject: [SLP][NFC]Replace multiple isa calls with single one where possible, X-Git-Tag: upstream/17.0.6~36434 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2819126d0c4f42573464ad5b64a2829e6c1f3c22;p=platform%2Fupstream%2Fllvm.git [SLP][NFC]Replace multiple isa calls with single one where possible, NFC. --- diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 999b396..7d76e1b 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -205,7 +205,7 @@ static bool isValidElementType(Type *Ty) { /// \returns True if the value is a constant (but not globals/constant /// expressions). static bool isConstant(Value *V) { - return isa(V) && !isa(V) && !isa(V); + return isa(V) && !isa(V); } /// Checks if \p V is one of vector-like instructions, i.e. undef, @@ -2994,7 +2994,7 @@ private: // okay. auto *In = BundleMember->Inst; assert(In && - (isa(In) || isa(In) || + (isa(In) || In->getNumOperands() == TE->getNumOperands()) && "Missed TreeEntry operands?"); (void)In; // fake use to avoid build failure when assertions disabled @@ -4489,7 +4489,7 @@ static std::pair generateKeySubkey( } else if (auto *I = dyn_cast(V)) { // Sort other instructions just by the opcodes except for CMPInst. // For CMP also sort by the predicate kind. - if ((isa(I) || isa(I)) && + if ((isa(I)) && isValidForAlternation(I->getOpcode())) { if (AllowAlternate) Key = hash_value(isa(I) ? 1 : 0); @@ -5536,8 +5536,7 @@ unsigned BoUpSLP::canMapToVector(Type *T, const DataLayout &DL) const { unsigned N = 1; Type *EltTy = T; - while (isa(EltTy) || isa(EltTy) || - isa(EltTy)) { + while (isa(EltTy)) { if (auto *ST = dyn_cast(EltTy)) { // Check that struct is homogeneous. for (const auto *Ty : ST->elements()) @@ -5867,9 +5866,9 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E, // Take credit for instruction that will become dead. if (EE->hasOneUse()) { Instruction *Ext = EE->user_back(); - if ((isa(Ext) || isa(Ext)) && - all_of(Ext->users(), - [](User *U) { return isa(U); })) { + if (isa(Ext) && all_of(Ext->users(), [](User *U) { + return isa(U); + })) { // Use getExtractWithExtendCost() to calculate the cost of // extractelement/ext pair. Cost -= @@ -6142,18 +6141,18 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E, // Take credit for instruction that will become dead. if (EI->hasOneUse()) { Instruction *Ext = EI->user_back(); - if ((isa(Ext) || isa(Ext)) && + if (isa(Ext) && all_of(Ext->users(), [](User *U) { return isa(U); })) { - // Use getExtractWithExtendCost() to calculate the cost of - // extractelement/ext pair. - CommonCost -= TTI->getExtractWithExtendCost( - Ext->getOpcode(), Ext->getType(), VecTy, I); - // Add back the cost of s|zext which is subtracted separately. - CommonCost += TTI->getCastInstrCost( - Ext->getOpcode(), Ext->getType(), EI->getType(), - TTI::getCastContextHint(Ext), CostKind, Ext); - continue; + // Use getExtractWithExtendCost() to calculate the cost of + // extractelement/ext pair. + CommonCost -= TTI->getExtractWithExtendCost( + Ext->getOpcode(), Ext->getType(), VecTy, I); + // Add back the cost of s|zext which is subtracted separately. + CommonCost += TTI->getCastInstrCost( + Ext->getOpcode(), Ext->getType(), EI->getType(), + TTI::getCastContextHint(Ext), CostKind, Ext); + continue; } } CommonCost -= @@ -9001,8 +9000,8 @@ void BoUpSLP::optimizeGatherSequence() { for (Instruction &In : llvm::make_early_inc_range(*BB)) { if (isDeleted(&In)) continue; - if (!isa(&In) && !isa(&In) && - !isa(&In) && !GatherShuffleSeq.contains(&In)) + if (!isa(&In) && + !GatherShuffleSeq.contains(&In)) continue; // Check if we can replace this instruction with any of the @@ -9660,17 +9659,15 @@ unsigned BoUpSLP::getVectorElementSize(Value *V) { // If the current instruction is a load, update MaxWidth to reflect the // width of the loaded value. - if (isa(I) || isa(I) || - isa(I)) + if (isa(I)) Width = std::max(Width, DL->getTypeSizeInBits(Ty)); // Otherwise, we need to visit the operands of the instruction. We only // handle the interesting cases from buildTree here. If an operand is an // instruction we haven't yet visited and from the same basic block as the // user or the use is a PHI node, we add it to the worklist. - else if (isa(I) || isa(I) || isa(I) || - isa(I) || isa(I) || isa(I) || - isa(I)) { + else if (isa(I)) { for (Use &U : I->operands()) if (auto *J = dyn_cast(U.get())) if (Visited.insert(J).second && @@ -9723,8 +9720,7 @@ static bool collectValuesToDemote(Value *V, SmallPtrSetImpl &Expr, break; case Instruction::ZExt: case Instruction::SExt: - if (isa(I->getOperand(0)) || - isa(I->getOperand(0))) + if (isa(I->getOperand(0))) return false; break; @@ -10422,8 +10418,7 @@ bool SLPVectorizerPass::tryToVectorize(Instruction *I, BoUpSLP &R) { if (!I) return false; - if ((!isa(I) && !isa(I)) || - isa(I->getType())) + if (!isa(I) || isa(I->getType())) return false; Value *P = I->getParent(); @@ -11533,8 +11528,7 @@ static void findBuildAggregate_rec(Instruction *LastInsertInst, getInsertIndex(LastInsertInst, OperandOffset); if (!OperandIndex) return; - if (isa(InsertedOperand) || - isa(InsertedOperand)) { + if (isa(InsertedOperand)) { findBuildAggregate_rec(cast(InsertedOperand), TTI, BuildVectorOpds, InsertElts, *OperandIndex); @@ -11544,8 +11538,7 @@ static void findBuildAggregate_rec(Instruction *LastInsertInst, } LastInsertInst = dyn_cast(LastInsertInst->getOperand(0)); } while (LastInsertInst != nullptr && - (isa(LastInsertInst) || - isa(LastInsertInst)) && + isa(LastInsertInst) && LastInsertInst->hasOneUse()); } @@ -12240,8 +12233,8 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) { // Ran into an instruction without users, like terminator, or function call // with ignored return value, store. Ignore unused instructions (basing on // instruction type, except for CallInst and InvokeInst). - if (it->use_empty() && (it->getType()->isVoidTy() || isa(it) || - isa(it))) { + if (it->use_empty() && + (it->getType()->isVoidTy() || isa(it))) { KeyNodes.insert(&*it); bool OpsChanged = false; if (ShouldStartVectorizeHorAtStore || !isa(it)) { @@ -12265,8 +12258,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) { } } - if (isa(it) || isa(it) || - isa(it)) + if (isa(it)) PostProcessInstructions.push_back(&*it); }