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

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 21 06:01:43 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: David Sherwood (david-arm)

<details>
<summary>Changes</summary>

I spotted recently that when attempting to compile a function with an early exit loop we don't emit any remarks when we fail to vectorise due to possible faulting loads. This PR fixes that and other missing remarks, plus I've also added missing tests for some cases where we fail to vectorise early exit loops.

For the remarks, I've used debug information to uniquely identify the remark and associate it with a particular function.

Tests were assisted by Codex (GPT 5.5)

---

Patch is 99.59 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/225078.diff


6 Files Affected:

- (modified) llvm/lib/Transforms/Vectorize/LoopVectorize.cpp (+3-2) 
- (modified) llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp (-3) 
- (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp (+46-13) 
- (modified) llvm/lib/Transforms/Vectorize/VPlanTransforms.h (+4-3) 
- (modified) llvm/test/Transforms/LoopVectorize/early_exit_legality.ll (+181-118) 
- (modified) llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll (+366-182) 


``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 5c4e20ee66b65..a6bdb6a15ea8e 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6439,9 +6439,10 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlan1() {
             ? UncountableExitStyle::MaskedHandleExitInScalarLoop
             : UncountableExitStyle::ReadOnly;
     if (!RUN_VPLAN_PASS(VPlanTransforms::handleUncountableEarlyExits, *VPlan0,
-                        OrigLoop, PSE, *DT, Legal->getAssumptionCache(),
-                        EEStyle))
+                        ORE, OrigLoop, PSE, *DT, Legal->getAssumptionCache(),
+                        EEStyle)) {
       return nullptr;
+    }
   } else {
     RUN_VPLAN_PASS(VPlanTransforms::handleCountableEarlyExits, *VPlan0);
   }
diff --git a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
index 4cd455adb7a90..dac58befe7e52 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
@@ -1251,9 +1251,6 @@ bool VPlanTransforms::areAllLoadsDereferenceable(VPBasicBlock *HeaderVPBB,
                                             TheLoop, SE, DT, AC, &Preds))
         continue;
 
-      LLVM_DEBUG(
-          dbgs() << "LV: Not vectorizing: Auto-vectorization of loops with "
-                    "potentially faulting load is not supported.\n");
       return false;
     }
   }
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index d78a3d3b1e344..a8a92de5e64cd 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -41,6 +41,7 @@
 #include "llvm/Transforms/Utils/LoopUtils.h"
 
 using namespace llvm;
+using namespace LoopVectorizationUtils;
 using namespace VPlanPatternMatch;
 using namespace SCEVPatternMatch;
 
@@ -3187,8 +3188,8 @@ struct EarlyExitInfo {
 static bool handleUncountableExitsWithSideEffects(
     VPlan &Plan, SmallVectorImpl<EarlyExitInfo> &Exits,
     VPBasicBlock *HeaderVPBB, VPBasicBlock *LatchVPBB, VPBasicBlock *MiddleVPBB,
-    Loop *TheLoop, PredicatedScalarEvolution &PSE, DominatorTree &DT,
-    AssumptionCache *AC) {
+    OptimizationRemarkEmitter *ORE, Loop *TheLoop,
+    PredicatedScalarEvolution &PSE, DominatorTree &DT, AssumptionCache *AC) {
 
   // Disconnect early exiting blocks from successors, remove branches. We
   // currently don't support multiple uses for recipes involved in creating
@@ -3211,8 +3212,13 @@ static bool handleUncountableExitsWithSideEffects(
   SmallVector<VPInstruction *, 8> ConditionRecipes;
 
   VPValue *Cond = getRecipesForUncountableExit(ConditionRecipes, LatchVPBB);
-  if (!Cond)
+  if (!Cond) {
+    reportVectorizationFailure(
+        "Unable to determine early exit condition for loop with side effects.\n",
+        "EarlyExitSideEffectsCond",
+        ORE, TheLoop);
     return false;
+  }
 
   // Find load contributing to condition.
   // At the moment LoopVectorizationLegality only supports a single
@@ -3246,8 +3252,13 @@ 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 "
+                                 "critical load 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
@@ -3257,9 +3268,14 @@ static bool handleUncountableExitsWithSideEffects(
   if (!match(IV->getStartValue(), m_SpecificInt(0)) ||
       !match(IV->getStepValue(), m_SpecificInt(1)))
     return false;
-  if (!match(Ptr, m_VPInstruction<Instruction::GetElementPtr>(m_LiveIn(),
-                                                              m_Specific(IV))))
+  if (!match(Ptr, m_VPInstruction<Instruction::GetElementPtr>(
+                      m_LiveIn(), m_Specific(IV)))) {
+    reportVectorizationFailure(
+        "Early exit loop with side effects contains unsupported critical load.\n",
+        "EarlyExitSideEffectsBadCriticalLoad",
+        ORE, TheLoop);
     return false;
+  }
 
   // We want to guarantee that the uncountable exit condition (and the mask
   // we will generate from it) are available for all operations in the loop
@@ -3291,8 +3307,13 @@ static bool handleUncountableExitsWithSideEffects(
     for (VPRecipeBase &R : *VPBB)
       if (R.mayReadOrWriteMemory() && &R != Load) {
         // TODO: Handle conditional memory operations in the loop.
-        if (!VPDT.dominates(R.getParent(), LatchVPBB))
+        if (!VPDT.dominates(R.getParent(), LatchVPBB)) {
+          reportVectorizationFailure("Early exit loop with side effects "
+                                     "contains unsupported memory operations.\n",
+                                     "EarlyExitSideEffectsUnsupportedMemOps",
+                                     ORE, TheLoop);
           return false;
+        }
         cast<VPInstruction>(&R)->addMask(Mask);
       }
 
@@ -3315,8 +3336,13 @@ static bool handleUncountableExitsWithSideEffects(
   auto Phis = ScalarPH->phis();
   // TODO: Handle more than one Phi; re-derive from IV.
   // TODO: Handle reductions.
-  if (range_size(Phis) != 1)
+  if (range_size(Phis) != 1) {
+    reportVectorizationFailure("Early exit loop with side effects contains "
+                               "unsupported reductions or recurrences.\n",
+                               "EarlyExitEffectsSideReductions",
+                               ORE, TheLoop);
     return false;
+  }
   VPPhi *ContinueIV = cast<VPPhi>(Phis.begin());
   // Make sure we're referring to the same IV.
   assert(
@@ -3328,8 +3354,9 @@ static bool handleUncountableExitsWithSideEffects(
 }
 
 bool VPlanTransforms::handleUncountableEarlyExits(
-    VPlan &Plan, Loop *TheLoop, PredicatedScalarEvolution &PSE,
-    DominatorTree &DT, AssumptionCache *AC, UncountableExitStyle Style) {
+    VPlan &Plan, OptimizationRemarkEmitter *ORE, Loop *TheLoop,
+    PredicatedScalarEvolution &PSE, DominatorTree &DT, AssumptionCache *AC,
+    UncountableExitStyle Style) {
 #ifndef NDEBUG
   VPDominatorTree VPDT(Plan);
 #endif
@@ -3341,8 +3368,13 @@ bool VPlanTransforms::handleUncountableEarlyExits(
   // stores, as only the loads contributing to the exit condition need to
   // be checked.
   if (Style == UncountableExitStyle::ReadOnly &&
-      !areAllLoadsDereferenceable(HeaderVPBB, TheLoop, PSE, DT, AC))
+      !areAllLoadsDereferenceable(HeaderVPBB, TheLoop, PSE, DT, AC)) {
+    reportVectorizationFailure(
+        "Auto-vectorization of early exit loops with potentially "
+        "faulting loads is not supported.\n.",
+        "EarlyExitFaultingLoads", ORE, TheLoop);
     return false;
+  }
 
   VPBuilder LatchBuilder(LatchVPBB->getTerminator());
   SmallVector<EarlyExitInfo> Exits;
@@ -3431,8 +3463,9 @@ bool VPlanTransforms::handleUncountableEarlyExits(
     LatchVPBB->setSuccessors({MiddleVPBB, MiddleVPBB, HeaderVPBB});
     MiddleVPBB->clearPredecessors();
     MiddleVPBB->setPredecessors({LatchVPBB, LatchVPBB});
-    return handleUncountableExitsWithSideEffects(
-        Plan, Exits, HeaderVPBB, LatchVPBB, MiddleVPBB, TheLoop, PSE, DT, AC);
+    return handleUncountableExitsWithSideEffects(Plan, Exits, HeaderVPBB,
+                                                 LatchVPBB, MiddleVPBB, ORE,
+                                                 TheLoop, PSE, DT, AC);
   }
 
   // Create the vector.early.exit blocks.
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
index 1c7b17942b795..a837d3fd4c266 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h
@@ -383,9 +383,10 @@ struct VPlanTransforms {
   /// latch exit condition. Multiple exits are handled with a dispatch block
   /// that determines which exit to take based on lane-by-lane semantics.
   LLVM_ABI_FOR_TEST static bool
-  handleUncountableEarlyExits(VPlan &Plan, Loop *TheLoop,
-                              PredicatedScalarEvolution &PSE, DominatorTree &DT,
-                              AssumptionCache *AC, UncountableExitStyle Style);
+  handleUncountableEarlyExits(VPlan &Plan, OptimizationRemarkEmitter *ORE,
+                              Loop *TheLoop, PredicatedScalarEvolution &PSE,
+                              DominatorTree &DT, AssumptionCache *AC,
+                              UncountableExitStyle Style);
 
   /// Disconnect countable early exits from the loop.
   LLVM_ABI_FOR_TEST static void handleCountableEarlyExits(VPlan &Plan);
diff --git a/llvm/test/Transforms/LoopVectorize/early_exit_legality.ll b/llvm/test/Transforms/LoopVectorize/early_exit_legality.ll
index 7768aac2ec309..ae7cce7116704 100644
--- a/llvm/test/Transforms/LoopVectorize/early_exit_legality.ll
+++ b/llvm/test/Transforms/LoopVectorize/early_exit_legality.ll
@@ -1,6 +1,9 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
 ; REQUIRES: asserts
-; RUN: opt -S < %s -p loop-vectorize -debug-only=loop-vectorize,vplan -force-vector-width=4 -disable-output 2>&1 | FileCheck %s
+; RUN: opt -S < %s -p loop-vectorize -debug-only=loop-vectorize,vplan -force-vector-width=4 \
+; RUN:   -disable-output 2>&1 | FileCheck %s --check-prefix=CHECK-DEBUG
+; RUN: opt -S < %s -p loop-vectorize -pass-remarks-analysis='loop-vectorize' \
+; RUN:   -force-vector-width=4 -disable-output 2>&1 | FileCheck %s --check-prefix=CHECK-REMARK
 
 declare void @init_mem(ptr, i64) nofree
 
@@ -8,10 +11,10 @@ declare void @init_mem(ptr, i64) nofree
 
 ; The form of the induction variables requires SCEV predicates.
 define i32 @diff_exit_block_needs_scev_check(i32 %end) {
-; CHECK-LABEL: LV: Checking a loop in 'diff_exit_block_needs_scev_check'
-; CHECK:       Found an early exit loop with symbolic max backedge taken count: (-1 + (1 umax (zext i10 (trunc i32 %end to i10) to i32)))<nsw>
-; CHECK-NEXT:  LV: We can vectorize this loop!
-; CHECK-NOT:   LV: Not vectorizing:
+; CHECK-DEBUG-LABEL: LV: Checking a loop in 'diff_exit_block_needs_scev_check'
+; CHECK-DEBUG:       Found an early exit loop with symbolic max backedge taken count: (-1 + (1 umax (zext i10 (trunc i32 %end to i10) to i32)))<nsw>
+; CHECK-DEBUG-NEXT:  LV: We can vectorize this loop!
+; CHECK-DEBUG-NOT:   LV: Not vectorizing:
 entry:
   %p1 = alloca [1024 x i32]
   %p2 = alloca [1024 x i32]
@@ -46,10 +49,10 @@ exit:
 
 
 define i64 @same_exit_block_pre_inc_use1() {
-; CHECK-LABEL: LV: Checking a loop in 'same_exit_block_pre_inc_use1'
-; CHECK:       LV: Found an early exit loop with symbolic max backedge taken count: 63
-; CHECK-NEXT:  LV: We can vectorize this loop!
-; CHECK-NOT:   LV: Not vectorizing
+; CHECK-DEBUG-LABEL: LV: Checking a loop in 'same_exit_block_pre_inc_use1'
+; CHECK-DEBUG:       LV: Found an early exit loop with symbolic max backedge taken count: 63
+; CHECK-DEBUG-NEXT:  LV: We can vectorize this loop!
+; CHECK-DEBUG-NOT:   LV: Not vectorizing
 entry:
   %p1 = alloca [1024 x i8]
   %p2 = alloca [1024 x i8]
@@ -78,9 +81,9 @@ loop.end:
 
 
 define i64 @loop_contains_safe_call() {
-; CHECK-LABEL: LV: Checking a loop in 'loop_contains_safe_call'
-; CHECK:       LV: Found an early exit loop with symbolic max backedge taken count: 63
-; CHECK-NEXT:  LV: We can vectorize this loop!
+; CHECK-DEBUG-LABEL: LV: Checking a loop in 'loop_contains_safe_call'
+; CHECK-DEBUG:       LV: Found an early exit loop with symbolic max backedge taken count: 63
+; CHECK-DEBUG-NEXT:  LV: We can vectorize this loop!
 entry:
   %p1 = alloca [1024 x i8]
   %p2 = alloca [1024 x i8]
@@ -108,9 +111,9 @@ loop.end:
 
 
 define i64 @loop_contains_safe_div() {
-; CHECK-LABEL: LV: Checking a loop in 'loop_contains_safe_div'
-; CHECK:       LV: Found an early exit loop with symbolic max backedge taken count: 63
-; CHECK-NEXT:  LV: We can vectorize this loop!
+; CHECK-DEBUG-LABEL: LV: Checking a loop in 'loop_contains_safe_div'
+; CHECK-DEBUG:       LV: Found an early exit loop with symbolic max backedge taken count: 63
+; CHECK-DEBUG-NEXT:  LV: We can vectorize this loop!
 entry:
   %p1 = alloca [1024 x i8]
   %p2 = alloca [1024 x i8]
@@ -138,10 +141,10 @@ loop.end:
 
 
 define i64 @loop_contains_load_after_early_exit(ptr dereferenceable(1024) align(8) %p2) {
-; CHECK-LABEL: LV: Checking a loop in 'loop_contains_load_after_early_exit'
-; CHECK:       LV: Found an early exit loop with symbolic max backedge taken count: 63
-; CHECK-NEXT:  LV: We can vectorize this loop!
-; CHECK-NOT:   LV: Not vectorizing
+; CHECK-DEBUG-LABEL: LV: Checking a loop in 'loop_contains_load_after_early_exit'
+; CHECK-DEBUG:       LV: Found an early exit loop with symbolic max backedge taken count: 63
+; CHECK-DEBUG-NEXT:  LV: We can vectorize this loop!
+; CHECK-DEBUG-NOT:   LV: Not vectorizing
 entry:
   %p1 = alloca [1024 x i8]
   call void @init_mem(ptr %p1, i64 1024)
@@ -167,22 +170,23 @@ loop.end:
 }
 
 
-define i64 @one_uncountable_two_countable_same_exit_phi_of_consts() {
-; CHECK-LABEL: LV: Checking a loop in 'one_uncountable_two_countable_same_exit_phi_of_consts'
-; CHECK:       LV: Found an early exit loop with symbolic max backedge taken count: 61
-; CHECK-NEXT:  LV: We can vectorize this loop!
-; CHECK-NEXT:  LV: Not vectorizing: Auto-vectorization of early exit loops requiring a scalar epilogue is unsupported.
+define i64 @one_uncountable_two_countable_same_exit_phi_of_consts() !dbg !39 {
+; CHECK-DEBUG-LABEL: LV: Checking a loop in 'one_uncountable_two_countable_same_exit_phi_of_consts'
+; CHECK-DEBUG:       LV: Found an early exit loop with symbolic max backedge taken count: 61
+; CHECK-DEBUG-NEXT:  LV: We can vectorize this loop!
+; CHECK-DEBUG-NEXT:  LV: Not vectorizing: Auto-vectorization of early exit loops requiring a scalar epilogue is unsupported.
+; CHECK-REMARK:      foo.c:60:3: loop not vectorized: Auto-vectorization of early exit loops requiring a scalar epilogue is unsupported
 entry:
   %p1 = alloca [1024 x i8]
   %p2 = alloca [1024 x i8]
   call void @init_mem(ptr %p1, i64 1024)
   call void @init_mem(ptr %p2, i64 1024)
-  br label %loop
+  br label %loop, !dbg !40
 
 loop:
   %index = phi i64 [ %index.next, %loop.inc ], [ 3, %entry ]
   %cmp1 = icmp ne i64 %index, 64
-  br i1 %cmp1, label %search, label %loop.end
+  br i1 %cmp1, label %search, label %loop.end, !dbg !40
 
 search:
   %arrayidx = getelementptr inbounds i8, ptr %p1, i64 %index
@@ -190,12 +194,12 @@ search:
   %arrayidx1 = getelementptr inbounds i8, ptr %p2, i64 %index
   %ld2 = load i8, ptr %arrayidx1, align 1
   %cmp3 = icmp eq i8 %ld1, %ld2
-  br i1 %cmp3, label %loop.end, label %loop.inc
+  br i1 %cmp3, label %loop.end, label %loop.inc, !dbg !40
 
 loop.inc:
   %index.next = add i64 %index, 1
   %exitcond = icmp ne i64 %index.next, 128
-  br i1 %exitcond, label %loop, label %loop.end
+  br i1 %exitcond, label %loop, label %loop.end, !dbg !40
 
 loop.end:
   %retval = phi i64 [ 0, %loop ], [ 1, %search ], [ 0, %loop.inc ]
@@ -206,29 +210,30 @@ loop.end:
 ; == SOME ILLEGAL EXAMPLES ==
 
 
-define i64 @same_exit_block_pre_inc_use1_too_small_allocas() {
-; CHECK-LABEL: LV: Checking a loop in 'same_exit_block_pre_inc_use1_too_small_allocas'
-; CHECK:       LV: Not vectorizing: Auto-vectorization of loops with potentially faulting load is not supported.
+define i64 @same_exit_block_pre_inc_use1_too_small_allocas() !dbg !4 {
+; CHECK-DEBUG-LABEL: LV: Checking a loop in 'same_exit_block_pre_inc_use1_too_small_allocas'
+; CHECK-DEBUG:       LV: Not vectorizing: Auto-vectorization of early exit loops with potentially faulting loads is not supported.
+; CHECK-REMARK:      foo.c:5:3: loop not vectorized: Auto-vectorization of early exit loops with potentially faulting loads is not supported.
 entry:
   %p1 = alloca [42 x i8]
   %p2 = alloca [42 x i8]
   call void @init_mem(ptr %p1, i64 1024)
   call void @init_mem(ptr %p2, i64 1024)
-  br label %loop
+  br label %loop, !dbg !8
 
 loop:
   %index = phi i64 [ %index.next, %loop.inc ], [ 3, %entry ]
   %arrayidx = getelementptr inbounds i8, ptr %p1, i64 %index
-  %ld1 = load i8, ptr %arrayidx, align 1
+  %ld1 = load i8, ptr %arrayidx, align 1, !dbg !8
   %arrayidx1 = getelementptr inbounds i8, ptr %p2, i64 %index
-  %ld2 = load i8, ptr %arrayidx1, align 1
-  %cmp3 = icmp eq i8 %ld1, %ld2
-  br i1 %cmp3, label %loop.inc, label %loop.end
+  %ld2 = load i8, ptr %arrayidx1, align 1, !dbg !8
+  %cmp3 = icmp eq i8 %ld1, %ld2, !dbg !8
+  br i1 %cmp3, label %loop.inc, label %loop.end, !dbg !8
 
 loop.inc:
-  %index.next = add i64 %index, 1
-  %exitcond = icmp ne i64 %index.next, 67
-  br i1 %exitcond, label %loop, label %loop.end
+  %index.next = add i64 %index, 1, !dbg !8
+  %exitcond = icmp ne i64 %index.next, 67, !dbg !8
+  br i1 %exitcond, label %loop, label %loop.end, !dbg !8
 
 loop.end:
   %retval = phi i64 [ %index, %loop ], [ 67, %loop.inc ]
@@ -236,11 +241,12 @@ loop.end:
 }
 
 
-define i64 @same_exit_block_pre_inc_use1_too_small_deref_ptrs(ptr dereferenceable(42) %p1, ptr dereferenceable(42) %p2) {
-; CHECK-LABEL: LV: Checking a loop in 'same_exit_block_pre_inc_use1_too_small_deref_ptrs'
-; CHECK:       LV: Not vectorizing: Auto-vectorization of loops with potentially faulting load is not supported.
+define i64 @same_exit_block_pre_inc_use1_too_small_deref_ptrs(ptr dereferenceable(42) %p1, ptr dereferenceable(42) %p2) !dbg !41 {
+; CHECK-DEBUG-LABEL: LV: Checking a loop in 'same_exit_block_pre_inc_use1_too_small_deref_ptrs'
+; CHECK-DEBUG:       LV: Not vectorizing: Auto-vectorization of early exit loops with potentially faulting loads is not supported.
+; CHECK-REMARK:      foo.c:70:3: loop not vectorized: Auto-vectorization of early exit loops with potentially faulting loads is not supported.
 entry:
-  br label %loop
+  br label %loop, !dbg !42
 
 loop:
   %index = phi i64 [ %index.next, %loop.inc ], [ 3, %entry ]
@@ -249,12 +255,12 @@ loop:
   %arrayidx1 = getelementptr inbounds i8, ptr %p2, i64 %index
   %ld2 = load i8, ptr %arrayidx1, align 1
   %cmp3 = icmp eq i8 %ld1, %ld2
-  br i1 %cmp3, label %loop.inc, label %loop.end
+  br i1 %cmp3, label %loop.inc, label %loop.end, !dbg !42
 
 loop.inc:
   %index.next = add i64 %index, 1
   %exitcond = icmp ne i64 %index.next, 67
-  br i1 %exitcond, label %loop, label %loop.end
+  br i1 %exitcond, label %loop, label %loop.end, !dbg !42
 
 loop.end:
   %retval = phi i64 [ %index, %loop ], [ 67, %loop.inc ]
@@ -262,11 +268,12 @@ loop.end:
 }
 
 
-define i64 @same_exit_block_pre_inc_use1_unknown_ptrs(ptr %p1, ptr %p2) {
-; CHECK-LABEL: LV: Checking a loop in 'same_exit_block_pre_inc_use1_unknown_ptrs'
-; CHECK:       LV: Not vectorizing: Auto-vectorization of loops with potentially faulting load is not supported.
+define i64 @same_exit_block_pre_inc_use1_unknown_ptrs(ptr %p1, ptr %p2) !dbg !43 {
+; CHECK-DEBUG-LABEL: LV: Checking a loop in 'same_exit_block_pre_inc_use1_unknown_ptrs'
+; CHECK-DEBUG:       LV: Not vectorizing: Auto-vectorization of early exit loops with potentially faulting loads is not supported.
+; CHECK-REMARK:      foo.c:80:3: loop not vectorized: Auto-vectorization of early exit loops with potentially faulting loads is not supported.
 entry:
-  br label %loop
+  br label %loop, !dbg !44
 
 loop:
   %index = phi i64 [ %index.next, %loop.inc ], [ 3, %entry ]
@@ -275,39 +282,40 @@ loop:
   %arrayidx1 = getelementptr inbounds i8, ptr %p2, i64 %index
   %ld2 = load i8, ptr %arrayidx1, align 1
   %cmp3 = icmp eq i8 %ld1, %ld2
-  br i1 %cmp3, label %loop.inc, label %loop.end
+  br i1 %cmp3, label %loop.inc, label %loop.end, !dbg !44
 
 loop.inc:
   %index.next = add i64 %index, 1
   %exitcond = icmp ne i64 %index.next, 67
-  br i1 %exitcond, label %loop, label %loop.end
+  br i1 %exitcond, label %loop, label %loop.end, !dbg !44
 
 loop.end:
   %retval = phi i64 [ %index, %loop ], [ 67, %loop.inc ]
   ret i64 %retval
 }
 
-define ptr @same_exit_block_strided_unknown_ptr(ptr %first, ptr %last, i32 %value) {
-...
[truncated]

``````````

</details>


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


More information about the llvm-commits mailing list