@@ -1192,78 +1192,65 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
1192
1192
ICA.getArgTypes ()[0 ], CmpInst::BAD_ICMP_PREDICATE,
1193
1193
CostKind);
1194
1194
case Intrinsic::vp_reduce_add:
1195
+ return getArithmeticReductionCost (Instruction::Add,
1196
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1197
+ std::nullopt, CostKind);
1195
1198
case Intrinsic::vp_reduce_fadd:
1199
+ return getArithmeticReductionCost (Instruction::FAdd,
1200
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1201
+ ICA.getFlags (), CostKind);
1196
1202
case Intrinsic::vp_reduce_mul:
1203
+ return getArithmeticReductionCost (Instruction::Mul,
1204
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1205
+ std::nullopt, CostKind);
1197
1206
case Intrinsic::vp_reduce_fmul:
1207
+ return getArithmeticReductionCost (Instruction::FMul,
1208
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1209
+ ICA.getFlags (), CostKind);
1198
1210
case Intrinsic::vp_reduce_and:
1211
+ return getArithmeticReductionCost (Instruction::And,
1212
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1213
+ std::nullopt, CostKind);
1199
1214
case Intrinsic::vp_reduce_or:
1200
- case Intrinsic::vp_reduce_xor: {
1201
- unsigned Opcode;
1202
- switch (ICA.getID ()) {
1203
- case Intrinsic::vp_reduce_add:
1204
- Opcode = Instruction::Add;
1205
- break ;
1206
- case Intrinsic::vp_reduce_fadd:
1207
- Opcode = Instruction::FAdd;
1208
- break ;
1209
- case Intrinsic::vp_reduce_mul:
1210
- Opcode = Instruction::Mul;
1211
- break ;
1212
- case Intrinsic::vp_reduce_fmul:
1213
- Opcode = Instruction::FMul;
1214
- break ;
1215
- case Intrinsic::vp_reduce_and:
1216
- Opcode = Instruction::And;
1217
- break ;
1218
- case Intrinsic::vp_reduce_or:
1219
- Opcode = Instruction::Or;
1220
- break ;
1221
- case Intrinsic::vp_reduce_xor:
1222
- Opcode = Instruction::Xor;
1223
- break ;
1224
- }
1225
- return getArithmeticReductionCost (Opcode,
1215
+ return getArithmeticReductionCost (Instruction::Or,
1226
1216
cast<VectorType>(ICA.getArgTypes ()[1 ]),
1227
- ICA.getFlags (), CostKind);
1228
- }
1217
+ std::nullopt, CostKind);
1218
+ case Intrinsic::vp_reduce_xor:
1219
+ return getArithmeticReductionCost (Instruction::Xor,
1220
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1221
+ std::nullopt, CostKind);
1229
1222
case Intrinsic::vp_reduce_smax:
1223
+ return getMinMaxReductionCost (Intrinsic::smax,
1224
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1225
+ ICA.getFlags (), CostKind);
1230
1226
case Intrinsic::vp_reduce_smin:
1227
+ return getMinMaxReductionCost (Intrinsic::smin,
1228
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1229
+ ICA.getFlags (), CostKind);
1231
1230
case Intrinsic::vp_reduce_umax:
1231
+ return getMinMaxReductionCost (Intrinsic::umax,
1232
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1233
+ ICA.getFlags (), CostKind);
1232
1234
case Intrinsic::vp_reduce_umin:
1235
+ return getMinMaxReductionCost (Intrinsic::umin,
1236
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1237
+ ICA.getFlags (), CostKind);
1233
1238
case Intrinsic::vp_reduce_fmax:
1239
+ return getMinMaxReductionCost (Intrinsic::maxnum,
1240
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1241
+ ICA.getFlags (), CostKind);
1234
1242
case Intrinsic::vp_reduce_fmaximum:
1243
+ return getMinMaxReductionCost (Intrinsic::maximum,
1244
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1245
+ ICA.getFlags (), CostKind);
1235
1246
case Intrinsic::vp_reduce_fmin:
1236
- case Intrinsic::vp_reduce_fminimum: {
1237
- unsigned IID;
1238
- switch (ICA.getID ()) {
1239
- case Intrinsic::vp_reduce_smax:
1240
- IID = Intrinsic::smax;
1241
- break ;
1242
- case Intrinsic::vp_reduce_smin:
1243
- IID = Intrinsic::smin;
1244
- break ;
1245
- case Intrinsic::vp_reduce_umax:
1246
- IID = Intrinsic::umax;
1247
- break ;
1248
- case Intrinsic::vp_reduce_umin:
1249
- IID = Intrinsic::umin;
1250
- break ;
1251
- case Intrinsic::vp_reduce_fmax:
1252
- IID = Intrinsic::maxnum;
1253
- break ;
1254
- case Intrinsic::vp_reduce_fmaximum:
1255
- IID = Intrinsic::maximum;
1256
- break ;
1257
- case Intrinsic::vp_reduce_fmin:
1258
- IID = Intrinsic::minnum;
1259
- break ;
1260
- case Intrinsic::vp_reduce_fminimum:
1261
- IID = Intrinsic::minimum;
1262
- break ;
1263
- }
1264
- return getMinMaxReductionCost (IID, cast<VectorType>(ICA.getArgTypes ()[1 ]),
1247
+ return getMinMaxReductionCost (Intrinsic::minnum,
1248
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1249
+ ICA.getFlags (), CostKind);
1250
+ case Intrinsic::vp_reduce_fminimum:
1251
+ return getMinMaxReductionCost (Intrinsic::minimum,
1252
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1265
1253
ICA.getFlags (), CostKind);
1266
- }
1267
1254
}
1268
1255
1269
1256
if (ST->hasVInstructions () && RetTy->isVectorTy ()) {
0 commit comments