[llvm] [LV] Fix FindLastIV reduction for epilogue vectorization. (PR #120395)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 15:02:48 PST 2025


================
@@ -3405,15 +3406,13 @@ void VPReductionPHIRecipe::execute(VPTransformState &State) {
     }
   } else if (RecurrenceDescriptor::isFindLastIVRecurrenceKind(RK)) {
     // [I|F]FindLastIV will use a sentinel value to initialize the reduction
-    // phi or the resume value from the main vector loop when vectorizing the
-    // epilogue loop. In the exit block, ComputeReductionResult will generate
-    // checks to verify if the reduction result is the sentinel value. If the
-    // result is the sentinel value, it will be corrected back to the start
-    // value.
+    // phi. In the exit block, ComputeReductionResult will generate checks to
+    // verify if the reduction result is the sentinel value. If the result is
+    // the sentinel value, it will be corrected back to the start value.
     // TODO: The sentinel value is not always necessary. When the start value is
     // a constant, and smaller than the start value of the induction variable,
     // the start value can be directly used to initialize the reduction phi.
-    Iden = StartV;
+    StartV = Iden = RdxDesc.getSentinelValue();
----------------
fhahn wrote:

Yes this is along the lines of what I was thinking. It would be great if we could convey all necessary info via the start value of the recipe (in line with all other reduction types) instead of ignoring it 

https://github.com/llvm/llvm-project/pull/120395


More information about the llvm-commits mailing list