[llvm] [LV] Handle partial sub-reductions with sub in middle block. (PR #178919)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 30 09:06:44 PST 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 h,cpp -- llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp llvm/lib/Transforms/Vectorize/LoopVectorize.cpp llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h --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/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index 7538930e3..fff059a93 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -5910,8 +5910,8 @@ InstructionCost AArch64TTIImpl::getPartialReductionCost(
InstructionCost Cost = InputLT.first * TTI::TCC_Basic;
- // The sub/negation cannot be folded into the operands of ISD::PARTIAL_REDUCE_*MLA,
- // so make the cost more expensive.
+ // The sub/negation cannot be folded into the operands of
+ // ISD::PARTIAL_REDUCE_*MLA, so make the cost more expensive.
if (Opcode == Instruction::Sub)
Cost += 8;
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index aea0a9811..d997e6ea1 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8321,7 +8321,8 @@ VPRecipeBuilder::tryToCreatePartialReduction(VPInstruction *Reduction,
bool IsSubPerformedInMiddleBlock =
ScaleFactor > 1 && getRecurKindForReduction(ReductionI) == RecurKind::Sub;
- if (Reduction->getOpcode() == Instruction::Sub && !IsSubPerformedInMiddleBlock) {
+ if (Reduction->getOpcode() == Instruction::Sub &&
+ !IsSubPerformedInMiddleBlock) {
SmallVector<VPValue *, 2> Ops;
Ops.push_back(Plan.getConstantInt(ReductionI->getType(), 0));
Ops.push_back(BinOp);
diff --git a/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h b/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h
index 885d94a8b..7ab75fc8a 100644
--- a/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h
+++ b/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h
@@ -81,7 +81,8 @@ class VPRecipeBuilder {
SmallVector<VPHeaderPHIRecipe *, 4> PhisToFix;
/// A mapping of partial reduction exit instructions to their scaling factor.
- DenseMap<const Instruction *, std::pair<unsigned, RecurKind>> ScaledReductionMap;
+ DenseMap<const Instruction *, std::pair<unsigned, RecurKind>>
+ ScaledReductionMap;
/// Check if \p I can be widened at the start of \p Range and possibly
/// decrease the range such that the returned value holds for the entire \p
``````````
</details>
https://github.com/llvm/llvm-project/pull/178919
More information about the llvm-commits
mailing list