@@ -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,24 +1609,63 @@ class VPScalarCastRecipe : public VPSingleDefRecipe {
16081609 }
16091610};
16101611
1611- // / A recipe for widening Call instructions.
1612- class VPWidenCallRecipe : public VPSingleDefRecipe {
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 VPSingleDefRecipe {
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 (Value *UV, Intrinsic::ID VectorIntrinsicID,
1623+ iterator_range<IterT> CallArguments, Type *Ty,
1624+ DebugLoc DL = {})
1625+ : VPSingleDefRecipe(VPDef::VPWidenIntrinsicSC, CallArguments, UV, DL),
1626+ VectorIntrinsicID (VectorIntrinsicID), ResultTy(Ty) {}
1627+
1628+ ~VPWidenIntrinsicRecipe () override = default ;
1629+
1630+ VPWidenIntrinsicRecipe *clone () override {
1631+ return new VPWidenIntrinsicRecipe (getUnderlyingValue (), VectorIntrinsicID,
1632+ operands (), ResultTy, getDebugLoc ());
1633+ }
1634+
1635+ VP_CLASSOF_IMPL (VPDef::VPWidenIntrinsicSC)
1636+
1637+ // / Produce a widened version of the vector intrinsic.
1638+ void execute(VPTransformState &State) override ;
1639+
1640+ // / Return the cost of this vector intrinsic.
1641+ InstructionCost computeCost (ElementCount VF,
1642+ VPCostContext &Ctx) const override ;
1643+
1644+ Type *getResultTy () const { return ResultTy; }
1645+
1646+ // / Return to name of the intrinsic as string.
1647+ StringRef getIntrinsicName () const ;
1648+
1649+ #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1650+ // / Print the recipe.
1651+ void print (raw_ostream &O, const Twine &Indent,
1652+ VPSlotTracker &SlotTracker) const override ;
1653+ #endif
1654+ };
1655+
1656+ // / A recipe for widening Call instructions using library calls.
1657+ class VPWidenCallRecipe : public VPSingleDefRecipe {
1658+ // / Variant stores a pointer to the chosen function. There is a 1:1 mapping
1659+ // / between a given VF and the chosen vectorized variant, so there will be a
1660+ // / different VPlan for each VF with a valid variant.
16201661 Function *Variant;
16211662
16221663public:
16231664 template <typename IterT>
1624- VPWidenCallRecipe (Value *UV, iterator_range<IterT> CallArguments,
1625- Intrinsic::ID VectorIntrinsicID, DebugLoc DL = {},
1626- Function *Variant = nullptr )
1665+ VPWidenCallRecipe (Value *UV, Function *Variant,
1666+ iterator_range<IterT> CallArguments, DebugLoc DL = {})
16271667 : VPSingleDefRecipe(VPDef::VPWidenCallSC, CallArguments, UV, DL),
1628- VectorIntrinsicID (VectorIntrinsicID), Variant(Variant) {
1668+ Variant (Variant) {
16291669 assert (
16301670 isa<Function>(getOperand (getNumOperands () - 1 )->getLiveInIRValue ()) &&
16311671 " last operand must be the called function" );
@@ -1634,8 +1674,8 @@ class VPWidenCallRecipe : public VPSingleDefRecipe {
16341674 ~VPWidenCallRecipe () override = default ;
16351675
16361676 VPWidenCallRecipe *clone () override {
1637- return new VPWidenCallRecipe (getUnderlyingValue (), operands (),
1638- VectorIntrinsicID, getDebugLoc (), Variant );
1677+ return new VPWidenCallRecipe (getUnderlyingValue (), Variant, operands (),
1678+ getDebugLoc ());
16391679 }
16401680
16411681 VP_CLASSOF_IMPL (VPDef::VPWidenCallSC)
0 commit comments