@@ -2074,18 +2074,24 @@ void VPReductionEVLRecipe::execute(VPTransformState &State) {
20742074InstructionCost VPReductionRecipe::computeCost (ElementCount VF,
20752075 VPCostContext &Ctx) const {
20762076 RecurKind RdxKind = RdxDesc.getRecurrenceKind ();
2077- // TODO: Support any-of reduction and in-loop reduction
2078- assert (!RecurrenceDescriptor::isAnyOfRecurrenceKind (RdxKind) &&
2079- " Not support any-of reduction in VPlan-based cost model currently." );
2080-
2081- Type *ElementTy = Ctx.Types .inferScalarType (this ->getVPSingleValue ());
2082- assert (ElementTy->getTypeID () == RdxDesc.getRecurrenceType ()->getTypeID () &&
2083- " Infered type and recurrence type mismatch." );
2084-
2077+ Type *ElementTy = Ctx.Types .inferScalarType (this );
20852078 auto *VectorTy = cast<VectorType>(ToVectorTy (ElementTy, VF));
20862079 TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
20872080 unsigned Opcode = RdxDesc.getOpcode ();
20882081
2082+ // TODO: Support any-of reduction and in-loop reductions.
2083+ assert (
2084+ (!RecurrenceDescriptor::isAnyOfRecurrenceKind (RdxKind) ||
2085+ ForceTargetInstructionCost.getNumOccurrences () > 0 ) &&
2086+ " Any-of reduction not implemented in VPlan-based cost model currently." );
2087+ assert (
2088+ (!Ctx.isInLoopReduction (getUnderlyingInstr (), VF, VectorTy) ||
2089+ ForceTargetInstructionCost.getNumOccurrences () > 0 ) &&
2090+ " In-loop reduction not implemented in VPlan-based cost model currently." );
2091+
2092+ assert (ElementTy->getTypeID () == RdxDesc.getRecurrenceType ()->getTypeID () &&
2093+ " Infered type and recurrence type mismatch." );
2094+
20892095 // Cost = Reduction cost + BinOp cost
20902096 InstructionCost Cost =
20912097 Ctx.TTI .getArithmeticInstrCost (Opcode, ElementTy, CostKind);
0 commit comments