diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp index 0d3c9aeec6be4..55d70fbbc5e41 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp @@ -754,6 +754,16 @@ InstructionCost VPInstruction::computeCost(ElementCount VF, return Cost + Ctx.TTI.getVectorInstrCost(Instruction::ExtractElement, VecTy, Ctx.CostKind); } + case VPInstruction::FirstOrderRecurrenceSplice: { + assert(VF.isVector() && "Scalar FirstOrderRecurrenceSplice?"); + SmallVector Mask(VF.getKnownMinValue()); + std::iota(Mask.begin(), Mask.end(), VF.getKnownMinValue() - 1); + Type *VectorTy = toVectorTy(Ctx.Types.inferScalarType(this), VF); + + return Ctx.TTI.getShuffleCost(TargetTransformInfo::SK_Splice, + cast(VectorTy), Mask, + Ctx.CostKind, VF.getKnownMinValue() - 1); + } default: // TODO: Compute cost other VPInstructions once the legacy cost model has // been retired. @@ -3472,14 +3482,7 @@ VPFirstOrderRecurrencePHIRecipe::computeCost(ElementCount VF, if (VF.isScalable() && VF.getKnownMinValue() == 1) return InstructionCost::getInvalid(); - SmallVector Mask(VF.getKnownMinValue()); - std::iota(Mask.begin(), Mask.end(), VF.getKnownMinValue() - 1); - Type *VectorTy = - toVectorTy(Ctx.Types.inferScalarType(this->getVPSingleValue()), VF); - - return Ctx.TTI.getShuffleCost(TargetTransformInfo::SK_Splice, - cast(VectorTy), Mask, Ctx.CostKind, - VF.getKnownMinValue() - 1); + return 0; } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) diff --git a/llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-intrinsics-fixed-order-recurrence.ll b/llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-intrinsics-fixed-order-recurrence.ll index 0bcfe13832ae7..deeff38b1fe78 100644 --- a/llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-intrinsics-fixed-order-recurrence.ll +++ b/llvm/test/Transforms/LoopVectorize/RISCV/vplan-vp-intrinsics-fixed-order-recurrence.ll @@ -51,7 +51,8 @@ define void @first_order_recurrence(ptr noalias %A, ptr noalias %B, i64 %TC) { ; IF-EVL-NEXT: EMIT vp<[[RESUME_EXTRACT:%.+]]> = extract-from-end ir<[[LD]]>, ir<1> ; IF-EVL-NEXT: EMIT branch-on-cond ir ; IF-EVL-NEXT: Successor(s): ir-bb, scalar.ph - +; IF-EVL: Cost of 0 for VF vscale x 4: FIRST-ORDER-RECURRENCE-PHI ir<[[FOR_PHI]]> = phi ir<33>, ir<[[LD]]> +; IF-EVL: Cost of 4 for VF vscale x 4: WIDEN-INTRINSIC vp<[[SPLICE]]> = call llvm.experimental.vp.splice(ir<[[FOR_PHI]]>, ir<[[LD]]>, ir<-1>, ir, vp<[[PREV_EVL]]>, vp<[[EVL]]>) entry: br label %for.body