[llvm] [LV][NFC] Emit remarks when failing to vectorise early exit loops (PR #225078)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 06:58:27 PDT 2026


================
@@ -3227,20 +3251,39 @@ static bool handleUncountableExitsWithSideEffects(
     if (!isDereferenceableAndAlignedInLoop(
             PtrSCEV, cast<LoadInst>(Load->getUnderlyingInstr())->getAlign(),
             PSE.getSE()->getConstant(EltSize), TheLoop, *PSE.getSE(), DT, AC,
-            &Predicates))
+            &Predicates)) {
+      reportVectorizationFailure("Early exit loop with side effects contains "
+                                 "load used by the exit condition that may "
+                                 "fault.\n",
+                                 "EarlyExitSideEffectsFaultingLoad", ORE,
+                                 TheLoop);
       return false;
+    }
   }
 
   // Check for a single GEP for the condition load to see if we can link it to
   // a widen IV recipe with a step of 1; we're only interested in contiguous
   // accesses for the condition load right now.
   auto *IV = cast<VPWidenInductionRecipe>(&HeaderVPBB->front());
   if (!match(IV->getStartValue(), m_SpecificInt(0)) ||
-      !match(IV->getStepValue(), m_SpecificInt(1)))
+      !match(IV->getStepValue(), m_SpecificInt(1))) {
+    reportVectorizationFailure("Early exit loop with side effects contains "
+                               "non-contiguous load used by the exit "
+                               "condition.\n",
+                               "EarlyExitSideEffectsBadCriticalLoad", ORE,
+                               TheLoop);
----------------
fhahn wrote:

I think this is not necessarily accurate in case start != 0 the access could still be continuous, just not starting at 0.

With step = 1, we may still not be continuous (this is only guaranteed with the GEP with IV as operand below I think

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


More information about the llvm-commits mailing list