@@ -2192,37 +2192,11 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
2192
2192
ISD = ISD::USUBO;
2193
2193
break ;
2194
2194
case Intrinsic::smul_with_overflow:
2195
- case Intrinsic::umul_with_overflow: {
2196
- Type *MulTy = RetTy->getContainedType (0 );
2197
- Type *OverflowTy = RetTy->getContainedType (1 );
2198
- unsigned ExtSize = MulTy->getScalarSizeInBits () * 2 ;
2199
- Type *ExtTy = MulTy->getWithNewBitWidth (ExtSize);
2200
- bool IsSigned = IID == Intrinsic::smul_with_overflow;
2201
-
2202
- unsigned ExtOp = IsSigned ? Instruction::SExt : Instruction::ZExt;
2203
- TTI::CastContextHint CCH = TTI::CastContextHint::None;
2204
-
2205
- InstructionCost Cost = 0 ;
2206
- Cost += 2 * thisT ()->getCastInstrCost (ExtOp, ExtTy, MulTy, CCH, CostKind);
2207
- Cost +=
2208
- thisT ()->getArithmeticInstrCost (Instruction::Mul, ExtTy, CostKind);
2209
- Cost += 2 * thisT ()->getCastInstrCost (Instruction::Trunc, MulTy, ExtTy,
2210
- CCH, CostKind);
2211
- Cost += thisT ()->getArithmeticInstrCost (Instruction::LShr, ExtTy,
2212
- CostKind,
2213
- {TTI::OK_AnyValue, TTI::OP_None},
2214
- {TTI::OK_UniformConstantValue, TTI::OP_None});
2215
-
2216
- if (IsSigned)
2217
- Cost += thisT ()->getArithmeticInstrCost (Instruction::AShr, MulTy,
2218
- CostKind,
2219
- {TTI::OK_AnyValue, TTI::OP_None},
2220
- {TTI::OK_UniformConstantValue, TTI::OP_None});
2221
-
2222
- Cost += thisT ()->getCmpSelInstrCost (
2223
- BinaryOperator::ICmp, MulTy, OverflowTy, CmpInst::ICMP_NE, CostKind);
2224
- return Cost;
2225
- }
2195
+ ISD = ISD::SMULO;
2196
+ break ;
2197
+ case Intrinsic::umul_with_overflow:
2198
+ ISD = ISD::UMULO;
2199
+ break ;
2226
2200
case Intrinsic::fptosi_sat:
2227
2201
case Intrinsic::fptoui_sat: {
2228
2202
if (Tys.empty ())
@@ -2367,6 +2341,37 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
2367
2341
OverflowTy, Pred, CostKind);
2368
2342
return Cost;
2369
2343
}
2344
+ case Intrinsic::smul_with_overflow:
2345
+ case Intrinsic::umul_with_overflow: {
2346
+ Type *MulTy = RetTy->getContainedType (0 );
2347
+ Type *OverflowTy = RetTy->getContainedType (1 );
2348
+ unsigned ExtSize = MulTy->getScalarSizeInBits () * 2 ;
2349
+ Type *ExtTy = MulTy->getWithNewBitWidth (ExtSize);
2350
+ bool IsSigned = IID == Intrinsic::smul_with_overflow;
2351
+
2352
+ unsigned ExtOp = IsSigned ? Instruction::SExt : Instruction::ZExt;
2353
+ TTI::CastContextHint CCH = TTI::CastContextHint::None;
2354
+
2355
+ InstructionCost Cost = 0 ;
2356
+ Cost += 2 * thisT ()->getCastInstrCost (ExtOp, ExtTy, MulTy, CCH, CostKind);
2357
+ Cost +=
2358
+ thisT ()->getArithmeticInstrCost (Instruction::Mul, ExtTy, CostKind);
2359
+ Cost += 2 * thisT ()->getCastInstrCost (Instruction::Trunc, MulTy, ExtTy,
2360
+ CCH, CostKind);
2361
+ Cost += thisT ()->getArithmeticInstrCost (
2362
+ Instruction::LShr, ExtTy, CostKind, {TTI::OK_AnyValue, TTI::OP_None},
2363
+ {TTI::OK_UniformConstantValue, TTI::OP_None});
2364
+
2365
+ if (IsSigned)
2366
+ Cost += thisT ()->getArithmeticInstrCost (
2367
+ Instruction::AShr, MulTy, CostKind,
2368
+ {TTI::OK_AnyValue, TTI::OP_None},
2369
+ {TTI::OK_UniformConstantValue, TTI::OP_None});
2370
+
2371
+ Cost += thisT ()->getCmpSelInstrCost (
2372
+ BinaryOperator::ICmp, MulTy, OverflowTy, CmpInst::ICMP_NE, CostKind);
2373
+ return Cost;
2374
+ }
2370
2375
case Intrinsic::sadd_sat:
2371
2376
case Intrinsic::ssub_sat: {
2372
2377
// Assume a default expansion.
0 commit comments