@@ -886,6 +886,7 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPValue {
886886 case VPRecipeBase::VPWidenCanonicalIVSC:
887887 case VPRecipeBase::VPWidenCastSC:
888888 case VPRecipeBase::VPWidenGEPSC:
889+ case VPRecipeBase::VPWidenIntrinsicSC:
889890 case VPRecipeBase::VPWidenSC:
890891 case VPRecipeBase::VPWidenEVLSC:
891892 case VPRecipeBase::VPWidenSelectSC:
@@ -1608,25 +1609,65 @@ class VPScalarCastRecipe : public VPSingleDefRecipe {
16081609 }
16091610};
16101611
1611- // / A recipe for widening Call instructions.
1612- class VPWidenCallRecipe : public VPRecipeWithIRFlags {
1613- // / ID of the vector intrinsic to call when widening the call. If set the
1614- // / Intrinsic::not_intrinsic, a library call will be used instead.
1612+ // / A recipe for widening vector intrinsics.
1613+ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags {
1614+ // / ID of the vector intrinsic to widen.
16151615 Intrinsic::ID VectorIntrinsicID;
1616- // / If this recipe represents a library call, Variant stores a pointer to
1617- // / the chosen function. There is a 1:1 mapping between a given VF and the
1618- // / chosen vectorized variant, so there will be a different vplan for each
1619- // / VF with a valid variant.
1616+
1617+ // / Scalar type of the result produced by the intrinsic.
1618+ Type *ResultTy;
1619+
1620+ public:
1621+ template <typename IterT>
1622+ VPWidenIntrinsicRecipe (CallInst &CI, Intrinsic::ID VectorIntrinsicID,
1623+ iterator_range<IterT> CallArguments, Type *Ty,
1624+ DebugLoc DL = {})
1625+ : VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, CI),
1626+ VectorIntrinsicID (VectorIntrinsicID), ResultTy(Ty) {}
1627+
1628+ ~VPWidenIntrinsicRecipe () override = default ;
1629+
1630+ VPWidenIntrinsicRecipe *clone () override {
1631+ return new VPWidenIntrinsicRecipe (*cast<CallInst>(getUnderlyingValue ()),
1632+ VectorIntrinsicID, operands (), ResultTy,
1633+ getDebugLoc ());
1634+ }
1635+
1636+ VP_CLASSOF_IMPL (VPDef::VPWidenIntrinsicSC)
1637+
1638+ // / Produce a widened version of the vector intrinsic.
1639+ void execute(VPTransformState &State) override ;
1640+
1641+ // / Return the cost of this vector intrinsic.
1642+ InstructionCost computeCost (ElementCount VF,
1643+ VPCostContext &Ctx) const override ;
1644+
1645+ Type *getResultTy () const { return ResultTy; }
1646+
1647+ // / Return to name of the intrinsic as string.
1648+ StringRef getIntrinsicName () const ;
1649+
1650+ #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1651+ // / Print the recipe.
1652+ void print (raw_ostream &O, const Twine &Indent,
1653+ VPSlotTracker &SlotTracker) const override ;
1654+ #endif
1655+ };
1656+
1657+ // / A recipe for widening Call instructions using library calls.
1658+ class VPWidenCallRecipe : public VPRecipeWithIRFlags {
1659+ // / Variant stores a pointer to the chosen function. There is a 1:1 mapping
1660+ // / between a given VF and the chosen vectorized variant, so there will be a
1661+ // / different VPlan for each VF with a valid variant.
16201662 Function *Variant;
16211663
16221664public:
16231665 template <typename IterT>
1624- VPWidenCallRecipe (Value *UV, iterator_range<IterT> CallArguments,
1625- Intrinsic::ID VectorIntrinsicID, DebugLoc DL = {},
1626- Function *Variant = nullptr )
1666+ VPWidenCallRecipe (Value *UV, Function *Variant,
1667+ iterator_range<IterT> CallArguments, DebugLoc DL = {})
16271668 : VPRecipeWithIRFlags(VPDef::VPWidenCallSC, CallArguments,
16281669 *cast<Instruction>(UV)),
1629- VectorIntrinsicID (VectorIntrinsicID), Variant(Variant) {
1670+ Variant (Variant) {
16301671 assert (
16311672 isa<Function>(getOperand (getNumOperands () - 1 )->getLiveInIRValue ()) &&
16321673 " last operand must be the called function" );
@@ -1635,8 +1676,8 @@ class VPWidenCallRecipe : public VPRecipeWithIRFlags {
16351676 ~VPWidenCallRecipe () override = default ;
16361677
16371678 VPWidenCallRecipe *clone () override {
1638- return new VPWidenCallRecipe (getUnderlyingValue (), operands (),
1639- VectorIntrinsicID, getDebugLoc (), Variant );
1679+ return new VPWidenCallRecipe (getUnderlyingValue (), Variant, operands (),
1680+ getDebugLoc ());
16401681 }
16411682
16421683 VP_CLASSOF_IMPL (VPDef::VPWidenCallSC)
0 commit comments