[llvm] [LV] Support argmin/argmax with strict predicates. (PR #170223)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 3 13:05:38 PST 2025


================
@@ -310,6 +311,11 @@ class RecurrenceDescriptor {
            isFindLastIVRecurrenceKind(Kind);
   }
 
+  /// Returns true if \p AR's range is valid for either FindFirstIV or
+  /// FindLastIV reductions i.e. if the sentinel value is outside \p AR's range.
----------------
fhahn wrote:

I am not sure if currently the condition must hold at least once unless I am missing something, because there are no restrictions on the start values e.g. the minimum reduction does not have to start at the max value, so the IV may never get selected in the loop, and the minimuxm index reduction may start at a value that's different to the IV start value.

But IV start == min.idx start and condition known to be true at least  once are good to optimize separately. Note that for the initial FindLastIV, the range is checked during the IVDescriptor analysis.

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


More information about the llvm-commits mailing list