[llvm] [NFC][LV] Introduce enums for uncountable exit detail and style (PR #184808)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 11 03:26:16 PDT 2026


================
@@ -8179,7 +8194,22 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(
             return !CM.requiresScalarEpilogue(VF.isVector());
           },
           Range);
-  VPlanTransforms::handleEarlyExits(*Plan, Legal->hasUncountableEarlyExit());
+
+  UncountableEarlyExitDetail EEDetail = Legal->getUncountableEarlyExitDetail();
+#ifndef NDEBUG
+  // If we're vectorizing a loop with an uncountable exit, make sure that the
+  // recipes are safe to handle.
+  if (EEDetail == UncountableEarlyExitDetail::ReadOnly) {
+    ReversePostOrderTraversal<VPBlockShallowTraversalWrapper<VPBlockBase *>>
+        RPOT(Plan->getEntry());
+    for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(RPOT))
+      for (VPRecipeBase &R : make_early_inc_range(*VPBB))
+        if (auto *SDR = dyn_cast<VPSingleDefRecipe>(&R))
+          assert(!match(SDR, m_VPInstruction<Instruction::Store>()) &&
+                 "Store recipe found in ReadOnly uncountable exit loop");
----------------
fhahn wrote:

can we instead check `mayWriteToMemory()` for any recipe?

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


More information about the llvm-commits mailing list