[llvm] [LV] Add support for cmp reductions with decreasing IVs. (PR #140451)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 28 14:42:19 PDT 2025


================
@@ -1227,9 +1227,12 @@ Value *llvm::createFindLastIVReduction(IRBuilderBase &Builder, Value *Src,
                                        RecurKind RdxKind, Value *Start,
                                        Value *Sentinel) {
   bool IsSigned = RecurrenceDescriptor::isSignedRecurrenceKind(RdxKind);
-  Value *MaxRdx = Src->getType()->isVectorTy()
-                      ? Builder.CreateIntMaxReduce(Src, IsSigned)
-                      : Src;
+  Value *MaxRdx =
+      Src->getType()->isVectorTy()
+          ? (RecurrenceDescriptor::isFindLastIVRecurrenceKind(RdxKind)
+                 ? Builder.CreateIntMaxReduce(Src, IsSigned)
+                 : Builder.CreateIntMinReduce(Src, IsSigned))
+          : Src;
----------------
fhahn wrote:

Done thanks

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


More information about the llvm-commits mailing list