Skip to content

Commit 3d51f57

Browse files
committed
fix the comments
1. modified the EVLRecipe of costing from llvm.vp.intrinsic* ID
1 parent 1fe1b92 commit 3d51f57

File tree

4 files changed

+196
-217
lines changed

4 files changed

+196
-217
lines changed

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -987,34 +987,13 @@ InstructionCost VPWidenIntrinsicRecipe::computeCost(ElementCount VF,
987987
// clear Arguments.
988988
// TODO: Rework TTI interface to be independent of concrete IR values.
989989
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())) {
1016991
auto *V = Op->getUnderlyingValue();
1017992
if (!V) {
993+
if (VPIntrinsic::isVPIntrinsic(VectorIntrinsicID)) {
994+
Arguments.push_back(V);
995+
break;
996+
}
1018997
if (auto *UI = dyn_cast_or_null<CallBase>(getUnderlyingValue())) {
1019998
Arguments.push_back(UI->getArgOperand(Idx));
1020999
continue;
@@ -1027,14 +1006,14 @@ InstructionCost VPWidenIntrinsicRecipe::computeCost(ElementCount VF,
10271006

10281007
Type *RetTy = ToVectorTy(Ctx.Types.inferScalarType(this), VF);
10291008
SmallVector<Type *> ParamTys;
1030-
for (unsigned I = 0; I != NumOperands; ++I)
1009+
for (unsigned I = 0; I != getNumOperands(); ++I)
10311010
ParamTys.push_back(
10321011
ToVectorTy(Ctx.Types.inferScalarType(getOperand(I)), VF));
10331012

10341013
// TODO: Rework TTI interface to avoid reliance on underlying IntrinsicInst.
10351014
FastMathFlags FMF = hasFastMathFlags() ? getFastMathFlags() : FastMathFlags();
10361015
IntrinsicCostAttributes CostAttrs(
1037-
FID, RetTy, Arguments, ParamTys, FMF,
1016+
VectorIntrinsicID, RetTy, Arguments, ParamTys, FMF,
10381017
dyn_cast_or_null<IntrinsicInst>(getUnderlyingValue()));
10391018
return Ctx.TTI.getIntrinsicInstrCost(CostAttrs, CostKind);
10401019
}

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,9 +1488,8 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
14881488
IntegerType::getInt1Ty(CI->getContext())));
14891489
Ops.push_back(Mask);
14901490
}
1491-
if (VPIntrinsic::getVectorLengthParamPos(VPID)) {
1491+
if (VPIntrinsic::getVectorLengthParamPos(VPID))
14921492
Ops.push_back(&EVL);
1493-
}
14941493
return new VPWidenIntrinsicRecipe(
14951494
*CI, VPID, Ops, TypeInfo.inferScalarType(CInst),
14961495
CInst->getDebugLoc());

0 commit comments

Comments
 (0)