if (CI)
Idx = CI->getZExtValue();
- // Try to match a reduction sequence (series of shufflevector and
- // vector adds followed by a extractelement).
- unsigned ReduxOpCode;
- VectorType *ReduxType;
-
- switch (TTI::matchVectorSplittingReduction(EEI, ReduxOpCode,
- ReduxType)) {
- case TTI::RK_Arithmetic:
- return TargetTTI->getArithmeticReductionCost(ReduxOpCode, ReduxType,
- /*IsPairwiseForm=*/false,
- CostKind);
- case TTI::RK_MinMax:
- return TargetTTI->getMinMaxReductionCost(
- ReduxType, cast<VectorType>(CmpInst::makeCmpResultType(ReduxType)),
- /*IsPairwiseForm=*/false, /*IsUnsigned=*/false, CostKind);
- case TTI::RK_UnsignedMinMax:
- return TargetTTI->getMinMaxReductionCost(
- ReduxType, cast<VectorType>(CmpInst::makeCmpResultType(ReduxType)),
- /*IsPairwiseForm=*/false, /*IsUnsigned=*/true, CostKind);
- case TTI::RK_None:
- break;
- }
-
- switch (TTI::matchPairwiseReduction(EEI, ReduxOpCode, ReduxType)) {
+ // Try to match a reduction (a series of shufflevector and vector ops
+ // followed by an extractelement).
+ unsigned RdxOpcode;
+ VectorType *RdxType;
+ bool IsPairwise;
+ switch (TTI::matchVectorReduction(EEI, RdxOpcode, RdxType, IsPairwise)) {
case TTI::RK_Arithmetic:
- return TargetTTI->getArithmeticReductionCost(ReduxOpCode, ReduxType,
- /*IsPairwiseForm=*/true, CostKind);
+ return TargetTTI->getArithmeticReductionCost(RdxOpcode, RdxType,
+ IsPairwise, CostKind);
case TTI::RK_MinMax:
return TargetTTI->getMinMaxReductionCost(
- ReduxType, cast<VectorType>(CmpInst::makeCmpResultType(ReduxType)),
- /*IsPairwiseForm=*/true, /*IsUnsigned=*/false, CostKind);
+ RdxType, cast<VectorType>(CmpInst::makeCmpResultType(RdxType)),
+ IsPairwise, /*IsUnsigned=*/false, CostKind);
case TTI::RK_UnsignedMinMax:
return TargetTTI->getMinMaxReductionCost(
- ReduxType, cast<VectorType>(CmpInst::makeCmpResultType(ReduxType)),
- /*IsPairwiseForm=*/true, /*IsUnsigned=*/true, CostKind);
+ RdxType, cast<VectorType>(CmpInst::makeCmpResultType(RdxType)),
+ IsPairwise, /*IsUnsigned=*/true, CostKind);
case TTI::RK_None:
break;
}
return RD->Kind;
}
+TTI::ReductionKind
+TTI::matchVectorReduction(const ExtractElementInst *Root, unsigned &Opcode,
+ VectorType *&Ty, bool &IsPairwise) {
+ TTI::ReductionKind RdxKind = matchVectorSplittingReduction(Root, Opcode, Ty);
+ if (RdxKind != TTI::ReductionKind::RK_None) {
+ IsPairwise = false;
+ return RdxKind;
+ }
+ IsPairwise = true;
+ return matchPairwiseReduction(Root, Opcode, Ty);
+}
+
int TargetTransformInfo::getInstructionThroughput(const Instruction *I) const {
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;