@@ -987,34 +987,13 @@ InstructionCost VPWidenIntrinsicRecipe::computeCost(ElementCount VF,
987
987
// clear Arguments.
988
988
// TODO: Rework TTI interface to be independent of concrete IR values.
989
989
SmallVector<const Value *> Arguments;
990
-
991
- // In fact, we need to get the VP intrinsics cost from the TTI, but currently
992
- // the legacy model, it will always calculate cost of the call Intrinsics, eg:
993
- // llvm.ctlz/llvm.smax, so VP Intrinsics should have the same cost as their
994
- // non-vp counterpart.
995
- // TODO: Use VP intrinsics to calculate the cost, if the following conditions
996
- // are met
997
- // 1. We don't need to compare to the legacy cost model
998
- // 2. The cost model of VP is gradually improved in TTI
999
- // 3. VPlan can set accurate CostAttrs’s parameters
1000
- Intrinsic::ID FID = VectorIntrinsicID;
1001
- unsigned NumOperands = getNumOperands ();
1002
- const_operand_range arg_operands =
1003
- make_range (op_begin (), op_begin () + getNumOperands ());
1004
- if (VPIntrinsic::isVPIntrinsic (VectorIntrinsicID)) {
1005
- std::optional<Intrinsic::ID> ID =
1006
- VPIntrinsic::getFunctionalIntrinsicIDForVP (VectorIntrinsicID);
1007
- if (ID) {
1008
- FID = ID.value ();
1009
- NumOperands = getNumOperands () - 2 ;
1010
- // Remove the Mask && EVL from arg_operands
1011
- arg_operands = make_range (op_begin (), op_begin () + getNumOperands () - 2 );
1012
- }
1013
- }
1014
-
1015
- for (const auto &[Idx, Op] : enumerate(arg_operands)) {
990
+ for (const auto &[Idx, Op] : enumerate(operands ())) {
1016
991
auto *V = Op->getUnderlyingValue ();
1017
992
if (!V) {
993
+ if (VPIntrinsic::isVPIntrinsic (VectorIntrinsicID)) {
994
+ Arguments.push_back (V);
995
+ break ;
996
+ }
1018
997
if (auto *UI = dyn_cast_or_null<CallBase>(getUnderlyingValue ())) {
1019
998
Arguments.push_back (UI->getArgOperand (Idx));
1020
999
continue ;
@@ -1027,14 +1006,14 @@ InstructionCost VPWidenIntrinsicRecipe::computeCost(ElementCount VF,
1027
1006
1028
1007
Type *RetTy = ToVectorTy (Ctx.Types .inferScalarType (this ), VF);
1029
1008
SmallVector<Type *> ParamTys;
1030
- for (unsigned I = 0 ; I != NumOperands ; ++I)
1009
+ for (unsigned I = 0 ; I != getNumOperands () ; ++I)
1031
1010
ParamTys.push_back (
1032
1011
ToVectorTy (Ctx.Types .inferScalarType (getOperand (I)), VF));
1033
1012
1034
1013
// TODO: Rework TTI interface to avoid reliance on underlying IntrinsicInst.
1035
1014
FastMathFlags FMF = hasFastMathFlags () ? getFastMathFlags () : FastMathFlags ();
1036
1015
IntrinsicCostAttributes CostAttrs (
1037
- FID , RetTy, Arguments, ParamTys, FMF,
1016
+ VectorIntrinsicID , RetTy, Arguments, ParamTys, FMF,
1038
1017
dyn_cast_or_null<IntrinsicInst>(getUnderlyingValue ()));
1039
1018
return Ctx.TTI .getIntrinsicInstrCost (CostAttrs, CostKind);
1040
1019
}
0 commit comments