Skip to content

Commit be9c4f5

Browse files
committed
Fixup! early return
1 parent 0430505 commit be9c4f5

File tree

1 file changed

+45
-58
lines changed

1 file changed

+45
-58
lines changed

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 45 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,78 +1180,65 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
11801180
ICA.getArgTypes()[0], CmpInst::BAD_ICMP_PREDICATE,
11811181
CostKind);
11821182
case Intrinsic::vp_reduce_add:
1183+
return getArithmeticReductionCost(Instruction::Add,
1184+
cast<VectorType>(ICA.getArgTypes()[1]),
1185+
std::nullopt, CostKind);
11831186
case Intrinsic::vp_reduce_fadd:
1187+
return getArithmeticReductionCost(Instruction::FAdd,
1188+
cast<VectorType>(ICA.getArgTypes()[1]),
1189+
ICA.getFlags(), CostKind);
11841190
case Intrinsic::vp_reduce_mul:
1191+
return getArithmeticReductionCost(Instruction::Mul,
1192+
cast<VectorType>(ICA.getArgTypes()[1]),
1193+
std::nullopt, CostKind);
11851194
case Intrinsic::vp_reduce_fmul:
1195+
return getArithmeticReductionCost(Instruction::FMul,
1196+
cast<VectorType>(ICA.getArgTypes()[1]),
1197+
ICA.getFlags(), CostKind);
11861198
case Intrinsic::vp_reduce_and:
1199+
return getArithmeticReductionCost(Instruction::And,
1200+
cast<VectorType>(ICA.getArgTypes()[1]),
1201+
std::nullopt, CostKind);
11871202
case Intrinsic::vp_reduce_or:
1188-
case Intrinsic::vp_reduce_xor: {
1189-
unsigned Opcode;
1190-
switch (ICA.getID()) {
1191-
case Intrinsic::vp_reduce_add:
1192-
Opcode = Instruction::Add;
1193-
break;
1194-
case Intrinsic::vp_reduce_fadd:
1195-
Opcode = Instruction::FAdd;
1196-
break;
1197-
case Intrinsic::vp_reduce_mul:
1198-
Opcode = Instruction::Mul;
1199-
break;
1200-
case Intrinsic::vp_reduce_fmul:
1201-
Opcode = Instruction::FMul;
1202-
break;
1203-
case Intrinsic::vp_reduce_and:
1204-
Opcode = Instruction::And;
1205-
break;
1206-
case Intrinsic::vp_reduce_or:
1207-
Opcode = Instruction::Or;
1208-
break;
1209-
case Intrinsic::vp_reduce_xor:
1210-
Opcode = Instruction::Xor;
1211-
break;
1212-
}
1213-
return getArithmeticReductionCost(Opcode,
1203+
return getArithmeticReductionCost(Instruction::Or,
12141204
cast<VectorType>(ICA.getArgTypes()[1]),
1215-
ICA.getFlags(), CostKind);
1216-
}
1205+
std::nullopt, CostKind);
1206+
case Intrinsic::vp_reduce_xor:
1207+
return getArithmeticReductionCost(Instruction::Xor,
1208+
cast<VectorType>(ICA.getArgTypes()[1]),
1209+
std::nullopt, CostKind);
12171210
case Intrinsic::vp_reduce_smax:
1211+
return getMinMaxReductionCost(Intrinsic::smax,
1212+
cast<VectorType>(ICA.getArgTypes()[1]),
1213+
ICA.getFlags(), CostKind);
12181214
case Intrinsic::vp_reduce_smin:
1215+
return getMinMaxReductionCost(Intrinsic::smin,
1216+
cast<VectorType>(ICA.getArgTypes()[1]),
1217+
ICA.getFlags(), CostKind);
12191218
case Intrinsic::vp_reduce_umax:
1219+
return getMinMaxReductionCost(Intrinsic::umax,
1220+
cast<VectorType>(ICA.getArgTypes()[1]),
1221+
ICA.getFlags(), CostKind);
12201222
case Intrinsic::vp_reduce_umin:
1223+
return getMinMaxReductionCost(Intrinsic::umin,
1224+
cast<VectorType>(ICA.getArgTypes()[1]),
1225+
ICA.getFlags(), CostKind);
12211226
case Intrinsic::vp_reduce_fmax:
1227+
return getMinMaxReductionCost(Intrinsic::maxnum,
1228+
cast<VectorType>(ICA.getArgTypes()[1]),
1229+
ICA.getFlags(), CostKind);
12221230
case Intrinsic::vp_reduce_fmaximum:
1231+
return getMinMaxReductionCost(Intrinsic::maximum,
1232+
cast<VectorType>(ICA.getArgTypes()[1]),
1233+
ICA.getFlags(), CostKind);
12231234
case Intrinsic::vp_reduce_fmin:
1224-
case Intrinsic::vp_reduce_fminimum: {
1225-
unsigned IID;
1226-
switch (ICA.getID()) {
1227-
case Intrinsic::vp_reduce_smax:
1228-
IID = Intrinsic::smax;
1229-
break;
1230-
case Intrinsic::vp_reduce_smin:
1231-
IID = Intrinsic::smin;
1232-
break;
1233-
case Intrinsic::vp_reduce_umax:
1234-
IID = Intrinsic::umax;
1235-
break;
1236-
case Intrinsic::vp_reduce_umin:
1237-
IID = Intrinsic::umin;
1238-
break;
1239-
case Intrinsic::vp_reduce_fmax:
1240-
IID = Intrinsic::maxnum;
1241-
break;
1242-
case Intrinsic::vp_reduce_fmaximum:
1243-
IID = Intrinsic::maximum;
1244-
break;
1245-
case Intrinsic::vp_reduce_fmin:
1246-
IID = Intrinsic::minnum;
1247-
break;
1248-
case Intrinsic::vp_reduce_fminimum:
1249-
IID = Intrinsic::minimum;
1250-
break;
1251-
}
1252-
return getMinMaxReductionCost(IID, cast<VectorType>(ICA.getArgTypes()[1]),
1235+
return getMinMaxReductionCost(Intrinsic::minnum,
1236+
cast<VectorType>(ICA.getArgTypes()[1]),
1237+
ICA.getFlags(), CostKind);
1238+
case Intrinsic::vp_reduce_fminimum:
1239+
return getMinMaxReductionCost(Intrinsic::minimum,
1240+
cast<VectorType>(ICA.getArgTypes()[1]),
12531241
ICA.getFlags(), CostKind);
1254-
}
12551242
}
12561243

12571244
if (ST->hasVInstructions() && RetTy->isVectorTy()) {

0 commit comments

Comments
 (0)