@@ -1192,66 +1192,40 @@ 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);
1198
1195
case Intrinsic::vp_reduce_fadd:
1199
- return getArithmeticReductionCost (Instruction::FAdd,
1200
- cast<VectorType>(ICA.getArgTypes ()[1 ]),
1201
- ICA.getFlags (), CostKind);
1202
1196
case Intrinsic::vp_reduce_mul:
1203
- return getArithmeticReductionCost (Instruction::Mul,
1204
- cast<VectorType>(ICA.getArgTypes ()[1 ]),
1205
- std::nullopt, CostKind);
1206
1197
case Intrinsic::vp_reduce_fmul:
1207
- return getArithmeticReductionCost (Instruction::FMul,
1208
- cast<VectorType>(ICA.getArgTypes ()[1 ]),
1209
- ICA.getFlags (), CostKind);
1210
1198
case Intrinsic::vp_reduce_and:
1211
- return getArithmeticReductionCost (Instruction::And,
1212
- cast<VectorType>(ICA.getArgTypes ()[1 ]),
1213
- std::nullopt, CostKind);
1214
1199
case Intrinsic::vp_reduce_or:
1215
- return getArithmeticReductionCost (Instruction::Or,
1216
- cast<VectorType>(ICA.getArgTypes ()[1 ]),
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);
1200
+ case Intrinsic::vp_reduce_xor: {
1201
+ std::optional<Intrinsic::ID> RedID =
1202
+ VPIntrinsic::getFunctionalIntrinsicIDForVP (ICA.getID ());
1203
+ assert (RedID.has_value ());
1204
+ unsigned RedOp = getArithmeticReductionInstruction (*RedID);
1205
+ if (RedOp == Instruction::FAdd || RedOp == Instruction::FMul)
1206
+ return getArithmeticReductionCost (RedOp,
1207
+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1208
+ ICA.getFlags (), CostKind);
1209
+ return getArithmeticReductionCost (
1210
+ RedOp, cast<VectorType>(ICA.getArgTypes ()[1 ]), std::nullopt, CostKind);
1211
+ }
1222
1212
case Intrinsic::vp_reduce_smax:
1223
- return getMinMaxReductionCost (Intrinsic::smax,
1224
- cast<VectorType>(ICA.getArgTypes ()[1 ]),
1225
- ICA.getFlags (), CostKind);
1226
1213
case Intrinsic::vp_reduce_smin:
1227
- return getMinMaxReductionCost (Intrinsic::smin,
1228
- cast<VectorType>(ICA.getArgTypes ()[1 ]),
1229
- ICA.getFlags (), CostKind);
1230
1214
case Intrinsic::vp_reduce_umax:
1231
- return getMinMaxReductionCost (Intrinsic::umax,
1232
- cast<VectorType>(ICA.getArgTypes ()[1 ]),
1233
- ICA.getFlags (), CostKind);
1234
1215
case Intrinsic::vp_reduce_umin:
1235
- return getMinMaxReductionCost (Intrinsic::umin,
1236
- cast<VectorType>(ICA.getArgTypes ()[1 ]),
1237
- ICA.getFlags (), CostKind);
1238
1216
case Intrinsic::vp_reduce_fmax:
1239
- return getMinMaxReductionCost (Intrinsic::maxnum,
1240
- cast<VectorType>(ICA.getArgTypes ()[1 ]),
1241
- ICA.getFlags (), CostKind);
1242
1217
case Intrinsic::vp_reduce_fmaximum:
1243
- return getMinMaxReductionCost (Intrinsic::maximum,
1244
- cast<VectorType>(ICA.getArgTypes ()[1 ]),
1245
- ICA.getFlags (), CostKind);
1246
1218
case Intrinsic::vp_reduce_fmin:
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,
1219
+ case Intrinsic::vp_reduce_fminimum: {
1220
+ std::optional<Intrinsic::ID> RedID =
1221
+ VPIntrinsic::getFunctionalIntrinsicIDForVP (ICA.getID ());
1222
+ assert (RedID.has_value ());
1223
+ Intrinsic::ID MinMaxID = getMinMaxReductionIntrinsicOp (*RedID);
1224
+ return getMinMaxReductionCost (MinMaxID,
1252
1225
cast<VectorType>(ICA.getArgTypes ()[1 ]),
1253
1226
ICA.getFlags (), CostKind);
1254
1227
}
1228
+ }
1255
1229
1256
1230
if (ST->hasVInstructions () && RetTy->isVectorTy ()) {
1257
1231
if (auto LT = getTypeLegalizationCost (RetTy);
0 commit comments