diff options
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 99428c6c5de..ad12646bdee 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -6499,10 +6499,19 @@ private: int ScalarReduxCost = 0; switch (ReductionData.getKind()) { - case RK_Arithmetic: - ScalarReduxCost = - TTI->getArithmeticInstrCost(ReductionData.getOpcode(), ScalarTy); + case RK_Arithmetic: { + // Note: Passing in the reduction operands allows the cost model to match + // load combining patterns for this reduction. + auto *ReduxInst = cast<Instruction>(ReductionRoot); + SmallVector<const Value *, 2> OperandList; + for (Value *Operand : ReduxInst->operands()) + OperandList.push_back(Operand); + ScalarReduxCost = TTI->getArithmeticInstrCost(ReductionData.getOpcode(), + ScalarTy, TargetTransformInfo::OK_AnyValue, + TargetTransformInfo::OK_AnyValue, TargetTransformInfo::OP_None, + TargetTransformInfo::OP_None, OperandList); break; + } case RK_Min: case RK_Max: case RK_UMin: |