Skip to content

Commit 3097f54

Browse files
committed
Address review comment
1 parent fc515fb commit 3097f54

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,29 +1691,6 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
16911691
return Cost;
16921692
}
16931693

1694-
InstructionCost getActiveLaneMaskCost(Type *RetTy, Type *ArgTy,
1695-
TTI::TargetCostKind CostKind) {
1696-
EVT ResVT = getTLI()->getValueType(DL, RetTy, true);
1697-
EVT ArgVT = getTLI()->getValueType(DL, ArgTy, true);
1698-
1699-
// If we're not expanding the intrinsic then we assume this is cheap
1700-
// to implement.
1701-
if (!getTLI()->shouldExpandGetActiveLaneMask(ResVT, ArgVT))
1702-
return getTypeLegalizationCost(RetTy).first;
1703-
1704-
// Create the expanded types that will be used to calculate the uadd_sat
1705-
// operation.
1706-
Type *ExpRetTy =
1707-
VectorType::get(ArgTy, cast<VectorType>(RetTy)->getElementCount());
1708-
IntrinsicCostAttributes Attrs(Intrinsic::uadd_sat, ExpRetTy, {},
1709-
FastMathFlags());
1710-
InstructionCost Cost =
1711-
thisT()->getTypeBasedIntrinsicInstrCost(Attrs, CostKind);
1712-
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, ExpRetTy, RetTy,
1713-
CmpInst::ICMP_ULT, CostKind);
1714-
return Cost;
1715-
}
1716-
17171694
/// Get intrinsic cost based on arguments.
17181695
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
17191696
TTI::TargetCostKind CostKind) {
@@ -2009,10 +1986,6 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
20091986
}
20101987
return Cost;
20111988
}
2012-
case Intrinsic::get_active_lane_mask: {
2013-
return thisT()->getActiveLaneMaskCost(RetTy, ICA.getArgTypes()[0],
2014-
CostKind);
2015-
}
20161989
case Intrinsic::experimental_cttz_elts: {
20171990
EVT ArgType = getTLI()->getValueType(DL, ICA.getArgTypes()[0], true);
20181991

@@ -2060,6 +2033,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
20602033

20612034
return Cost;
20622035
}
2036+
case Intrinsic::get_active_lane_mask:
20632037
case Intrinsic::experimental_vector_match:
20642038
return thisT()->getTypeBasedIntrinsicInstrCost(ICA, CostKind);
20652039
case Intrinsic::modf:
@@ -2400,9 +2374,28 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
24002374
thisT()->getArithmeticInstrCost(BinaryOperator::And, RetTy, CostKind);
24012375
return Cost;
24022376
}
2403-
case Intrinsic::get_active_lane_mask:
2404-
return thisT()->getActiveLaneMaskCost(RetTy, ICA.getArgTypes()[0],
2405-
CostKind);
2377+
case Intrinsic::get_active_lane_mask: {
2378+
Type *ArgTy = ICA.getArgTypes()[0];
2379+
EVT ResVT = getTLI()->getValueType(DL, RetTy, true);
2380+
EVT ArgVT = getTLI()->getValueType(DL, ArgTy, true);
2381+
2382+
// If we're not expanding the intrinsic then we assume this is cheap
2383+
// to implement.
2384+
if (!getTLI()->shouldExpandGetActiveLaneMask(ResVT, ArgVT))
2385+
return getTypeLegalizationCost(RetTy).first;
2386+
2387+
// Create the expanded types that will be used to calculate the uadd_sat
2388+
// operation.
2389+
Type *ExpRetTy =
2390+
VectorType::get(ArgTy, cast<VectorType>(RetTy)->getElementCount());
2391+
IntrinsicCostAttributes Attrs(Intrinsic::uadd_sat, ExpRetTy, {},
2392+
FastMathFlags());
2393+
InstructionCost Cost =
2394+
thisT()->getTypeBasedIntrinsicInstrCost(Attrs, CostKind);
2395+
Cost += thisT()->getCmpSelInstrCost(BinaryOperator::ICmp, ExpRetTy, RetTy,
2396+
CmpInst::ICMP_ULT, CostKind);
2397+
return Cost;
2398+
}
24062399
case Intrinsic::abs:
24072400
ISD = ISD::ABS;
24082401
break;

0 commit comments

Comments
 (0)