[llvm] [VPlan] Check FOR/FMinMaxNum epilogue restrictions in VPlan. (PR #191815)

via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 18 01:22:44 PDT 2026


================
@@ -4267,22 +4267,28 @@ static bool hasUnsupportedHeaderPhiRecipe(VPlan &Plan) {
   return any_of(
       Plan.getVectorLoopRegion()->getEntryBasicBlock()->phis(),
       [](VPRecipeBase &R) {
+        // Fixed-order recurrences need special handling and are currently
+        // unsupported.
+        if (isa<VPFirstOrderRecurrencePHIRecipe>(R))
+          return true;
         if (auto *WidenInd = dyn_cast<VPWidenIntOrFpInductionRecipe>(&R))
           return !WidenInd->getPHINode();
         auto *RedPhi = dyn_cast<VPReductionPHIRecipe>(&R);
         if (!RedPhi)
           return false;
-        if (RecurrenceDescriptor::isFindLastRecurrenceKind(
-                RedPhi->getRecurrenceKind()) ||
+        // FMinNum/FMaxNum, FindLast reductions, and reductions without
+        // underlying value need special handling and are currently unsupported.
+        RecurKind Kind = RedPhi->getRecurrenceKind();
+        if (RecurrenceDescriptor::isFPMinMaxNumRecurrenceKind(Kind) ||
+            RecurrenceDescriptor::isFindLastRecurrenceKind(Kind) ||
             !RedPhi->getUnderlyingValue())
           return true;
         // FindIV reductions with sunk expressions are not yet supported for
         // epilogue vectorization: the resume value from the main loop is in
         // expression domain (e.g., mul(ReducedIV, 3)), but the epilogue tracks
         // raw IV values. A sunk expression is identified by a non-VPInstruction
         // user of ComputeReductionResult.
-        if (RecurrenceDescriptor::isFindIVRecurrenceKind(
-                RedPhi->getRecurrenceKind())) {
+        if (RecurrenceDescriptor::isFindIVRecurrenceKind(Kind)) {
----------------
ayalz wrote:

nit: defining and using `Kind` here can be committed separately as NFC.

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


More information about the llvm-commits mailing list