[llvm] 0d7b34b - [LoopUtils] Pass start value directly to createAnyOfReduction (NFC).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed May 28 13:28:10 PDT 2025


Author: Florian Hahn
Date: 2025-05-28T21:28:02+01:00
New Revision: 0d7b34bfc10ba789541d736d68c24eb8d5666ce4

URL: https://github.com/llvm/llvm-project/commit/0d7b34bfc10ba789541d736d68c24eb8d5666ce4
DIFF: https://github.com/llvm/llvm-project/commit/0d7b34bfc10ba789541d736d68c24eb8d5666ce4.diff

LOG: [LoopUtils] Pass start value directly to createAnyOfReduction (NFC).

Now that there is only a single AnyOf recurrence kind, simply pass the
start value instead of the full recurrence descriptor, to tighten the
interface.

Added: 
    

Modified: 
    llvm/include/llvm/Transforms/Utils/LoopUtils.h
    llvm/lib/Transforms/Utils/LoopUtils.cpp
    llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/Utils/LoopUtils.h b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
index 416a0a70325d1..f52f8922ea8cc 100644
--- a/llvm/include/llvm/Transforms/Utils/LoopUtils.h
+++ b/llvm/include/llvm/Transforms/Utils/LoopUtils.h
@@ -413,11 +413,9 @@ Value *createSimpleReduction(IRBuilderBase &B, Value *Src,
 /// reduction.
 Value *createSimpleReduction(VectorBuilder &VB, Value *Src, RecurKind RdxKind);
 
-/// Create a reduction of the given vector \p Src for a reduction of the
-/// kind RecurKind::IAnyOf or RecurKind::FAnyOf. The reduction operation is
-/// described by \p Desc.
-Value *createAnyOfReduction(IRBuilderBase &B, Value *Src,
-                            const RecurrenceDescriptor &Desc,
+/// Create a reduction of the given vector \p Src for a reduction of kind
+/// RecurKind::AnyOf. The start value of the reduction is \p InitVal.
+Value *createAnyOfReduction(IRBuilderBase &B, Value *Src, Value *InitVal,
                             PHINode *OrigPhi);
 
 /// Create a reduction of the given vector \p Src for a reduction of the

diff  --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index 2fff9521017ff..67efafe2ef2d9 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -1207,12 +1207,7 @@ Value *llvm::getShuffleReduction(IRBuilderBase &Builder, Value *Src,
 }
 
 Value *llvm::createAnyOfReduction(IRBuilderBase &Builder, Value *Src,
-                                  const RecurrenceDescriptor &Desc,
-                                  PHINode *OrigPhi) {
-  assert(
-      RecurrenceDescriptor::isAnyOfRecurrenceKind(Desc.getRecurrenceKind()) &&
-      "Unexpected reduction kind");
-  Value *InitVal = Desc.getRecurrenceStartValue();
+                                  Value *InitVal, PHINode *OrigPhi) {
   Value *NewVal = nullptr;
 
   // First use the original phi to determine the new value we're trying to

diff  --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 5fbf79085cb74..ad84b412af31d 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -688,7 +688,8 @@ Value *VPInstruction::generate(VPTransformState &State) {
       // descriptor.
       if (RecurrenceDescriptor::isAnyOfRecurrenceKind(RK))
         ReducedPartRdx =
-            createAnyOfReduction(Builder, ReducedPartRdx, RdxDesc, OrigPhi);
+            createAnyOfReduction(Builder, ReducedPartRdx,
+                                 RdxDesc.getRecurrenceStartValue(), OrigPhi);
       else
         ReducedPartRdx = createSimpleReduction(Builder, ReducedPartRdx, RK);
 


        


More information about the llvm-commits mailing list