@@ -1192,78 +1192,65 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
11921192 ICA.getArgTypes ()[0 ], CmpInst::BAD_ICMP_PREDICATE,
11931193 CostKind);
11941194 case Intrinsic::vp_reduce_add:
1195+ return getArithmeticReductionCost (Instruction::Add,
1196+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1197+ std::nullopt , CostKind);
11951198 case Intrinsic::vp_reduce_fadd:
1199+ return getArithmeticReductionCost (Instruction::FAdd,
1200+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1201+ ICA.getFlags (), CostKind);
11961202 case Intrinsic::vp_reduce_mul:
1203+ return getArithmeticReductionCost (Instruction::Mul,
1204+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1205+ std::nullopt , CostKind);
11971206 case Intrinsic::vp_reduce_fmul:
1207+ return getArithmeticReductionCost (Instruction::FMul,
1208+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1209+ ICA.getFlags (), CostKind);
11981210 case Intrinsic::vp_reduce_and:
1211+ return getArithmeticReductionCost (Instruction::And,
1212+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1213+ std::nullopt , CostKind);
11991214 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,
12261216 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);
12291222 case Intrinsic::vp_reduce_smax:
1223+ return getMinMaxReductionCost (Intrinsic::smax,
1224+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1225+ ICA.getFlags (), CostKind);
12301226 case Intrinsic::vp_reduce_smin:
1227+ return getMinMaxReductionCost (Intrinsic::smin,
1228+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1229+ ICA.getFlags (), CostKind);
12311230 case Intrinsic::vp_reduce_umax:
1231+ return getMinMaxReductionCost (Intrinsic::umax,
1232+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1233+ ICA.getFlags (), CostKind);
12321234 case Intrinsic::vp_reduce_umin:
1235+ return getMinMaxReductionCost (Intrinsic::umin,
1236+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1237+ ICA.getFlags (), CostKind);
12331238 case Intrinsic::vp_reduce_fmax:
1239+ return getMinMaxReductionCost (Intrinsic::maxnum,
1240+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1241+ ICA.getFlags (), CostKind);
12341242 case Intrinsic::vp_reduce_fmaximum:
1243+ return getMinMaxReductionCost (Intrinsic::maximum,
1244+ cast<VectorType>(ICA.getArgTypes ()[1 ]),
1245+ ICA.getFlags (), CostKind);
12351246 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 ]),
12651253 ICA.getFlags (), CostKind);
1266- }
12671254 }
12681255
12691256 if (ST->hasVInstructions () && RetTy->isVectorTy ()) {
0 commit comments