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