[llvm] SLP] Support ordered fadd reduction via reduction intrinsics (PR #189451)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 11:50:57 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 5f9025872..862f9226a 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -27791,9 +27791,9 @@ public:
unsigned MaxVecRegSize = V.getMaxVecRegSize();
unsigned EltSize = V.getVectorElementSize(Candidates[0]);
- const unsigned MaxElts = std::clamp<unsigned>(
- llvm::bit_floor(MaxVecRegSize / EltSize), RedValsMaxNumber,
- RegMaxNumber * RedValsMaxNumber);
+ const unsigned MaxElts =
+ std::clamp<unsigned>(llvm::bit_floor(MaxVecRegSize / EltSize),
+ RedValsMaxNumber, RegMaxNumber * RedValsMaxNumber);
unsigned ReduxWidth = 0;
auto GetVectorFactor = [&, &TTI = *TTI](unsigned ReduxWidth) {
@@ -27860,13 +27860,12 @@ public:
V.transformNodes();
V.computeMinimumValueSizes();
- InstructionCost TreeCost =
- V.calculateTreeCostAndTrimNonProfitable(VL);
+ InstructionCost TreeCost = V.calculateTreeCostAndTrimNonProfitable(VL);
V.buildExternalUses(LocalExternallyUsedValues);
- InstructionCost ReductionCost = getReductionCost(
- TTI, VL, EmptySameValuesCounter, /*IsCmpSelMinMax=*/false, RdxFMF, V,
- DT, DL, TLI);
+ InstructionCost ReductionCost =
+ getReductionCost(TTI, VL, EmptySameValuesCounter,
+ /*IsCmpSelMinMax=*/false, RdxFMF, V, DT, DL, TLI);
InstructionCost Cost =
V.getTreeCost(TreeCost, VL, ReductionCost, RdxRootInst);
LLVM_DEBUG(dbgs() << "SLP: Found cost = " << Cost
@@ -27875,9 +27874,8 @@ public:
(Cost == -SLPCostThreshold && V.getTreeSize() > 1)) {
if (Cost.isValid())
V.getORE()->emit([&]() {
- return OptimizationRemarkMissed(
- SV_NAME, "HorSLPNotBeneficial",
- ReducedValsToOps.at(VL[0]).front())
+ return OptimizationRemarkMissed(SV_NAME, "HorSLPNotBeneficial",
+ ReducedValsToOps.at(VL[0]).front())
<< "Vectorizing ordered reduction is possible "
<< "but not beneficial with cost " << ore::NV("Cost", Cost)
<< " and threshold "
@@ -27887,8 +27885,8 @@ public:
return false;
}
- LLVM_DEBUG(dbgs() << "SLP: Vectorizing ordered reduction at cost:"
- << Cost << ". (HorRdx)\n");
+ LLVM_DEBUG(dbgs() << "SLP: Vectorizing ordered reduction at cost:" << Cost
+ << ". (HorRdx)\n");
V.getORE()->emit([&]() {
return OptimizationRemark(SV_NAME, "VectorizedHorizontalReduction",
ReducedValsToOps.at(VL[0]).front())
@@ -27898,8 +27896,7 @@ public:
});
Builder.setFastMathFlags(RdxFMF);
- SuccessRoot =
- V.vectorizeTree(LocalExternallyUsedValues, RdxRootInst);
+ SuccessRoot = V.vectorizeTree(LocalExternallyUsedValues, RdxRootInst);
assert(SuccessRoot && "Expected vectorized tree");
SuccessStart = Start;
SuccessWidth = Width;
@@ -28883,12 +28880,10 @@ bool SLPVectorizerPass::vectorizeHorReduction(
}
if (HorizontalReduction::isSupportedOrderedReductionOp(Inst)) {
if (HorRdx.matchOrderedReduction(R, Inst, /*MatchLHS=*/true))
- if (Value *Red =
- HorRdx.tryToReduceOrdered(R, *DL, TTI, *TLI, AC, *DT))
+ if (Value *Red = HorRdx.tryToReduceOrdered(R, *DL, TTI, *TLI, AC, *DT))
return Red;
if (HorRdx.matchOrderedReduction(R, Inst, /*MatchLHS=*/false))
- if (Value *Red =
- HorRdx.tryToReduceOrdered(R, *DL, TTI, *TLI, AC, *DT))
+ if (Value *Red = HorRdx.tryToReduceOrdered(R, *DL, TTI, *TLI, AC, *DT))
return Red;
}
return Res;
``````````
</details>
https://github.com/llvm/llvm-project/pull/189451
More information about the llvm-commits
mailing list