File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -6138,12 +6138,20 @@ LoopVectorizationCostModel::getReductionPatternCost(
6138
6138
const RecurrenceDescriptor &RdxDesc =
6139
6139
Legal->getReductionVars ().find (cast<PHINode>(ReductionPhi))->second ;
6140
6140
6141
- InstructionCost BaseCost = TTI.getArithmeticReductionCost (
6142
- RdxDesc.getOpcode (), VectorTy, RdxDesc.getFastMathFlags (), CostKind);
6141
+ InstructionCost BaseCost;
6142
+ RecurKind RK = RdxDesc.getRecurrenceKind ();
6143
+ if (RecurrenceDescriptor::isMinMaxRecurrenceKind (RK)) {
6144
+ Intrinsic::ID MinMaxID = getMinMaxReductionIntrinsicOp (RK);
6145
+ BaseCost = TTI.getMinMaxReductionCost (MinMaxID, VectorTy,
6146
+ RdxDesc.getFastMathFlags (), CostKind);
6147
+ } else {
6148
+ BaseCost = TTI.getArithmeticReductionCost (
6149
+ RdxDesc.getOpcode (), VectorTy, RdxDesc.getFastMathFlags (), CostKind);
6150
+ }
6143
6151
6144
6152
// For a call to the llvm.fmuladd intrinsic we need to add the cost of a
6145
6153
// normal fmul instruction to the cost of the fadd reduction.
6146
- if (RdxDesc. getRecurrenceKind () == RecurKind::FMulAdd)
6154
+ if (RK == RecurKind::FMulAdd)
6147
6155
BaseCost +=
6148
6156
TTI.getArithmeticInstrCost (Instruction::FMul, VectorTy, CostKind);
6149
6157
You can’t perform that action at this time.
0 commit comments