@@ -2116,20 +2116,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
21162116 case Intrinsic::vector_reduce_fminimum:
21172117 return thisT ()->getMinMaxReductionCost (getMinMaxReductionIntrinsicOp (IID),
21182118 VecOpTy, ICA.getFlags (), CostKind);
2119- case Intrinsic::abs: {
2120- // abs(X) = select(icmp(X,0),X,sub(0,X))
2121- Type *CondTy = RetTy->getWithNewBitWidth (1 );
2122- CmpInst::Predicate Pred = CmpInst::ICMP_SGT;
2123- InstructionCost Cost = 0 ;
2124- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, RetTy, CondTy,
2125- Pred, CostKind);
2126- Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::Select, RetTy, CondTy,
2127- Pred, CostKind);
2128- // TODO: Should we add an OperandValueProperties::OP_Zero property?
2129- Cost += thisT ()->getArithmeticInstrCost (
2130- BinaryOperator::Sub, RetTy, CostKind, {TTI::OK_UniformConstantValue, TTI::OP_None});
2131- return Cost;
2132- }
2119+ case Intrinsic::abs:
2120+ ISD = ISD::ABS;
2121+ break ;
21332122 case Intrinsic::smax:
21342123 ISD = ISD::SMAX;
21352124 break ;
@@ -2398,6 +2387,21 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
23982387 Cost += thisT ()->getArithmeticInstrCost (Instruction::Or, RetTy, CostKind);
23992388 return Cost;
24002389 }
2390+ case Intrinsic::abs: {
2391+ // abs(X) = select(icmp(X,0),X,sub(0,X))
2392+ Type *CondTy = RetTy->getWithNewBitWidth (1 );
2393+ CmpInst::Predicate Pred = CmpInst::ICMP_SGT;
2394+ InstructionCost Cost = 0 ;
2395+ Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::ICmp, RetTy, CondTy,
2396+ Pred, CostKind);
2397+ Cost += thisT ()->getCmpSelInstrCost (BinaryOperator::Select, RetTy, CondTy,
2398+ Pred, CostKind);
2399+ // TODO: Should we add an OperandValueProperties::OP_Zero property?
2400+ Cost += thisT ()->getArithmeticInstrCost (
2401+ BinaryOperator::Sub, RetTy, CostKind,
2402+ {TTI::OK_UniformConstantValue, TTI::OP_None});
2403+ return Cost;
2404+ }
24012405 case Intrinsic::fptosi_sat:
24022406 case Intrinsic::fptoui_sat: {
24032407 if (Tys.empty ())
0 commit comments