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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 27 05:07:11 PDT 2025


================
@@ -741,9 +741,17 @@ Value *VPInstruction::generate(VPTransformState &State) {
     // sentinel value, followed by one operand for each part of the reduction.
     unsigned UF = getNumOperands() - 3;
     Value *ReducedPartRdx = State.get(getOperand(3));
-    RecurKind MinMaxKind = RecurrenceDescriptor::isSignedRecurrenceKind(RK)
-                               ? RecurKind::SMax
-                               : RecurKind::UMax;
+    RecurKind MinMaxKind;
+    bool IsSigned = RecurrenceDescriptor::isSignedRecurrenceKind(RK);
+    if (RecurrenceDescriptor::isFindLastIVRecurrenceKind(RK)) {
+      MinMaxKind = IsSigned ? RecurKind::SMax : RecurKind::UMax;
+    } else {
+      assert(RecurrenceDescriptor::isFindFirstIVRecurrenceKind(RK) &&
+             "Kind must either be a FindLastIV or FindFirstIV");
+      assert(IsSigned &&
+             "only FindFirstIV with SMax is supported at the moment");
----------------
fhahn wrote:

Done thanks

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


More information about the llvm-commits mailing list