@@ -886,6 +886,7 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPValue {
886
886
case VPRecipeBase::VPWidenCanonicalIVSC:
887
887
case VPRecipeBase::VPWidenCastSC:
888
888
case VPRecipeBase::VPWidenGEPSC:
889
+ case VPRecipeBase::VPWidenIntrinsicSC:
889
890
case VPRecipeBase::VPWidenSC:
890
891
case VPRecipeBase::VPWidenEVLSC:
891
892
case VPRecipeBase::VPWidenSelectSC:
@@ -1608,24 +1609,63 @@ class VPScalarCastRecipe : public VPSingleDefRecipe {
1608
1609
}
1609
1610
};
1610
1611
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.
1615
1615
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.
1620
1661
Function *Variant;
1621
1662
1622
1663
public:
1623
1664
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 = {})
1627
1667
: VPSingleDefRecipe(VPDef::VPWidenCallSC, CallArguments, UV, DL),
1628
- VectorIntrinsicID (VectorIntrinsicID), Variant(Variant) {
1668
+ Variant (Variant) {
1629
1669
assert (
1630
1670
isa<Function>(getOperand (getNumOperands () - 1 )->getLiveInIRValue ()) &&
1631
1671
" last operand must be the called function" );
@@ -1634,8 +1674,8 @@ class VPWidenCallRecipe : public VPSingleDefRecipe {
1634
1674
~VPWidenCallRecipe () override = default ;
1635
1675
1636
1676
VPWidenCallRecipe *clone () override {
1637
- return new VPWidenCallRecipe (getUnderlyingValue (), operands (),
1638
- VectorIntrinsicID, getDebugLoc (), Variant );
1677
+ return new VPWidenCallRecipe (getUnderlyingValue (), Variant, operands (),
1678
+ getDebugLoc ());
1639
1679
}
1640
1680
1641
1681
VP_CLASSOF_IMPL (VPDef::VPWidenCallSC)
0 commit comments