@@ -2120,20 +2120,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
2120
2120
case Intrinsic::vector_reduce_fminimum:
2121
2121
return thisT ()->getMinMaxReductionCost (getMinMaxReductionIntrinsicOp (IID),
2122
2122
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 ;
2137
2126
case Intrinsic::smax:
2138
2127
ISD = ISD::SMAX;
2139
2128
break ;
@@ -2402,6 +2391,21 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
2402
2391
Cost += thisT ()->getArithmeticInstrCost (Instruction::Or, RetTy, CostKind);
2403
2392
return Cost;
2404
2393
}
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
+ }
2405
2409
case Intrinsic::fptosi_sat:
2406
2410
case Intrinsic::fptoui_sat: {
2407
2411
if (Tys.empty ())
0 commit comments