@@ -2116,20 +2116,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
2116
2116
case Intrinsic::vector_reduce_fminimum:
2117
2117
return thisT ()->getMinMaxReductionCost (getMinMaxReductionIntrinsicOp (IID),
2118
2118
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 ;
2133
2122
case Intrinsic::smax:
2134
2123
ISD = ISD::SMAX;
2135
2124
break ;
@@ -2398,6 +2387,21 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
2398
2387
Cost += thisT ()->getArithmeticInstrCost (Instruction::Or, RetTy, CostKind);
2399
2388
return Cost;
2400
2389
}
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
+ }
2401
2405
case Intrinsic::fptosi_sat:
2402
2406
case Intrinsic::fptoui_sat: {
2403
2407
if (Tys.empty ())
0 commit comments