@@ -2015,18 +2015,24 @@ void VPReductionEVLRecipe::execute(VPTransformState &State) {
20152015InstructionCost VPReductionRecipe::computeCost (ElementCount VF,
20162016 VPCostContext &Ctx) const {
20172017 RecurKind RdxKind = RdxDesc.getRecurrenceKind ();
2018- // TODO: Support any-of reduction and in-loop reduction
2019- assert (!RecurrenceDescriptor::isAnyOfRecurrenceKind (RdxKind) &&
2020- " Not support any-of reduction in VPlan-based cost model currently." );
2021-
2022- Type *ElementTy = Ctx.Types .inferScalarType (this ->getVPSingleValue ());
2023- assert (ElementTy->getTypeID () == RdxDesc.getRecurrenceType ()->getTypeID () &&
2024- " Infered type and recurrence type mismatch." );
2025-
2018+ Type *ElementTy = Ctx.Types .inferScalarType (this );
20262019 auto *VectorTy = cast<VectorType>(ToVectorTy (ElementTy, VF));
20272020 TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
20282021 unsigned Opcode = RdxDesc.getOpcode ();
20292022
2023+ // TODO: Support any-of reduction and in-loop reductions.
2024+ assert (
2025+ (!RecurrenceDescriptor::isAnyOfRecurrenceKind (RdxKind) ||
2026+ ForceTargetInstructionCost.getNumOccurrences () > 0 ) &&
2027+ " Any-of reduction not implemented in VPlan-based cost model currently." );
2028+ assert (
2029+ (!Ctx.isInLoopReduction (getUnderlyingInstr (), VF, VectorTy) ||
2030+ ForceTargetInstructionCost.getNumOccurrences () > 0 ) &&
2031+ " In-loop reduction not implemented in VPlan-based cost model currently." );
2032+
2033+ assert (ElementTy->getTypeID () == RdxDesc.getRecurrenceType ()->getTypeID () &&
2034+ " Infered type and recurrence type mismatch." );
2035+
20302036 // Cost = Reduction cost + BinOp cost
20312037 InstructionCost Cost =
20322038 Ctx.TTI .getArithmeticInstrCost (Opcode, ElementTy, CostKind);
0 commit comments