@@ -2120,20 +2120,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
21202120 case Intrinsic::vector_reduce_fminimum:
21212121 return thisT ()->getMinMaxReductionCost (getMinMaxReductionIntrinsicOp (IID),
21222122 VecOpTy, ICA.getFlags (), CostKind);
2123- case Intrinsic::abs: {
2124- // abs(X) = select(icmp(X,0),X,sub(0,X))
2125- Type *CondTy = RetTy->getWithNewBitWidth (1 );
2126- CmpInst::Predicate Pred = CmpInst::ICMP_SGT;
2127- InstructionCost Cost = 0 ;
2128- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, RetTy, CondTy,
2129- Pred, CostKind);
2130- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::Select, RetTy, CondTy,
2131- Pred, CostKind);
2132- // TODO: Should we add an OperandValueProperties::OP_Zero property?
2133- Cost += thisT ()->getArithmeticInstrCost (
2134- BinaryOperator::Sub, RetTy, CostKind, {TTI::OK_UniformConstantValue, TTI::OP_None});
2135- return Cost;
2136- }
2123+ case Intrinsic::abs:
2124+ ISD = ISD::ABS;
2125+ break ;
21372126 case Intrinsic::smax:
21382127 ISD = ISD::SMAX;
21392128 break ;
@@ -2402,6 +2391,21 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
24022391 Cost += thisT ()->getArithmeticInstrCost (Instruction::Or, RetTy, CostKind);
24032392 return Cost;
24042393 }
2394+ case Intrinsic::abs: {
2395+ // abs(X) = select(icmp(X,0),X,sub(0,X))
2396+ Type *CondTy = RetTy->getWithNewBitWidth (1 );
2397+ CmpInst::Predicate Pred = CmpInst::ICMP_SGT;
2398+ InstructionCost Cost = 0 ;
2399+ Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, RetTy, CondTy,
2400+ Pred, CostKind);
2401+ Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::Select, RetTy, CondTy,
2402+ Pred, CostKind);
2403+ // TODO: Should we add an OperandValueProperties::OP_Zero property?
2404+ Cost += thisT ()->getArithmeticInstrCost (
2405+ BinaryOperator::Sub, RetTy, CostKind,
2406+ {TTI::OK_UniformConstantValue, TTI::OP_None});
2407+ return Cost;
2408+ }
24052409 case Intrinsic::fptosi_sat:
24062410 case Intrinsic::fptoui_sat: {
24072411 if (Tys.empty ())
0 commit comments