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