[llvm] [CostModel] Add type-based cost model for get.active.lane.mask intrinsic (PR #130132)
Ricardo Jesus via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 6 08:52:27 PST 2025
================
@@ -1987,25 +2010,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return Cost;
}
case Intrinsic::get_active_lane_mask: {
- EVT ResVT = getTLI()->getValueType(DL, RetTy, true);
- EVT ArgType = getTLI()->getValueType(DL, ICA.getArgTypes()[0], true);
-
- // If we're not expanding the intrinsic then we assume this is cheap
- // to implement.
- if (!getTLI()->shouldExpandGetActiveLaneMask(ResVT, ArgType)) {
- return getTypeLegalizationCost(RetTy).first;
- }
-
- // Create the expanded types that will be used to calculate the uadd_sat
- // operation.
- Type *ExpRetTy = VectorType::get(
- ICA.getArgTypes()[0], cast<VectorType>(RetTy)->getElementCount());
- IntrinsicCostAttributes Attrs(Intrinsic::uadd_sat, ExpRetTy, {}, FMF);
- InstructionCost Cost =
- thisT()->getTypeBasedIntrinsicInstrCost(Attrs, CostKind);
- Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, ExpRetTy, RetTy,
- CmpInst::ICMP_ULT, CostKind);
- return Cost;
+ return thisT()->getActiveLaneMaskCost(RetTy, ICA.getArgTypes()[0],
+ CostKind);
----------------
rj-jesus wrote:
Could this be
```
return thisT()->getTypeBasedIntrinsicInstrCost(ICA, CostKind);
```
so that `getActiveLaneMaskCost` could be moved inline to `getTypeBasedIntrinsicInstrCost`? That's what we did for `experimental_vector_match`.
If we did this, we could probably also group the `case` blocks of the two intrinsics and save an extra LOC. What do you think? :)
https://github.com/llvm/llvm-project/pull/130132
More information about the llvm-commits
mailing list