@@ -5410,6 +5410,24 @@ static InstructionCost getVectorInstrCost(
5410
5410
ScalarUserAndIdx);
5411
5411
}
5412
5412
5413
+ /// This is similar to TargetTransformInfo::getExtractWithExtendCost, but if Dst
5414
+ /// is a FixedVectorType, a vector will be extracted instead of a scalar.
5415
+ static InstructionCost getExtractWithExtendCost(
5416
+ const TargetTransformInfo &TTI, unsigned Opcode, Type *Dst,
5417
+ VectorType *VecTy, unsigned Index,
5418
+ TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput) {
5419
+ if (auto *ScalarTy = dyn_cast<FixedVectorType>(Dst)) {
5420
+ assert(SLPReVec && "Only supported by REVEC.");
5421
+ auto *SubTp =
5422
+ getWidenedType(VecTy->getElementType(), ScalarTy->getNumElements());
5423
+ return getShuffleCost(TTI, TTI::SK_ExtractSubvector, VecTy, {}, CostKind,
5424
+ Index * ScalarTy->getNumElements(), SubTp) +
5425
+ TTI.getCastInstrCost(Opcode, Dst, SubTp, TTI::CastContextHint::None,
5426
+ CostKind);
5427
+ }
5428
+ return TTI.getExtractWithExtendCost(Opcode, Dst, VecTy, Index);
5429
+ }
5430
+
5413
5431
/// Correctly creates insert_subvector, checking that the index is multiple of
5414
5432
/// the subvectors length. Otherwise, generates shuffle using \p Generator or
5415
5433
/// using default shuffle.
@@ -14155,13 +14173,15 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals,
14155
14173
const TreeEntry *Entry = &EU.E;
14156
14174
auto It = MinBWs.find(Entry);
14157
14175
if (It != MinBWs.end()) {
14158
- auto *MinTy = IntegerType::get(F->getContext(), It->second.first);
14176
+ Type *MinTy = IntegerType::get(F->getContext(), It->second.first);
14177
+ if (auto *VecTy = dyn_cast<FixedVectorType>(ScalarTy))
14178
+ MinTy = getWidenedType(MinTy, VecTy->getNumElements());
14159
14179
unsigned Extend = isKnownNonNegative(EU.Scalar, SimplifyQuery(*DL))
14160
14180
? Instruction::ZExt
14161
14181
: Instruction::SExt;
14162
14182
VecTy = getWidenedType(MinTy, BundleWidth);
14163
- ExtraCost = TTI->getExtractWithExtendCost(Extend, EU.Scalar->getType(),
14164
- VecTy, EU.Lane);
14183
+ ExtraCost =
14184
+ getExtractWithExtendCost(*TTI, Extend, ScalarTy, VecTy, EU.Lane);
14165
14185
} else {
14166
14186
ExtraCost =
14167
14187
getVectorInstrCost(*TTI, ScalarTy, Instruction::ExtractElement, VecTy,
0 commit comments