@@ -205,7 +205,7 @@ static bool isValidElementType(Type *Ty) {
205
205
// / \returns True if the value is a constant (but not globals/constant
206
206
// / expressions).
207
207
static bool isConstant (Value *V) {
208
- return isa<Constant>(V) && !isa<ConstantExpr>(V) && !isa< GlobalValue>(V);
208
+ return isa<Constant>(V) && !isa<ConstantExpr, GlobalValue>(V);
209
209
}
210
210
211
211
// / Checks if \p V is one of vector-like instructions, i.e. undef,
@@ -2994,7 +2994,7 @@ class BoUpSLP {
2994
2994
// okay.
2995
2995
auto *In = BundleMember->Inst ;
2996
2996
assert (In &&
2997
- (isa<ExtractValueInst>(In) || isa< ExtractElementInst>(In) ||
2997
+ (isa<ExtractValueInst, ExtractElementInst>(In) ||
2998
2998
In->getNumOperands () == TE->getNumOperands ()) &&
2999
2999
" Missed TreeEntry operands?" );
3000
3000
(void )In; // fake use to avoid build failure when assertions disabled
@@ -4489,7 +4489,7 @@ static std::pair<size_t, size_t> generateKeySubkey(
4489
4489
} else if (auto *I = dyn_cast<Instruction>(V)) {
4490
4490
// Sort other instructions just by the opcodes except for CMPInst.
4491
4491
// For CMP also sort by the predicate kind.
4492
- if ((isa<BinaryOperator>(I) || isa< CastInst>(I)) &&
4492
+ if ((isa<BinaryOperator, CastInst>(I)) &&
4493
4493
isValidForAlternation (I->getOpcode ())) {
4494
4494
if (AllowAlternate)
4495
4495
Key = hash_value (isa<BinaryOperator>(I) ? 1 : 0 );
@@ -5536,8 +5536,7 @@ unsigned BoUpSLP::canMapToVector(Type *T, const DataLayout &DL) const {
5536
5536
unsigned N = 1 ;
5537
5537
Type *EltTy = T;
5538
5538
5539
- while (isa<StructType>(EltTy) || isa<ArrayType>(EltTy) ||
5540
- isa<VectorType>(EltTy)) {
5539
+ while (isa<StructType, ArrayType, VectorType>(EltTy)) {
5541
5540
if (auto *ST = dyn_cast<StructType>(EltTy)) {
5542
5541
// Check that struct is homogeneous.
5543
5542
for (const auto *Ty : ST->elements ())
@@ -5867,9 +5866,9 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
5867
5866
// Take credit for instruction that will become dead.
5868
5867
if (EE->hasOneUse ()) {
5869
5868
Instruction *Ext = EE->user_back ();
5870
- if (( isa<SExtInst>(Ext) || isa<ZExtInst> (Ext)) &&
5871
- all_of (Ext-> users (),
5872
- [](User *U) { return isa<GetElementPtrInst>(U); })) {
5869
+ if (isa<SExtInst, ZExtInst >(Ext) && all_of (Ext-> users (), [](User *U) {
5870
+ return isa<GetElementPtrInst>(U);
5871
+ })) {
5873
5872
// Use getExtractWithExtendCost() to calculate the cost of
5874
5873
// extractelement/ext pair.
5875
5874
Cost -=
@@ -6142,18 +6141,18 @@ InstructionCost BoUpSLP::getEntryCost(const TreeEntry *E,
6142
6141
// Take credit for instruction that will become dead.
6143
6142
if (EI->hasOneUse ()) {
6144
6143
Instruction *Ext = EI->user_back ();
6145
- if (( isa<SExtInst>(Ext) || isa< ZExtInst>(Ext) ) &&
6144
+ if (isa<SExtInst, ZExtInst>(Ext) &&
6146
6145
all_of (Ext->users (),
6147
6146
[](User *U) { return isa<GetElementPtrInst>(U); })) {
6148
- // Use getExtractWithExtendCost() to calculate the cost of
6149
- // extractelement/ext pair.
6150
- CommonCost -= TTI->getExtractWithExtendCost (
6151
- Ext->getOpcode (), Ext->getType (), VecTy, I);
6152
- // Add back the cost of s|zext which is subtracted separately.
6153
- CommonCost += TTI->getCastInstrCost (
6154
- Ext->getOpcode (), Ext->getType (), EI->getType (),
6155
- TTI::getCastContextHint (Ext), CostKind, Ext);
6156
- continue ;
6147
+ // Use getExtractWithExtendCost() to calculate the cost of
6148
+ // extractelement/ext pair.
6149
+ CommonCost -= TTI->getExtractWithExtendCost (
6150
+ Ext->getOpcode (), Ext->getType (), VecTy, I);
6151
+ // Add back the cost of s|zext which is subtracted separately.
6152
+ CommonCost += TTI->getCastInstrCost (
6153
+ Ext->getOpcode (), Ext->getType (), EI->getType (),
6154
+ TTI::getCastContextHint (Ext), CostKind, Ext);
6155
+ continue ;
6157
6156
}
6158
6157
}
6159
6158
CommonCost -=
@@ -9001,8 +9000,8 @@ void BoUpSLP::optimizeGatherSequence() {
9001
9000
for (Instruction &In : llvm::make_early_inc_range (*BB)) {
9002
9001
if (isDeleted (&In))
9003
9002
continue ;
9004
- if (!isa<InsertElementInst>(&In) && !isa< ExtractElementInst>(&In) &&
9005
- !isa<ShuffleVectorInst>(&In) && ! GatherShuffleSeq.contains (&In))
9003
+ if (!isa<InsertElementInst, ExtractElementInst, ShuffleVectorInst >(&In) &&
9004
+ !GatherShuffleSeq.contains (&In))
9006
9005
continue ;
9007
9006
9008
9007
// Check if we can replace this instruction with any of the
@@ -9660,17 +9659,15 @@ unsigned BoUpSLP::getVectorElementSize(Value *V) {
9660
9659
9661
9660
// If the current instruction is a load, update MaxWidth to reflect the
9662
9661
// width of the loaded value.
9663
- if (isa<LoadInst>(I) || isa<ExtractElementInst>(I) ||
9664
- isa<ExtractValueInst>(I))
9662
+ if (isa<LoadInst, ExtractElementInst, ExtractValueInst>(I))
9665
9663
Width = std::max<unsigned >(Width, DL->getTypeSizeInBits (Ty));
9666
9664
9667
9665
// Otherwise, we need to visit the operands of the instruction. We only
9668
9666
// handle the interesting cases from buildTree here. If an operand is an
9669
9667
// instruction we haven't yet visited and from the same basic block as the
9670
9668
// user or the use is a PHI node, we add it to the worklist.
9671
- else if (isa<PHINode>(I) || isa<CastInst>(I) || isa<GetElementPtrInst>(I) ||
9672
- isa<CmpInst>(I) || isa<SelectInst>(I) || isa<BinaryOperator>(I) ||
9673
- isa<UnaryOperator>(I)) {
9669
+ else if (isa<PHINode, CastInst, GetElementPtrInst, CmpInst, SelectInst,
9670
+ BinaryOperator, UnaryOperator>(I)) {
9674
9671
for (Use &U : I->operands ())
9675
9672
if (auto *J = dyn_cast<Instruction>(U.get ()))
9676
9673
if (Visited.insert (J).second &&
@@ -9723,8 +9720,7 @@ static bool collectValuesToDemote(Value *V, SmallPtrSetImpl<Value *> &Expr,
9723
9720
break ;
9724
9721
case Instruction::ZExt:
9725
9722
case Instruction::SExt:
9726
- if (isa<ExtractElementInst>(I->getOperand (0 )) ||
9727
- isa<InsertElementInst>(I->getOperand (0 )))
9723
+ if (isa<ExtractElementInst, InsertElementInst>(I->getOperand (0 )))
9728
9724
return false ;
9729
9725
break ;
9730
9726
@@ -10422,8 +10418,7 @@ bool SLPVectorizerPass::tryToVectorize(Instruction *I, BoUpSLP &R) {
10422
10418
if (!I)
10423
10419
return false ;
10424
10420
10425
- if ((!isa<BinaryOperator>(I) && !isa<CmpInst>(I)) ||
10426
- isa<VectorType>(I->getType ()))
10421
+ if (!isa<BinaryOperator, CmpInst>(I) || isa<VectorType>(I->getType ()))
10427
10422
return false ;
10428
10423
10429
10424
Value *P = I->getParent ();
@@ -11533,8 +11528,7 @@ static void findBuildAggregate_rec(Instruction *LastInsertInst,
11533
11528
getInsertIndex (LastInsertInst, OperandOffset);
11534
11529
if (!OperandIndex)
11535
11530
return ;
11536
- if (isa<InsertElementInst>(InsertedOperand) ||
11537
- isa<InsertValueInst>(InsertedOperand)) {
11531
+ if (isa<InsertElementInst, InsertValueInst>(InsertedOperand)) {
11538
11532
findBuildAggregate_rec (cast<Instruction>(InsertedOperand), TTI,
11539
11533
BuildVectorOpds, InsertElts, *OperandIndex);
11540
11534
@@ -11544,8 +11538,7 @@ static void findBuildAggregate_rec(Instruction *LastInsertInst,
11544
11538
}
11545
11539
LastInsertInst = dyn_cast<Instruction>(LastInsertInst->getOperand (0 ));
11546
11540
} while (LastInsertInst != nullptr &&
11547
- (isa<InsertValueInst>(LastInsertInst) ||
11548
- isa<InsertElementInst>(LastInsertInst)) &&
11541
+ isa<InsertValueInst, InsertElementInst>(LastInsertInst) &&
11549
11542
LastInsertInst->hasOneUse ());
11550
11543
}
11551
11544
@@ -12240,8 +12233,8 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
12240
12233
// Ran into an instruction without users, like terminator, or function call
12241
12234
// with ignored return value, store. Ignore unused instructions (basing on
12242
12235
// instruction type, except for CallInst and InvokeInst).
12243
- if (it->use_empty () && (it-> getType ()-> isVoidTy () || isa<CallInst>(it) ||
12244
- isa<InvokeInst>(it))) {
12236
+ if (it->use_empty () &&
12237
+ (it-> getType ()-> isVoidTy () || isa<CallInst, InvokeInst>(it))) {
12245
12238
KeyNodes.insert (&*it);
12246
12239
bool OpsChanged = false ;
12247
12240
if (ShouldStartVectorizeHorAtStore || !isa<StoreInst>(it)) {
@@ -12265,8 +12258,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
12265
12258
}
12266
12259
}
12267
12260
12268
- if (isa<InsertElementInst>(it) || isa<CmpInst>(it) ||
12269
- isa<InsertValueInst>(it))
12261
+ if (isa<CmpInst, InsertElementInst, InsertValueInst>(it))
12270
12262
PostProcessInstructions.push_back (&*it);
12271
12263
}
12272
12264
0 commit comments