@@ -1116,6 +1116,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1116
1116
unsigned getIntrinsicInstrCost (
1117
1117
Intrinsic::ID IID, Type *RetTy, ArrayRef<Type *> Tys, FastMathFlags FMF,
1118
1118
unsigned ScalarizationCostPassed = std::numeric_limits<unsigned >::max()) {
1119
+ auto *ConcreteTTI = static_cast <T *>(this );
1120
+
1119
1121
SmallVector<unsigned , 2 > ISDs;
1120
1122
unsigned SingleCallCost = 10 ; // Library call cost. Make it expensive.
1121
1123
switch (IID) {
@@ -1144,8 +1146,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1144
1146
if (ScalarCalls == 1 )
1145
1147
return 1 ; // Return cost of a scalar intrinsic. Assume it to be cheap.
1146
1148
1147
- unsigned ScalarCost = static_cast <T *>( this )-> getIntrinsicInstrCost (
1148
- IID, ScalarRetTy, ScalarTys, FMF);
1149
+ unsigned ScalarCost =
1150
+ ConcreteTTI-> getIntrinsicInstrCost ( IID, ScalarRetTy, ScalarTys, FMF);
1149
1151
1150
1152
return ScalarCalls * ScalarCost + ScalarizationCost;
1151
1153
}
@@ -1227,42 +1229,41 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1227
1229
case Intrinsic::sideeffect:
1228
1230
return 0 ;
1229
1231
case Intrinsic::masked_store:
1230
- return static_cast <T *>( this )
1231
- -> getMaskedMemoryOpCost (Instruction::Store, Tys[ 0 ], 0 , 0 );
1232
+ return ConcreteTTI-> getMaskedMemoryOpCost (Instruction::Store, Tys[ 0 ], 0 ,
1233
+ 0 );
1232
1234
case Intrinsic::masked_load:
1233
- return static_cast <T *>(this )
1234
- ->getMaskedMemoryOpCost (Instruction::Load, RetTy, 0 , 0 );
1235
+ return ConcreteTTI->getMaskedMemoryOpCost (Instruction::Load, RetTy, 0 , 0 );
1235
1236
case Intrinsic::experimental_vector_reduce_add:
1236
- return static_cast <T *>( this ) ->getArithmeticReductionCost (
1237
- Instruction::Add, Tys[ 0 ], /* IsPairwiseForm=*/ false );
1237
+ return ConcreteTTI ->getArithmeticReductionCost (Instruction::Add, Tys[ 0 ],
1238
+ /* IsPairwiseForm=*/ false );
1238
1239
case Intrinsic::experimental_vector_reduce_mul:
1239
- return static_cast <T *>( this ) ->getArithmeticReductionCost (
1240
- Instruction::Mul, Tys[ 0 ], /* IsPairwiseForm=*/ false );
1240
+ return ConcreteTTI ->getArithmeticReductionCost (Instruction::Mul, Tys[ 0 ],
1241
+ /* IsPairwiseForm=*/ false );
1241
1242
case Intrinsic::experimental_vector_reduce_and:
1242
- return static_cast <T *>( this ) ->getArithmeticReductionCost (
1243
- Instruction::And, Tys[ 0 ], /* IsPairwiseForm=*/ false );
1243
+ return ConcreteTTI ->getArithmeticReductionCost (Instruction::And, Tys[ 0 ],
1244
+ /* IsPairwiseForm=*/ false );
1244
1245
case Intrinsic::experimental_vector_reduce_or:
1245
- return static_cast <T *>( this ) ->getArithmeticReductionCost (
1246
- Instruction::Or, Tys[ 0 ], /* IsPairwiseForm=*/ false );
1246
+ return ConcreteTTI ->getArithmeticReductionCost (Instruction::Or, Tys[ 0 ],
1247
+ /* IsPairwiseForm=*/ false );
1247
1248
case Intrinsic::experimental_vector_reduce_xor:
1248
- return static_cast <T *>( this ) ->getArithmeticReductionCost (
1249
- Instruction::Xor, Tys[ 0 ], /* IsPairwiseForm=*/ false );
1249
+ return ConcreteTTI ->getArithmeticReductionCost (Instruction::Xor, Tys[ 0 ],
1250
+ /* IsPairwiseForm=*/ false );
1250
1251
case Intrinsic::experimental_vector_reduce_fadd:
1251
- return static_cast <T *>( this ) ->getArithmeticReductionCost (
1252
- Instruction::FAdd, Tys[ 0 ], /* IsPairwiseForm=*/ false );
1252
+ return ConcreteTTI ->getArithmeticReductionCost (Instruction::FAdd, Tys[ 0 ],
1253
+ /* IsPairwiseForm=*/ false );
1253
1254
case Intrinsic::experimental_vector_reduce_fmul:
1254
- return static_cast <T *>( this ) ->getArithmeticReductionCost (
1255
- Instruction::FMul, Tys[ 0 ], /* IsPairwiseForm=*/ false );
1255
+ return ConcreteTTI ->getArithmeticReductionCost (Instruction::FMul, Tys[ 0 ],
1256
+ /* IsPairwiseForm=*/ false );
1256
1257
case Intrinsic::experimental_vector_reduce_smax:
1257
1258
case Intrinsic::experimental_vector_reduce_smin:
1258
1259
case Intrinsic::experimental_vector_reduce_fmax:
1259
1260
case Intrinsic::experimental_vector_reduce_fmin:
1260
- return static_cast <T *>( this ) ->getMinMaxReductionCost (
1261
+ return ConcreteTTI ->getMinMaxReductionCost (
1261
1262
Tys[0 ], CmpInst::makeCmpResultType (Tys[0 ]), /* IsPairwiseForm=*/ false ,
1262
1263
/* IsSigned=*/ true );
1263
1264
case Intrinsic::experimental_vector_reduce_umax:
1264
1265
case Intrinsic::experimental_vector_reduce_umin:
1265
- return static_cast <T *>( this ) ->getMinMaxReductionCost (
1266
+ return ConcreteTTI ->getMinMaxReductionCost (
1266
1267
Tys[0 ], CmpInst::makeCmpResultType (Tys[0 ]), /* IsPairwiseForm=*/ false ,
1267
1268
/* IsSigned=*/ false );
1268
1269
case Intrinsic::ctpop:
@@ -1305,17 +1306,16 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1305
1306
if (MinLegalCostI != LegalCost.end ())
1306
1307
return *MinLegalCostI;
1307
1308
1308
- auto MinCustomCostI = std::min_element (CustomCost.begin (), CustomCost.end ());
1309
+ auto MinCustomCostI =
1310
+ std::min_element (CustomCost.begin (), CustomCost.end ());
1309
1311
if (MinCustomCostI != CustomCost.end ())
1310
1312
return *MinCustomCostI;
1311
1313
1312
1314
// If we can't lower fmuladd into an FMA estimate the cost as a floating
1313
1315
// point mul followed by an add.
1314
1316
if (IID == Intrinsic::fmuladd)
1315
- return static_cast <T *>(this )
1316
- ->getArithmeticInstrCost (BinaryOperator::FMul, RetTy) +
1317
- static_cast <T *>(this )
1318
- ->getArithmeticInstrCost (BinaryOperator::FAdd, RetTy);
1317
+ return ConcreteTTI->getArithmeticInstrCost (BinaryOperator::FMul, RetTy) +
1318
+ ConcreteTTI->getArithmeticInstrCost (BinaryOperator::FAdd, RetTy);
1319
1319
1320
1320
// Else, assume that we need to scalarize this intrinsic. For math builtins
1321
1321
// this will emit a costly libcall, adding call overhead and spills. Make it
@@ -1333,7 +1333,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
1333
1333
Ty = Ty->getScalarType ();
1334
1334
ScalarTys.push_back (Ty);
1335
1335
}
1336
- unsigned ScalarCost = static_cast <T *>( this ) ->getIntrinsicInstrCost (
1336
+ unsigned ScalarCost = ConcreteTTI ->getIntrinsicInstrCost (
1337
1337
IID, RetTy->getScalarType (), ScalarTys, FMF);
1338
1338
for (unsigned i = 0 , ie = Tys.size (); i != ie; ++i) {
1339
1339
if (Tys[i]->isVectorTy ()) {
0 commit comments