[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
================
@@ -736,11 +757,18 @@ RecurrenceDescriptor::isFindLastIVPattern(Loop *TheLoop, PHINode *OrigPhi,
// We are looking for selects of the form:
// select(cmp(), phi, increasing_loop_induction) or
// select(cmp(), increasing_loop_induction, phi)
- // TODO: Support for monotonically decreasing induction variable
- if (!IsIncreasingLoopInduction(NonRdxPhi))
+ if (Kind == RecurKind::FindLastIV) {
+ if (IsSupportedLoopInduction(NonRdxPhi, Kind))
+ return InstDesc(I, Kind);
return InstDesc(false, I);
+ }
+
+ if (IsSupportedLoopInduction(NonRdxPhi, RecurKind::FindFirstIVSMin))
+ return InstDesc(I, RecurKind::FindFirstIVSMin);
+ if (IsSupportedLoopInduction(NonRdxPhi, RecurKind::FindFirstIVUMin))
+ return InstDesc(I, RecurKind::FindFirstIVUMin);
- return InstDesc(I, RecurKind::FindLastIV);
+ return InstDesc(false, I);
----------------
artagnon wrote:
Get IsSupportedLoopInduction to return a Kind, and compare with `Kind ==` to unify this code?
https://github.com/llvm/llvm-project/pull/140451
More information about the llvm-commits
mailing list