Skip to content

Commit 1030345

Browse files
committed
Use switch
1 parent 0783583 commit 1030345

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,23 +2323,26 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
23232323
return (LT.first * 2);
23242324
}
23252325

2326-
// If we can't lower fmuladd into an FMA estimate the cost as a floating
2327-
// point mul followed by an add.
2328-
if (IID == Intrinsic::fmuladd)
2326+
switch (IID) {
2327+
case Intrinsic::fmuladd: {
2328+
// If we can't lower fmuladd into an FMA estimate the cost as a floating
2329+
// point mul followed by an add.
2330+
23292331
return thisT()->getArithmeticInstrCost(BinaryOperator::FMul, RetTy,
23302332
CostKind) +
23312333
thisT()->getArithmeticInstrCost(BinaryOperator::FAdd, RetTy,
23322334
CostKind);
2333-
if (IID == Intrinsic::experimental_constrained_fmuladd) {
2335+
}
2336+
case Intrinsic::experimental_constrained_fmuladd: {
23342337
IntrinsicCostAttributes FMulAttrs(
23352338
Intrinsic::experimental_constrained_fmul, RetTy, Tys);
23362339
IntrinsicCostAttributes FAddAttrs(
23372340
Intrinsic::experimental_constrained_fadd, RetTy, Tys);
23382341
return thisT()->getIntrinsicInstrCost(FMulAttrs, CostKind) +
23392342
thisT()->getIntrinsicInstrCost(FAddAttrs, CostKind);
23402343
}
2341-
2342-
if (IID == Intrinsic::sadd_sat || IID == Intrinsic::ssub_sat) {
2344+
case Intrinsic::sadd_sat:
2345+
case Intrinsic::ssub_sat: {
23432346
// Assume a default expansion.
23442347
Type *CondTy = RetTy->getWithNewBitWidth(1);
23452348

@@ -2361,8 +2364,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
23612364
CondTy, Pred, CostKind);
23622365
return Cost;
23632366
}
2364-
2365-
if (IID == Intrinsic::uadd_sat || IID == Intrinsic::usub_sat) {
2367+
case Intrinsic::uadd_sat:
2368+
case Intrinsic::usub_sat: {
23662369
Type *CondTy = RetTy->getWithNewBitWidth(1);
23672370

23682371
Type *OpTy = StructType::create({RetTy, CondTy});
@@ -2379,6 +2382,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
23792382
CmpInst::BAD_ICMP_PREDICATE, CostKind);
23802383
return Cost;
23812384
}
2385+
default:
2386+
break;
2387+
}
23822388

23832389
// Else, assume that we need to scalarize this intrinsic. For math builtins
23842390
// this will emit a costly libcall, adding call overhead and spills. Make it

0 commit comments

Comments
 (0)