@@ -2183,31 +2183,11 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
2183
2183
ISD = ISD::UMULO;
2184
2184
break ;
2185
2185
case Intrinsic::fptosi_sat:
2186
- case Intrinsic::fptoui_sat: {
2187
- if (Tys.empty ())
2188
- break ;
2189
- Type *FromTy = Tys[0 ];
2190
- bool IsSigned = IID == Intrinsic::fptosi_sat;
2191
-
2192
- InstructionCost Cost = 0 ;
2193
- IntrinsicCostAttributes Attrs1 (Intrinsic::minnum, FromTy,
2194
- {FromTy, FromTy});
2195
- Cost += thisT ()->getIntrinsicInstrCost (Attrs1, CostKind);
2196
- IntrinsicCostAttributes Attrs2 (Intrinsic::maxnum, FromTy,
2197
- {FromTy, FromTy});
2198
- Cost += thisT ()->getIntrinsicInstrCost (Attrs2, CostKind);
2199
- Cost += thisT ()->getCastInstrCost (
2200
- IsSigned ? Instruction::FPToSI : Instruction::FPToUI, RetTy, FromTy,
2201
- TTI::CastContextHint::None, CostKind);
2202
- if (IsSigned) {
2203
- Type *CondTy = RetTy->getWithNewBitWidth (1 );
2204
- Cost += thisT ()->getCmpSelInstrCost (
2205
- BinaryOperator::FCmp, FromTy, CondTy, CmpInst::FCMP_UNO, CostKind);
2206
- Cost += thisT ()->getCmpSelInstrCost (
2207
- BinaryOperator::Select, RetTy, CondTy, CmpInst::FCMP_UNO, CostKind);
2208
- }
2209
- return Cost;
2210
- }
2186
+ ISD = ISD::FP_TO_SINT_SAT;
2187
+ break ;
2188
+ case Intrinsic::fptoui_sat:
2189
+ ISD = ISD::FP_TO_UINT_SAT;
2190
+ break ;
2211
2191
case Intrinsic::ctpop:
2212
2192
ISD = ISD::CTPOP;
2213
2193
// In case of legalization use TCC_Expensive. This is cheaper than a
@@ -2422,6 +2402,32 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
2422
2402
Cost += thisT ()->getArithmeticInstrCost (Instruction::Or, RetTy, CostKind);
2423
2403
return Cost;
2424
2404
}
2405
+ case Intrinsic::fptosi_sat:
2406
+ case Intrinsic::fptoui_sat: {
2407
+ if (Tys.empty ())
2408
+ break ;
2409
+ Type *FromTy = Tys[0 ];
2410
+ bool IsSigned = IID == Intrinsic::fptosi_sat;
2411
+
2412
+ InstructionCost Cost = 0 ;
2413
+ IntrinsicCostAttributes Attrs1 (Intrinsic::minnum, FromTy,
2414
+ {FromTy, FromTy});
2415
+ Cost += thisT ()->getIntrinsicInstrCost (Attrs1, CostKind);
2416
+ IntrinsicCostAttributes Attrs2 (Intrinsic::maxnum, FromTy,
2417
+ {FromTy, FromTy});
2418
+ Cost += thisT ()->getIntrinsicInstrCost (Attrs2, CostKind);
2419
+ Cost += thisT ()->getCastInstrCost (
2420
+ IsSigned ? Instruction::FPToSI : Instruction::FPToUI, RetTy, FromTy,
2421
+ TTI::CastContextHint::None, CostKind);
2422
+ if (IsSigned) {
2423
+ Type *CondTy = RetTy->getWithNewBitWidth (1 );
2424
+ Cost += thisT ()->getCmpSelInstrCost (
2425
+ BinaryOperator::FCmp, FromTy, CondTy, CmpInst::FCMP_UNO, CostKind);
2426
+ Cost += thisT ()->getCmpSelInstrCost (
2427
+ BinaryOperator::Select, RetTy, CondTy, CmpInst::FCMP_UNO, CostKind);
2428
+ }
2429
+ return Cost;
2430
+ }
2425
2431
default :
2426
2432
break ;
2427
2433
}
0 commit comments