@@ -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,25 +1609,65 @@ class VPScalarCastRecipe : public VPSingleDefRecipe {
1608
1609
}
1609
1610
};
1610
1611
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.
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
+ : VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments,
1626
+ *cast<Instruction>(UV)),
1627
+ VectorIntrinsicID (VectorIntrinsicID), ResultTy(Ty) {}
1628
+
1629
+ ~VPWidenIntrinsicRecipe () override = default ;
1630
+
1631
+ VPWidenIntrinsicRecipe *clone () override {
1632
+ return new VPWidenIntrinsicRecipe (getUnderlyingValue (), VectorIntrinsicID,
1633
+ operands (), ResultTy, 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.
1620
1662
Function *Variant;
1621
1663
1622
1664
public:
1623
1665
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 = {})
1627
1668
: VPRecipeWithIRFlags(VPDef::VPWidenCallSC, CallArguments,
1628
1669
*cast<Instruction>(UV)),
1629
- VectorIntrinsicID (VectorIntrinsicID), Variant(Variant) {
1670
+ Variant (Variant) {
1630
1671
assert (
1631
1672
isa<Function>(getOperand (getNumOperands () - 1 )->getLiveInIRValue ()) &&
1632
1673
" last operand must be the called function" );
@@ -1635,8 +1676,8 @@ class VPWidenCallRecipe : public VPRecipeWithIRFlags {
1635
1676
~VPWidenCallRecipe () override = default ;
1636
1677
1637
1678
VPWidenCallRecipe *clone () override {
1638
- return new VPWidenCallRecipe (getUnderlyingValue (), operands (),
1639
- VectorIntrinsicID, getDebugLoc (), Variant );
1679
+ return new VPWidenCallRecipe (getUnderlyingValue (), Variant, operands (),
1680
+ getDebugLoc ());
1640
1681
}
1641
1682
1642
1683
VP_CLASSOF_IMPL (VPDef::VPWidenCallSC)
0 commit comments