[llvm] [LV] Support argmin/argmax with strict predicates. (PR #170223)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 26 15:51:39 PST 2026
================
@@ -1406,12 +1406,14 @@ bool VPlanTransforms::handleFindLastReductions(VPlan &Plan) {
}
/// For an argmin/argmax reduction with strict predicate \p MinOrMaxPhiR,
-/// convert the FindLastIV reduction \p FindLastIVPhiR of induction \p WideIV to
-/// a new UMin reduction of a wide canonical IV. If the original IV was not
-/// canonical, a new canonical wide IV is added, and the final result is scaled
-/// back to the original IV. \p MinOrMaxResult computes the final value of \p
-/// MinOrMaxPhiR and \p FindIVSelect, \p FindIVCmp, \p FindIVRdxResult compute
-/// the final value of \p FindLastIVPhiR.
+/// update the FindLastIV reduction \p FindLastIVPhiR of induction \p WideIV to
+/// to select the first index of the wide canonical IV outside the loop using
+/// UMin or \p FindLastIVPhiR's start value, if \p MinMaxResult equals \p
+/// MinOrMaxPhiR's start value. If \p WideIV was not canonical, a new canonical
+/// wide IV is added, and the final result is scaled back to the original IV. \p
+/// MinOrMaxResult computes the final value of \p MinOrMaxPhiR and \p
+/// FindIVSelect, \p FindIVCmp, \p FindIVRdxResult compute the final value of \p
+/// FindLastIVPhiR.
----------------
ayalz wrote:
Trying to further clarify:
```suggestion
/// Given a first argmin/argmax pattern with strict predicate consisting of
/// 1) a MinOrMax reduction \p MinOrMaxPhiR producing \p MinOrMaxResult,
/// 2) a wide induction \p WideIV,
/// 3) a FindLastIV reduction \p FindLastIVPhiR,
/// return the smallest index of the FindLastIV reduction result using UMin,
/// but if \p MinOnMaxResult equals the start value of its MinOrMax reduction
/// then return the start value of FindLastIV reduction instead.
/// If \p WideIV is not canonical, a new canonical wide IV is added, and the
/// final result is scaled back to non canonical \p WideIV.
/// The final value of FindLastIV reduction is originally computed using
/// \p FindIVSelect, \p FindIVCmp, and \p FindIVRdxResult which are replaced
/// and removed.
```
https://github.com/llvm/llvm-project/pull/170223
More information about the llvm-commits
mailing list