aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUtils.cpp
diff options
context:
space:
mode:
authorSam Tebbs <samuel.tebbs@arm.com>2025-08-12 10:22:41 +0100
committerGitHub <noreply@github.com>2025-08-12 10:22:41 +0100
commit0bfa1718af7663f39d5089f29907b8446e919789 (patch)
treee07ab88dc0770f39b8712972948781e8e756dc99 /llvm/lib/Transforms/Utils/LoopUtils.cpp
parent111cdaac994ba79af6f51f0970b51c0e4d705cd9 (diff)
downloadllvm-0bfa1718af7663f39d5089f29907b8446e919789.zip
llvm-0bfa1718af7663f39d5089f29907b8446e919789.tar.gz
llvm-0bfa1718af7663f39d5089f29907b8446e919789.tar.bz2
[LV] Create in-loop sub reductions (#147026)
This PR allows the loop vectorizer to handle in-loop sub reductions by forming a normal in-loop add reduction with a negated input. Stacked PRs: 1. -> https://github.com/llvm/llvm-project/pull/147026 2. https://github.com/llvm/llvm-project/pull/147255 3. https://github.com/llvm/llvm-project/pull/147302 4. https://github.com/llvm/llvm-project/pull/147513
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUtils.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index e7623aa..2d830f3 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -914,6 +914,8 @@ constexpr Intrinsic::ID llvm::getReductionIntrinsicID(RecurKind RK) {
switch (RK) {
default:
llvm_unreachable("Unexpected recurrence kind");
+ case RecurKind::AddChainWithSubs:
+ case RecurKind::Sub:
case RecurKind::Add:
return Intrinsic::vector_reduce_add;
case RecurKind::Mul:
@@ -1301,6 +1303,8 @@ Value *llvm::createSimpleReduction(IRBuilderBase &Builder, Value *Src,
Builder.getFastMathFlags());
};
switch (RdxKind) {
+ case RecurKind::AddChainWithSubs:
+ case RecurKind::Sub:
case RecurKind::Add:
case RecurKind::Mul:
case RecurKind::And: