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

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Tue May 27 07:51:47 PDT 2025


================
@@ -990,6 +1018,12 @@ bool RecurrenceDescriptor::isReductionPHI(PHINode *Phi, Loop *TheLoop,
     LLVM_DEBUG(dbgs() << "Found a FindLastIV reduction PHI." << *Phi << "\n");
     return true;
   }
+  if (AddReductionVar(Phi, RecurKind::FindFirstIVUMin, TheLoop, FMF, RedDes, DB,
+                      AC, DT, SE)) {
+    LLVM_DEBUG(dbgs() << "Found a FindFirstV reduction PHI." << *Phi << "\n");
+    return true;
+  }
----------------
artagnon wrote:

I wonder if it's possible to avoid adding two RecurKinds, one for signed and another for unsigned? It's very displeasing to check just one of them?

Also, will the FindLast pattern not suffice?

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


More information about the llvm-commits mailing list