[llvm] [LV] Emit better debug and opt-report messages when vectorization is disallowed in the LoopVectorizer (PR #158513)

Tibor Győri via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 17 03:31:37 PST 2025


https://github.com/TiborGY updated https://github.com/llvm/llvm-project/pull/158513

>From 81f1800118aab3462dbbd03023c2b052f7d455df Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sun, 14 Sep 2025 23:19:37 +0200
Subject: [PATCH 01/34] Emit better debug and opt-report messages when
 vectorization is disallowed in the LoopVectorizer

formatting

formatting2

fix ;) vs. ); typos

formatting3
---
 .../Vectorize/LoopVectorizationLegality.cpp   | 35 ++++++++++++++++---
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index ff35db14f7094..9010ca62aeee7 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -182,14 +182,41 @@ void LoopVectorizeHints::setAlreadyVectorized() {
 bool LoopVectorizeHints::allowVectorization(
     Function *F, Loop *L, bool VectorizeOnlyWhenForced) const {
   if (getForce() == LoopVectorizeHints::FK_Disabled) {
-    LLVM_DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n");
-    emitRemarkWithHints();
+    if (Force.Value == LoopVectorizeHints::FK_Disabled) {
+      LLVM_DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n");
+      ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedExplicitlyDisabled",
+                                        TheLoop->getStartLoc(),
+                                        TheLoop->getHeader())
+               << "loop not vectorized: vectorization is explicitly disabled");
+    } else if (hasDisableAllTransformsHint(TheLoop)) {
+      LLVM_DEBUG(
+          dbgs() << "LV: Not vectorizing: loop hasDisableAllTransformsHint.\n");
+      ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedTrafoDisabled",
+                                        TheLoop->getStartLoc(),
+                                        TheLoop->getHeader())
+               << "loop not vectorized: loop transformations are disabled");
+    } else {
+      // This should be unreachable unless there is a bug.
+      LLVM_DEBUG(
+          dbgs() << "LV: [FIXME] Not vectorizing: loop vect disabled for "
+                    "an unknown reason!\n");
+      ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedUnknown",
+                                        TheLoop->getStartLoc(),
+                                        TheLoop->getHeader())
+               << "loop not vectorized: unknown reason, please file a bug "
+                  "report on the LLVM issue tracker");
+    }
     return false;
   }
 
   if (VectorizeOnlyWhenForced && getForce() != LoopVectorizeHints::FK_Enabled) {
-    LLVM_DEBUG(dbgs() << "LV: Not vectorizing: No #pragma vectorize enable.\n");
-    emitRemarkWithHints();
+    LLVM_DEBUG(dbgs() << "LV: Not vectorizing: VectorizeOnlyWhenForced is set, "
+                         "and no #pragma vectorize enable.\n");
+    ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedForceOnly",
+                                      TheLoop->getStartLoc(),
+                                      TheLoop->getHeader())
+             << "loop not vectorized: only vectorizing loops that "
+                "explicitly request it");
     return false;
   }
 

>From 6d941ff51d221e03a9d575086f4cec5efdf43dd2 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Mon, 15 Sep 2025 12:22:19 +0200
Subject: [PATCH 02/34] Trafo -> Transforms

---
 llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 9010ca62aeee7..2dbab7d485ec0 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -191,7 +191,7 @@ bool LoopVectorizeHints::allowVectorization(
     } else if (hasDisableAllTransformsHint(TheLoop)) {
       LLVM_DEBUG(
           dbgs() << "LV: Not vectorizing: loop hasDisableAllTransformsHint.\n");
-      ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedTrafoDisabled",
+      ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedTransformsDisabled",
                                         TheLoop->getStartLoc(),
                                         TheLoop->getHeader())
                << "loop not vectorized: loop transformations are disabled");

>From c0e6aec88cd15bc307d7b9a63828ef4fb2cbe7bb Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Mon, 15 Sep 2025 19:13:41 +0200
Subject: [PATCH 03/34] Testing part 1: explicitly disabled code path

---
 .../check-disabled-vectorization-msgs.ll      | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 llvm/test/Transforms/LoopVectorize/check-disabled-vectorization-msgs.ll

diff --git a/llvm/test/Transforms/LoopVectorize/check-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/check-disabled-vectorization-msgs.ll
new file mode 100644
index 0000000000000..be903d3ff61b8
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/check-disabled-vectorization-msgs.ll
@@ -0,0 +1,47 @@
+; This test checks that we emit only the correct debug message and
+; optimization remark when the loop vectorizer is disabled by loop metadata.
+
+; REQUIRES: asserts
+; RUN: opt -passes=loop-vectorize -pass-remarks=loop-vectorize \
+; RUN:     -pass-remarks-missed=loop-vectorize \
+; RUN:     -pass-remarks-analysis=loop-vectorize -debug -disable-output \
+; RUN:     < %s 2>&1 | FileCheck %s
+; CHECK-NOT: LV: We can vectorize this loop
+; CHECK-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
+; CHECK-NOT: LV: [FIXME] Not vectorizing: loop vect disabled for an unknown reason
+; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
+; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
+; CHECK-NOT: LV: Not vectorizing: Cannot prove legality
+; CHECK: LV: Loop hints: force=disabled
+; CHECK: LV: Not vectorizing: #pragma vectorize disable.
+; CHECK: remark:
+; CHECK-SAME: loop not vectorized: vectorization is explicitly disabled
+; CHECK: LV: Loop hints prevent vectorization
+
+define dso_local noundef nofpclass(nan inf) double @_Z15CompareDistmatsPKdS0_(ptr noundef readonly captures(none) %distmat1, ptr noundef readonly captures(none) %distmat2) local_unnamed_addr {
+entry:
+  br label %for.body
+
+for.cond.cleanup:                                 ; preds = %for.body
+  %add.lcssa = phi double [ %add, %for.body ]
+  %div = fmul fast double %add.lcssa, 0x3FB1111111111111
+  %0 = tail call fast double @llvm.sqrt.f64(double %div)
+  ret double %0
+
+for.body:                                         ; preds = %entry, %for.body
+  %i.014 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
+  %RMSD.013 = phi double [ 0.000000e+00, %entry ], [ %add, %for.body ]
+  %arrayidx = getelementptr inbounds nuw double, ptr %distmat1, i64 %i.014
+  %1 = load double, ptr %arrayidx, align 8
+  %arrayidx1 = getelementptr inbounds nuw double, ptr %distmat2, i64 %i.014
+  %2 = load double, ptr %arrayidx1, align 8
+  %sub = fsub fast double %1, %2
+  %mul = fmul fast double %sub, %sub
+  %add = fadd fast double %mul, %RMSD.013
+  %inc = add nuw nsw i64 %i.014, 1
+  %exitcond.not = icmp eq i64 %inc, 15
+  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body, !llvm.loop !0
+}
+
+!0 = distinct !{!0, !1}
+!1 = !{!"llvm.loop.vectorize.enable", i1 false}
\ No newline at end of file

>From c290becce4d3b7e1b1f7582fc2045621f63fc369 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Tue, 16 Sep 2025 01:19:25 +0200
Subject: [PATCH 04/34] Testing part 2: VectorizeOnlyWhenForced code path

---
 .../check-disabled-vectorization-msgs.ll      |  4 +-
 .../check-vectorize-forced-only-msgs.ll       | 46 +++++++++++++++++++
 2 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/Transforms/LoopVectorize/check-vectorize-forced-only-msgs.ll

diff --git a/llvm/test/Transforms/LoopVectorize/check-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/check-disabled-vectorization-msgs.ll
index be903d3ff61b8..7ed1750d9d8d1 100644
--- a/llvm/test/Transforms/LoopVectorize/check-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/check-disabled-vectorization-msgs.ll
@@ -1,4 +1,4 @@
-; This test checks that we emit only the correct debug message and
+; This test checks that we emit only the correct debug messages and
 ; optimization remark when the loop vectorizer is disabled by loop metadata.
 
 ; REQUIRES: asserts
@@ -44,4 +44,4 @@ for.body:                                         ; preds = %entry, %for.body
 }
 
 !0 = distinct !{!0, !1}
-!1 = !{!"llvm.loop.vectorize.enable", i1 false}
\ No newline at end of file
+!1 = !{!"llvm.loop.vectorize.enable", i1 false}
diff --git a/llvm/test/Transforms/LoopVectorize/check-vectorize-forced-only-msgs.ll b/llvm/test/Transforms/LoopVectorize/check-vectorize-forced-only-msgs.ll
new file mode 100644
index 0000000000000..18e398e2b0331
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/check-vectorize-forced-only-msgs.ll
@@ -0,0 +1,46 @@
+; This test checks that we emit only the correct debug messages and
+; optimization remark when the loop is not vectorized due to the 
+; vectorize-forced-only pass option being set.
+
+; REQUIRES: asserts
+; RUN: opt -passes='loop-vectorize<vectorize-forced-only>' \
+; RUN:   -pass-remarks=loop-vectorize \
+; RUN:   -pass-remarks-missed=loop-vectorize \
+; RUN:   -pass-remarks-analysis=loop-vectorize -debug -disable-output \
+; RUN:   < %s 2>&1 | FileCheck %s
+; CHECK-NOT: LV: We can vectorize this loop
+; CHECK-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
+; CHECK-NOT: LV: [FIXME] Not vectorizing: loop vect disabled for an unknown reason
+; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable
+; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
+; CHECK-NOT: LV: Not vectorizing: Cannot prove legality
+; CHECK: LV: Loop hints: force=?
+; CHECK: LV: Not vectorizing: VectorizeOnlyWhenForced is set, and no #pragma vectorize enable
+; CHECK: remark:
+; CHECK-SAME: loop not vectorized: only vectorizing loops that explicitly request it
+; CHECK: LV: Loop hints prevent vectorization
+
+define dso_local noundef nofpclass(nan inf) double @_Z15CompareDistmatsPKdS0_(ptr noundef readonly captures(none) %distmat1, ptr noundef readonly captures(none) %distmat2) local_unnamed_addr {
+entry:
+  br label %for.body
+
+for.cond.cleanup:                                 ; preds = %for.body
+  %add.lcssa = phi double [ %add, %for.body ]
+  %div = fmul fast double %add.lcssa, 0x3FB1111111111111
+  %0 = tail call fast double @llvm.sqrt.f64(double %div)
+  ret double %0
+
+for.body:                                         ; preds = %entry, %for.body
+  %i.014 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
+  %RMSD.013 = phi double [ 0.000000e+00, %entry ], [ %add, %for.body ]
+  %arrayidx = getelementptr inbounds nuw double, ptr %distmat1, i64 %i.014
+  %1 = load double, ptr %arrayidx, align 8
+  %arrayidx1 = getelementptr inbounds nuw double, ptr %distmat2, i64 %i.014
+  %2 = load double, ptr %arrayidx1, align 8
+  %sub = fsub fast double %1, %2
+  %mul = fmul fast double %sub, %sub
+  %add = fadd fast double %mul, %RMSD.013
+  %inc = add nuw nsw i64 %i.014, 1
+  %exitcond.not = icmp eq i64 %inc, 15
+  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
+}

>From 109b3fd0dabec169b693c7a9b80eba704531ae2a Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Tue, 16 Sep 2025 14:31:37 +0200
Subject: [PATCH 05/34] Rename the two new tests so far to begin with diag-

---
 ...-vectorization-msgs.ll => diag-disabled-vectorization-msgs.ll} | 0
 ...ize-forced-only-msgs.ll => diag-vectorize-forced-only-msgs.ll} | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 rename llvm/test/Transforms/LoopVectorize/{check-disabled-vectorization-msgs.ll => diag-disabled-vectorization-msgs.ll} (100%)
 rename llvm/test/Transforms/LoopVectorize/{check-vectorize-forced-only-msgs.ll => diag-vectorize-forced-only-msgs.ll} (100%)

diff --git a/llvm/test/Transforms/LoopVectorize/check-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
similarity index 100%
rename from llvm/test/Transforms/LoopVectorize/check-disabled-vectorization-msgs.ll
rename to llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
diff --git a/llvm/test/Transforms/LoopVectorize/check-vectorize-forced-only-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll
similarity index 100%
rename from llvm/test/Transforms/LoopVectorize/check-vectorize-forced-only-msgs.ll
rename to llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll

>From 3c4c8de8370e398d1b72c4b29e07e6c9a253f2bd Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Tue, 16 Sep 2025 14:42:10 +0200
Subject: [PATCH 06/34] Testing part 3: hasDisableAllTransformsHint code path

---
 .../diag-disable_nonforced-msgs.ll            | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
new file mode 100644
index 0000000000000..1add46f951190
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
@@ -0,0 +1,42 @@
+; This test checks that we emit only the correct debug messages and
+; optimization remark when the loop vectorizer is disabled by loop metadata
+; that requests no loop transformations.
+
+; REQUIRES: asserts
+; RUN: opt -passes=loop-vectorize -pass-remarks=loop-vectorize \
+; RUN:     -pass-remarks-missed=loop-vectorize \
+; RUN:     -pass-remarks-analysis=loop-vectorize -debug -disable-output \
+; RUN:     -force-vector-interleave=1 -force-vector-width=2 \
+; RUN:     < %s 2>&1 | FileCheck %s
+; CHECK-NOT: LV: We can vectorize this loop
+; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable.
+; CHECK-NOT: LV: [FIXME] Not vectorizing: loop vect disabled for an unknown reason
+; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
+; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
+; CHECK-NOT: LV: Not vectorizing: Cannot prove legality
+; CHECK: LV: Loop hints: force=disabled
+; CHECK: LV: Not vectorizing: loop hasDisableAllTransformsHint.
+; CHECK: remark:
+; CHECK-SAME: loop not vectorized: vectorization is explicitly disabled
+; CHECK: LV: Loop hints prevent vectorization
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+define void @disable_nonforced(ptr nocapture %a, i32 %n) {
+entry:
+  %cmp4 = icmp sgt i32 %n, 0
+  br i1 %cmp4, label %for.body, label %for.end
+
+for.body:
+  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
+  %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
+  %0 = trunc i64 %indvars.iv to i32
+  store i32 %0, ptr %arrayidx, align 4
+  %indvars.iv.next = add i64 %indvars.iv, 1
+  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
+  %exitcond = icmp eq i32 %lftr.wideiv, %n
+  br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0
+
+for.end:
+  ret void
+}
+
+!0 = !{!0, !{!"llvm.loop.disable_nonforced"}}

>From fa19cccfe3fc524439cca5b2cc6444ba4b193f24 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Tue, 16 Sep 2025 15:04:27 +0200
Subject: [PATCH 07/34] fix test 3

---
 .../Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
index 1add46f951190..df4905fd4595e 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
@@ -17,7 +17,7 @@
 ; CHECK: LV: Loop hints: force=disabled
 ; CHECK: LV: Not vectorizing: loop hasDisableAllTransformsHint.
 ; CHECK: remark:
-; CHECK-SAME: loop not vectorized: vectorization is explicitly disabled
+; CHECK-SAME: loop not vectorized: loop transformations are disabled
 ; CHECK: LV: Loop hints prevent vectorization
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 define void @disable_nonforced(ptr nocapture %a, i32 %n) {

>From 29d1fa2e300f538cd7825bc6b7d5bfa4457bf37f Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Mon, 13 Oct 2025 23:11:22 +0200
Subject: [PATCH 08/34] use [BUG] instead of [FIXME] in the sanity check fail
 debug msg

---
 llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp  | 5 ++---
 .../Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll  | 2 +-
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll        | 2 +-
 .../LoopVectorize/diag-vectorize-forced-only-msgs.ll         | 2 +-
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 2dbab7d485ec0..4df0c27a9ea24 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -197,9 +197,8 @@ bool LoopVectorizeHints::allowVectorization(
                << "loop not vectorized: loop transformations are disabled");
     } else {
       // This should be unreachable unless there is a bug.
-      LLVM_DEBUG(
-          dbgs() << "LV: [FIXME] Not vectorizing: loop vect disabled for "
-                    "an unknown reason!\n");
+      LLVM_DEBUG(dbgs() << "LV: [BUG] Not vectorizing: loop vect disabled for "
+                           "an unknown reason!\n");
       ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedUnknown",
                                         TheLoop->getStartLoc(),
                                         TheLoop->getHeader())
diff --git a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
index df4905fd4595e..0a22bdb172584 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
@@ -10,7 +10,7 @@
 ; RUN:     < %s 2>&1 | FileCheck %s
 ; CHECK-NOT: LV: We can vectorize this loop
 ; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable.
-; CHECK-NOT: LV: [FIXME] Not vectorizing: loop vect disabled for an unknown reason
+; CHECK-NOT: LV: [BUG] Not vectorizing: loop vect disabled for an unknown reason
 ; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
 ; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
 ; CHECK-NOT: LV: Not vectorizing: Cannot prove legality
diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index 7ed1750d9d8d1..8fc4bf5aad683 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -8,7 +8,7 @@
 ; RUN:     < %s 2>&1 | FileCheck %s
 ; CHECK-NOT: LV: We can vectorize this loop
 ; CHECK-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
-; CHECK-NOT: LV: [FIXME] Not vectorizing: loop vect disabled for an unknown reason
+; CHECK-NOT: LV: [BUG] Not vectorizing: loop vect disabled for an unknown reason
 ; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
 ; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
 ; CHECK-NOT: LV: Not vectorizing: Cannot prove legality
diff --git a/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll
index 18e398e2b0331..7cc042f5c45b7 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll
@@ -10,7 +10,7 @@
 ; RUN:   < %s 2>&1 | FileCheck %s
 ; CHECK-NOT: LV: We can vectorize this loop
 ; CHECK-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
-; CHECK-NOT: LV: [FIXME] Not vectorizing: loop vect disabled for an unknown reason
+; CHECK-NOT: LV: [BUG] Not vectorizing: loop vect disabled for an unknown reason
 ; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable
 ; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
 ; CHECK-NOT: LV: Not vectorizing: Cannot prove legality

>From 117c3584794b21d209c039d1041508cc7865ddf8 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Tue, 14 Oct 2025 01:57:15 +0200
Subject: [PATCH 09/34] Clean up function name and remove excessive attributes
 from Test 1 and Test 2

---
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll           | 2 +-
 .../Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index 8fc4bf5aad683..5b68f9057efcc 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -18,7 +18,7 @@
 ; CHECK-SAME: loop not vectorized: vectorization is explicitly disabled
 ; CHECK: LV: Loop hints prevent vectorization
 
-define dso_local noundef nofpclass(nan inf) double @_Z15CompareDistmatsPKdS0_(ptr noundef readonly captures(none) %distmat1, ptr noundef readonly captures(none) %distmat2) local_unnamed_addr {
+define double @CompareDistmats(ptr %distmat1, ptr %distmat2){
 entry:
   br label %for.body
 
diff --git a/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll
index 7cc042f5c45b7..c0c9fb176d148 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll
@@ -20,7 +20,7 @@
 ; CHECK-SAME: loop not vectorized: only vectorizing loops that explicitly request it
 ; CHECK: LV: Loop hints prevent vectorization
 
-define dso_local noundef nofpclass(nan inf) double @_Z15CompareDistmatsPKdS0_(ptr noundef readonly captures(none) %distmat1, ptr noundef readonly captures(none) %distmat2) local_unnamed_addr {
+define double @CompareDistmats(ptr %distmat1, ptr %distmat2){
 entry:
   br label %for.body
 

>From 2241343d1834af085b0b7467d5b69d5b499d25e3 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 18 Oct 2025 03:26:04 +0200
Subject: [PATCH 10/34] Try combining Test1 and Test2 into one file

---
 .../diag-disabled-vectorization-msgs.ll       | 49 ++++++++++++++-----
 .../diag-vectorize-forced-only-msgs.ll        | 46 -----------------
 2 files changed, 37 insertions(+), 58 deletions(-)
 delete mode 100644 llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index 5b68f9057efcc..989bafa29745e 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -1,3 +1,4 @@
+; TEST 1
 ; This test checks that we emit only the correct debug messages and
 ; optimization remark when the loop vectorizer is disabled by loop metadata.
 
@@ -5,18 +6,42 @@
 ; RUN: opt -passes=loop-vectorize -pass-remarks=loop-vectorize \
 ; RUN:     -pass-remarks-missed=loop-vectorize \
 ; RUN:     -pass-remarks-analysis=loop-vectorize -debug -disable-output \
-; RUN:     < %s 2>&1 | FileCheck %s
-; CHECK-NOT: LV: We can vectorize this loop
-; CHECK-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
-; CHECK-NOT: LV: [BUG] Not vectorizing: loop vect disabled for an unknown reason
-; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
-; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
-; CHECK-NOT: LV: Not vectorizing: Cannot prove legality
-; CHECK: LV: Loop hints: force=disabled
-; CHECK: LV: Not vectorizing: #pragma vectorize disable.
-; CHECK: remark:
-; CHECK-SAME: loop not vectorized: vectorization is explicitly disabled
-; CHECK: LV: Loop hints prevent vectorization
+; RUN:     < %s 2>&1 | FileCheck --check-prefix=METADATA %s
+; METADATA-NOT: LV: We can vectorize this loop
+; METADATA-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
+; METADATA-NOT: LV: [BUG] Not vectorizing: loop vect disabled for an unknown reason
+; METADATA-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
+; METADATA-NOT: LV: Not vectorizing: Disabled/already vectorized
+; METADATA-NOT: LV: Not vectorizing: Cannot prove legality
+; METADATA: LV: Loop hints: force=disabled
+; METADATA: LV: Not vectorizing: #pragma vectorize disable.
+; METADATA: remark:
+; METADATA-SAME: loop not vectorized: vectorization is explicitly disabled
+; METADATA: LV: Loop hints prevent vectorization
+
+; TEST 2
+; This test checks that we emit only the correct debug messages and
+; optimization remark when the loop is not vectorized due to the 
+; vectorize-forced-only pass option being set.
+
+; Strip metadata for FORCEDONLY run, keep it for METADATA run
+; RUN: sed 's/,[[:space:]]*!llvm\.loop[[:space:]]*!0//' %s | \
+; RUN: opt -passes='loop-vectorize<vectorize-forced-only>' \
+; RUN:   -pass-remarks=loop-vectorize \
+; RUN:   -pass-remarks-missed=loop-vectorize \
+; RUN:   -pass-remarks-analysis=loop-vectorize -debug -disable-output \
+; RUN:   2>&1 | FileCheck --check-prefix=FORCEDONLY %s
+; FORCEDONLY-NOT: LV: We can vectorize this loop
+; FORCEDONLY-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
+; FORCEDONLY-NOT: LV: [BUG] Not vectorizing: loop vect disabled for an unknown reason
+; FORCEDONLY-NOT: LV: Not vectorizing: #pragma vectorize disable
+; FORCEDONLY-NOT: LV: Not vectorizing: Disabled/already vectorized
+; FORCEDONLY-NOT: LV: Not vectorizing: Cannot prove legality
+; FORCEDONLY: LV: Loop hints: force=?
+; FORCEDONLY: LV: Not vectorizing: VectorizeOnlyWhenForced is set, and no #pragma vectorize enable
+; FORCEDONLY: remark:
+; FORCEDONLY-SAME: loop not vectorized: only vectorizing loops that explicitly request it
+; FORCEDONLY: LV: Loop hints prevent vectorization
 
 define double @CompareDistmats(ptr %distmat1, ptr %distmat2){
 entry:
diff --git a/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll
deleted file mode 100644
index c0c9fb176d148..0000000000000
--- a/llvm/test/Transforms/LoopVectorize/diag-vectorize-forced-only-msgs.ll
+++ /dev/null
@@ -1,46 +0,0 @@
-; This test checks that we emit only the correct debug messages and
-; optimization remark when the loop is not vectorized due to the 
-; vectorize-forced-only pass option being set.
-
-; REQUIRES: asserts
-; RUN: opt -passes='loop-vectorize<vectorize-forced-only>' \
-; RUN:   -pass-remarks=loop-vectorize \
-; RUN:   -pass-remarks-missed=loop-vectorize \
-; RUN:   -pass-remarks-analysis=loop-vectorize -debug -disable-output \
-; RUN:   < %s 2>&1 | FileCheck %s
-; CHECK-NOT: LV: We can vectorize this loop
-; CHECK-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
-; CHECK-NOT: LV: [BUG] Not vectorizing: loop vect disabled for an unknown reason
-; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable
-; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
-; CHECK-NOT: LV: Not vectorizing: Cannot prove legality
-; CHECK: LV: Loop hints: force=?
-; CHECK: LV: Not vectorizing: VectorizeOnlyWhenForced is set, and no #pragma vectorize enable
-; CHECK: remark:
-; CHECK-SAME: loop not vectorized: only vectorizing loops that explicitly request it
-; CHECK: LV: Loop hints prevent vectorization
-
-define double @CompareDistmats(ptr %distmat1, ptr %distmat2){
-entry:
-  br label %for.body
-
-for.cond.cleanup:                                 ; preds = %for.body
-  %add.lcssa = phi double [ %add, %for.body ]
-  %div = fmul fast double %add.lcssa, 0x3FB1111111111111
-  %0 = tail call fast double @llvm.sqrt.f64(double %div)
-  ret double %0
-
-for.body:                                         ; preds = %entry, %for.body
-  %i.014 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
-  %RMSD.013 = phi double [ 0.000000e+00, %entry ], [ %add, %for.body ]
-  %arrayidx = getelementptr inbounds nuw double, ptr %distmat1, i64 %i.014
-  %1 = load double, ptr %arrayidx, align 8
-  %arrayidx1 = getelementptr inbounds nuw double, ptr %distmat2, i64 %i.014
-  %2 = load double, ptr %arrayidx1, align 8
-  %sub = fsub fast double %1, %2
-  %mul = fmul fast double %sub, %sub
-  %add = fadd fast double %mul, %RMSD.013
-  %inc = add nuw nsw i64 %i.014, 1
-  %exitcond.not = icmp eq i64 %inc, 15
-  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
-}

>From 98a90e976957e3ac38d9a581fb12ee1af3c7a1c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tibor=20Gy=C5=91ri?= <tibor.gyori at chem.u-szeged.hu>
Date: Sat, 1 Nov 2025 07:35:35 +0100
Subject: [PATCH 11/34] Address IR review pt1: datalayout

Co-authored-by: Florian Hahn <flo at fhahn.com>
---
 .../test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll | 1 -
 1 file changed, 1 deletion(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
index 0a22bdb172584..c9b8ff6b10b1c 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
@@ -19,7 +19,6 @@
 ; CHECK: remark:
 ; CHECK-SAME: loop not vectorized: loop transformations are disabled
 ; CHECK: LV: Loop hints prevent vectorization
-target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 define void @disable_nonforced(ptr nocapture %a, i32 %n) {
 entry:
   %cmp4 = icmp sgt i32 %n, 0

>From 55af5ac968f0ca6c02eea436b90096df623ef68a Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 1 Nov 2025 09:11:12 +0100
Subject: [PATCH 12/34] Address IR review pt2: use llvm_unreachable

---
 llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 4df0c27a9ea24..ca791811849f3 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -197,13 +197,12 @@ bool LoopVectorizeHints::allowVectorization(
                << "loop not vectorized: loop transformations are disabled");
     } else {
       // This should be unreachable unless there is a bug.
-      LLVM_DEBUG(dbgs() << "LV: [BUG] Not vectorizing: loop vect disabled for "
-                           "an unknown reason!\n");
       ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedUnknown",
                                         TheLoop->getStartLoc(),
                                         TheLoop->getHeader())
                << "loop not vectorized: unknown reason, please file a bug "
                   "report on the LLVM issue tracker");
+      llvm_unreachable("loop vect disabled for an unknown reason");
     }
     return false;
   }

>From 120a5bf39baeff1aee66345cb9ec56a08abf6af8 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 1 Nov 2025 16:48:56 +0100
Subject: [PATCH 13/34] Address IR review pt3: only 1 load

---
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll       | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index 989bafa29745e..e509d3218f71a 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -43,7 +43,7 @@
 ; FORCEDONLY-SAME: loop not vectorized: only vectorizing loops that explicitly request it
 ; FORCEDONLY: LV: Loop hints prevent vectorization
 
-define double @CompareDistmats(ptr %distmat1, ptr %distmat2){
+define double @CompareDistmats(ptr %distmat1){
 entry:
   br label %for.body
 
@@ -58,9 +58,7 @@ for.body:                                         ; preds = %entry, %for.body
   %RMSD.013 = phi double [ 0.000000e+00, %entry ], [ %add, %for.body ]
   %arrayidx = getelementptr inbounds nuw double, ptr %distmat1, i64 %i.014
   %1 = load double, ptr %arrayidx, align 8
-  %arrayidx1 = getelementptr inbounds nuw double, ptr %distmat2, i64 %i.014
-  %2 = load double, ptr %arrayidx1, align 8
-  %sub = fsub fast double %1, %2
+  %sub = fsub fast double %1, 1.234e+0
   %mul = fmul fast double %sub, %sub
   %add = fadd fast double %mul, %RMSD.013
   %inc = add nuw nsw i64 %i.014, 1

>From a509ea91a1407004dc3a96cd5094f93829519026 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 1 Nov 2025 17:31:43 +0100
Subject: [PATCH 14/34] Address IR review pt4: exit block

---
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index e509d3218f71a..a908dbe2c153e 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -47,12 +47,6 @@ define double @CompareDistmats(ptr %distmat1){
 entry:
   br label %for.body
 
-for.cond.cleanup:                                 ; preds = %for.body
-  %add.lcssa = phi double [ %add, %for.body ]
-  %div = fmul fast double %add.lcssa, 0x3FB1111111111111
-  %0 = tail call fast double @llvm.sqrt.f64(double %div)
-  ret double %0
-
 for.body:                                         ; preds = %entry, %for.body
   %i.014 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
   %RMSD.013 = phi double [ 0.000000e+00, %entry ], [ %add, %for.body ]
@@ -63,7 +57,10 @@ for.body:                                         ; preds = %entry, %for.body
   %add = fadd fast double %mul, %RMSD.013
   %inc = add nuw nsw i64 %i.014, 1
   %exitcond.not = icmp eq i64 %inc, 15
-  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body, !llvm.loop !0
+  br i1 %exitcond.not, label %exit, label %for.body, !llvm.loop !0
+
+exit:
+  ret double %add
 }
 
 !0 = distinct !{!0, !1}

>From bc685717842322483a5e2e7516b045cdff22654d Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 1 Nov 2025 19:47:07 +0100
Subject: [PATCH 15/34] Refactor the printing of the new messages

---
 .../Vectorize/LoopVectorizationLegality.h     |  8 ++++
 .../Vectorize/LoopVectorizationLegality.cpp   | 46 +++++++++----------
 2 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
index 405d4a742f37b..fc75c698bd881 100644
--- a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
@@ -196,6 +196,14 @@ class LoopVectorizeHints {
 
   /// Interface to emit optimization remarks.
   OptimizationRemarkEmitter &ORE;
+
+  /// Reports a condition where loop vectorization is disallowed: prints
+  /// \p DebugMsg for debugging purposes along with the corresponding
+  /// optimization remark \p RemarkName , with \p RemarkMsg as the user-facing
+  /// message. The loop \p L is used for the location of the remark.
+  void LoopVectorizeHints::reportDisallowedVectorization(
+      const StringRef DebugMsg, const StringRef RemarkName,
+      const StringRef RemarkMsg, const Loop *L) const;
 };
 
 /// This holds vectorization requirements that must be verified late in
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index ca791811849f3..3b4ea35a5f20b 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -179,42 +179,40 @@ void LoopVectorizeHints::setAlreadyVectorized() {
   IsVectorized.Value = 1;
 }
 
+void LoopVectorizeHints::reportDisallowedVectorization(
+    const StringRef DebugMsg, const StringRef RemarkName,
+    const StringRef RemarkMsg, const Loop *L) const {
+  LLVM_DEBUG(dbgs() << "LV: Not vectorizing: " << DebugMsg << ".\n");
+  ORE.emit(OptimizationRemarkMissed(LV_NAME, RemarkName, L->getStartLoc(),
+                                    L->getHeader())
+           << "loop not vectorized: " << RemarkMsg);
+}
+
 bool LoopVectorizeHints::allowVectorization(
     Function *F, Loop *L, bool VectorizeOnlyWhenForced) const {
   if (getForce() == LoopVectorizeHints::FK_Disabled) {
     if (Force.Value == LoopVectorizeHints::FK_Disabled) {
-      LLVM_DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n");
-      ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedExplicitlyDisabled",
-                                        TheLoop->getStartLoc(),
-                                        TheLoop->getHeader())
-               << "loop not vectorized: vectorization is explicitly disabled");
-    } else if (hasDisableAllTransformsHint(TheLoop)) {
-      LLVM_DEBUG(
-          dbgs() << "LV: Not vectorizing: loop hasDisableAllTransformsHint.\n");
-      ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedTransformsDisabled",
-                                        TheLoop->getStartLoc(),
-                                        TheLoop->getHeader())
-               << "loop not vectorized: loop transformations are disabled");
+      reportDisallowedVectorization("#pragma vectorize disable",
+                                    "MissedExplicitlyDisabled",
+                                    "vectorization is explicitly disabled");
+    } else if (hasDisableAllTransformsHint(L)) {
+      reportDisallowedVectorization("loop hasDisableAllTransformsHint",
+                                    "MissedTransformsDisabled",
+                                    "loop transformations are disabled");
     } else {
       // This should be unreachable unless there is a bug.
-      ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedUnknown",
-                                        TheLoop->getStartLoc(),
-                                        TheLoop->getHeader())
-               << "loop not vectorized: unknown reason, please file a bug "
-                  "report on the LLVM issue tracker");
+      reportDisallowedVectorization(
+          "disabled for an unknown reason", "MissedUnknown",
+          "unknown reason, please file a bug report on the LLVM issue tracker");
       llvm_unreachable("loop vect disabled for an unknown reason");
     }
     return false;
   }
 
   if (VectorizeOnlyWhenForced && getForce() != LoopVectorizeHints::FK_Enabled) {
-    LLVM_DEBUG(dbgs() << "LV: Not vectorizing: VectorizeOnlyWhenForced is set, "
-                         "and no #pragma vectorize enable.\n");
-    ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedForceOnly",
-                                      TheLoop->getStartLoc(),
-                                      TheLoop->getHeader())
-             << "loop not vectorized: only vectorizing loops that "
-                "explicitly request it");
+    reportDisallowedVectorization(
+        "VectorizeOnlyWhenForced is set, and no #pragma vectorize enable",
+        "MissedForceOnly", "only vectorizing loops that explicitly request it");
     return false;
   }
 

>From c6a624d83b89fa95415bb708f09a0b919330a144 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 1 Nov 2025 20:26:57 +0100
Subject: [PATCH 16/34] fix

---
 .../Transforms/Vectorize/LoopVectorizationLegality.h   |  7 ++++---
 .../Transforms/Vectorize/LoopVectorizationLegality.cpp | 10 ++++++----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
index fc75c698bd881..971e4a6b0a33e 100644
--- a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
@@ -201,9 +201,10 @@ class LoopVectorizeHints {
   /// \p DebugMsg for debugging purposes along with the corresponding
   /// optimization remark \p RemarkName , with \p RemarkMsg as the user-facing
   /// message. The loop \p L is used for the location of the remark.
-  void LoopVectorizeHints::reportDisallowedVectorization(
-      const StringRef DebugMsg, const StringRef RemarkName,
-      const StringRef RemarkMsg, const Loop *L) const;
+  void reportDisallowedVectorization(const StringRef DebugMsg,
+                                     const StringRef RemarkName,
+                                     const StringRef RemarkMsg,
+                                     const Loop *L) const;
 };
 
 /// This holds vectorization requirements that must be verified late in
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 3b4ea35a5f20b..a9216c1dcf080 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -194,16 +194,17 @@ bool LoopVectorizeHints::allowVectorization(
     if (Force.Value == LoopVectorizeHints::FK_Disabled) {
       reportDisallowedVectorization("#pragma vectorize disable",
                                     "MissedExplicitlyDisabled",
-                                    "vectorization is explicitly disabled");
+                                    "vectorization is explicitly disabled", L);
     } else if (hasDisableAllTransformsHint(L)) {
       reportDisallowedVectorization("loop hasDisableAllTransformsHint",
                                     "MissedTransformsDisabled",
-                                    "loop transformations are disabled");
+                                    "loop transformations are disabled", L);
     } else {
       // This should be unreachable unless there is a bug.
       reportDisallowedVectorization(
           "disabled for an unknown reason", "MissedUnknown",
-          "unknown reason, please file a bug report on the LLVM issue tracker");
+          "unknown reason, please file a bug report on the LLVM issue tracker",
+          L);
       llvm_unreachable("loop vect disabled for an unknown reason");
     }
     return false;
@@ -212,7 +213,8 @@ bool LoopVectorizeHints::allowVectorization(
   if (VectorizeOnlyWhenForced && getForce() != LoopVectorizeHints::FK_Enabled) {
     reportDisallowedVectorization(
         "VectorizeOnlyWhenForced is set, and no #pragma vectorize enable",
-        "MissedForceOnly", "only vectorizing loops that explicitly request it");
+        "MissedForceOnly", "only vectorizing loops that explicitly request it",
+        L);
     return false;
   }
 

>From d4f407b426e2dfe1a5c187a0ca8eed8f86d2817c Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 1 Nov 2025 21:47:34 +0100
Subject: [PATCH 17/34] update message in tests

---
 .../Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll   | 2 +-
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll         | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
index c9b8ff6b10b1c..bcfff9ce6ca9e 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
@@ -10,7 +10,7 @@
 ; RUN:     < %s 2>&1 | FileCheck %s
 ; CHECK-NOT: LV: We can vectorize this loop
 ; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable.
-; CHECK-NOT: LV: [BUG] Not vectorizing: loop vect disabled for an unknown reason
+; CHECK-NOT: LV: Not vectorizing: disabled for an unknown reason
 ; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
 ; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
 ; CHECK-NOT: LV: Not vectorizing: Cannot prove legality
diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index a908dbe2c153e..a89dd5ee9a29a 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -9,7 +9,7 @@
 ; RUN:     < %s 2>&1 | FileCheck --check-prefix=METADATA %s
 ; METADATA-NOT: LV: We can vectorize this loop
 ; METADATA-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
-; METADATA-NOT: LV: [BUG] Not vectorizing: loop vect disabled for an unknown reason
+; METADATA-NOT: LV: Not vectorizing: disabled for an unknown reason
 ; METADATA-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
 ; METADATA-NOT: LV: Not vectorizing: Disabled/already vectorized
 ; METADATA-NOT: LV: Not vectorizing: Cannot prove legality
@@ -33,7 +33,7 @@
 ; RUN:   2>&1 | FileCheck --check-prefix=FORCEDONLY %s
 ; FORCEDONLY-NOT: LV: We can vectorize this loop
 ; FORCEDONLY-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
-; FORCEDONLY-NOT: LV: [BUG] Not vectorizing: loop vect disabled for an unknown reason
+; FORCEDONLY-NOT: LV: Not vectorizing: disabled for an unknown reason
 ; FORCEDONLY-NOT: LV: Not vectorizing: #pragma vectorize disable
 ; FORCEDONLY-NOT: LV: Not vectorizing: Disabled/already vectorized
 ; FORCEDONLY-NOT: LV: Not vectorizing: Cannot prove legality

>From 5d656e888a4e37787b9aea3a32dcf5c0068307c8 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 1 Nov 2025 21:51:01 +0100
Subject: [PATCH 18/34] give test fn a more descriptive name

---
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index a89dd5ee9a29a..bc7ac91cfe77e 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -43,7 +43,7 @@
 ; FORCEDONLY-SAME: loop not vectorized: only vectorizing loops that explicitly request it
 ; FORCEDONLY: LV: Loop hints prevent vectorization
 
-define double @CompareDistmats(ptr %distmat1){
+define double @disabled_loop_vectorization(ptr %distmat1){
 entry:
   br label %for.body
 

>From 0a933b224e40e0714c75f8d54ce5667cf79f41f6 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 1 Nov 2025 21:59:33 +0100
Subject: [PATCH 19/34] Address IR review pt5: simplify entry block of
 disable_nonforced

---
 .../Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll    | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
index bcfff9ce6ca9e..3159b97adbbae 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
@@ -21,8 +21,7 @@
 ; CHECK: LV: Loop hints prevent vectorization
 define void @disable_nonforced(ptr nocapture %a, i32 %n) {
 entry:
-  %cmp4 = icmp sgt i32 %n, 0
-  br i1 %cmp4, label %for.body, label %for.end
+  br label %for.body
 
 for.body:
   %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]

>From 6dfffe8f6ad73a9fbc3265eaec70c284913cf76f Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 1 Nov 2025 22:51:28 +0100
Subject: [PATCH 20/34] Address IR review pt6: simplify some variable and label
 names

---
 .../diag-disabled-vectorization-msgs.ll          | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index bc7ac91cfe77e..a3a11aae2918d 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -45,19 +45,19 @@
 
 define double @disabled_loop_vectorization(ptr %distmat1){
 entry:
-  br label %for.body
+  br label %loop
 
-for.body:                                         ; preds = %entry, %for.body
-  %i.014 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
-  %RMSD.013 = phi double [ 0.000000e+00, %entry ], [ %add, %for.body ]
-  %arrayidx = getelementptr inbounds nuw double, ptr %distmat1, i64 %i.014
+loop:
+  %iv = phi i64 [ 0, %entry ], [ %inc, %loop ]
+  %RMSD = phi double [ 0.000000e+00, %entry ], [ %add, %loop ]
+  %arrayidx = getelementptr inbounds nuw double, ptr %distmat1, i64 %iv
   %1 = load double, ptr %arrayidx, align 8
   %sub = fsub fast double %1, 1.234e+0
   %mul = fmul fast double %sub, %sub
-  %add = fadd fast double %mul, %RMSD.013
-  %inc = add nuw nsw i64 %i.014, 1
+  %add = fadd fast double %mul, %RMSD
+  %inc = add nuw nsw i64 %iv, 1
   %exitcond.not = icmp eq i64 %inc, 15
-  br i1 %exitcond.not, label %exit, label %for.body, !llvm.loop !0
+  br i1 %exitcond.not, label %exit, label %loop, !llvm.loop !0
 
 exit:
   ret double %add

>From 936d9e37251f2f2a8e26a0afb9c04f118c758e84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tibor=20Gy=C5=91ri?= <tibor.gyori at chem.u-szeged.hu>
Date: Fri, 7 Nov 2025 17:42:55 +0100
Subject: [PATCH 21/34] Apply suggestions from code review

Co-authored-by: Florian Hahn <flo at fhahn.com>
---
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll         | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index a3a11aae2918d..ced36f91e662f 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -43,13 +43,13 @@
 ; FORCEDONLY-SAME: loop not vectorized: only vectorizing loops that explicitly request it
 ; FORCEDONLY: LV: Loop hints prevent vectorization
 
-define double @disabled_loop_vectorization(ptr %distmat1){
+define double @disabled_loop_vectorization(ptr %src) {
 entry:
   br label %loop
 
 loop:
   %iv = phi i64 [ 0, %entry ], [ %inc, %loop ]
-  %RMSD = phi double [ 0.000000e+00, %entry ], [ %add, %loop ]
+  %rdx = phi double [ 0.000000e+00, %entry ], [ %add, %loop ]
   %arrayidx = getelementptr inbounds nuw double, ptr %distmat1, i64 %iv
   %1 = load double, ptr %arrayidx, align 8
   %sub = fsub fast double %1, 1.234e+0

>From b895a97b01775629843fb842bf51d55e648b7fdd Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Fri, 7 Nov 2025 17:46:33 +0100
Subject: [PATCH 22/34] update check-nots as the message was removed in favor
 of llvm_unreachable

---
 .../Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll     | 1 -
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll           | 2 --
 2 files changed, 3 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
index 3159b97adbbae..2c8c3293168e4 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
@@ -10,7 +10,6 @@
 ; RUN:     < %s 2>&1 | FileCheck %s
 ; CHECK-NOT: LV: We can vectorize this loop
 ; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable.
-; CHECK-NOT: LV: Not vectorizing: disabled for an unknown reason
 ; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
 ; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
 ; CHECK-NOT: LV: Not vectorizing: Cannot prove legality
diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index ced36f91e662f..fa9ab6578e23e 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -9,7 +9,6 @@
 ; RUN:     < %s 2>&1 | FileCheck --check-prefix=METADATA %s
 ; METADATA-NOT: LV: We can vectorize this loop
 ; METADATA-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
-; METADATA-NOT: LV: Not vectorizing: disabled for an unknown reason
 ; METADATA-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
 ; METADATA-NOT: LV: Not vectorizing: Disabled/already vectorized
 ; METADATA-NOT: LV: Not vectorizing: Cannot prove legality
@@ -33,7 +32,6 @@
 ; RUN:   2>&1 | FileCheck --check-prefix=FORCEDONLY %s
 ; FORCEDONLY-NOT: LV: We can vectorize this loop
 ; FORCEDONLY-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
-; FORCEDONLY-NOT: LV: Not vectorizing: disabled for an unknown reason
 ; FORCEDONLY-NOT: LV: Not vectorizing: #pragma vectorize disable
 ; FORCEDONLY-NOT: LV: Not vectorizing: Disabled/already vectorized
 ; FORCEDONLY-NOT: LV: Not vectorizing: Cannot prove legality

>From 8173da8023be4ce46647ad1d99b8f78e2c5c8eb1 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Fri, 7 Nov 2025 18:13:54 +0100
Subject: [PATCH 23/34] fix test

---
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll         | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index fa9ab6578e23e..0741cb94e6535 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -48,11 +48,11 @@ entry:
 loop:
   %iv = phi i64 [ 0, %entry ], [ %inc, %loop ]
   %rdx = phi double [ 0.000000e+00, %entry ], [ %add, %loop ]
-  %arrayidx = getelementptr inbounds nuw double, ptr %distmat1, i64 %iv
+  %arrayidx = getelementptr inbounds nuw double, ptr %src, i64 %iv
   %1 = load double, ptr %arrayidx, align 8
   %sub = fsub fast double %1, 1.234e+0
   %mul = fmul fast double %sub, %sub
-  %add = fadd fast double %mul, %RMSD
+  %add = fadd fast double %mul, %rdx
   %inc = add nuw nsw i64 %iv, 1
   %exitcond.not = icmp eq i64 %inc, 15
   br i1 %exitcond.not, label %exit, label %loop, !llvm.loop !0

>From 835f8f04a564ad3558d786cb76672682c9c89f0c Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Fri, 7 Nov 2025 18:35:49 +0100
Subject: [PATCH 24/34] try simplifying disabled_loop_vectorization test fn to
 constant store

---
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll     | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index 0741cb94e6535..42f0d798ffa37 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -47,18 +47,14 @@ entry:
 
 loop:
   %iv = phi i64 [ 0, %entry ], [ %inc, %loop ]
-  %rdx = phi double [ 0.000000e+00, %entry ], [ %add, %loop ]
   %arrayidx = getelementptr inbounds nuw double, ptr %src, i64 %iv
-  %1 = load double, ptr %arrayidx, align 8
-  %sub = fsub fast double %1, 1.234e+0
-  %mul = fmul fast double %sub, %sub
-  %add = fadd fast double %mul, %rdx
+  store double 1.234e+0, ptr %arrayidx, align 8
   %inc = add nuw nsw i64 %iv, 1
   %exitcond.not = icmp eq i64 %inc, 15
   br i1 %exitcond.not, label %exit, label %loop, !llvm.loop !0
 
 exit:
-  ret double %add
+  ret i64 0
 }
 
 !0 = distinct !{!0, !1}

>From 7f9fe50bec2e0dc5208b24b46dc07420f227c8d8 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Fri, 7 Nov 2025 19:30:01 +0100
Subject: [PATCH 25/34] fix return type

---
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index 42f0d798ffa37..b3b555bb11e8d 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -41,7 +41,7 @@
 ; FORCEDONLY-SAME: loop not vectorized: only vectorizing loops that explicitly request it
 ; FORCEDONLY: LV: Loop hints prevent vectorization
 
-define double @disabled_loop_vectorization(ptr %src) {
+define i64 @disabled_loop_vectorization(ptr %src) {
 entry:
   br label %loop
 

>From 552a8ab0dd78dc2cae247c936baeec7fdfc54d71 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Fri, 7 Nov 2025 21:46:16 +0100
Subject: [PATCH 26/34] try moving Test3 into the same file as Test 1&2

---
 .../diag-disable_nonforced-msgs.ll            | 39 ------------------
 .../diag-disabled-vectorization-msgs.ll       | 40 +++++++++++++++++++
 2 files changed, 40 insertions(+), 39 deletions(-)
 delete mode 100644 llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
deleted file mode 100644
index 2c8c3293168e4..0000000000000
--- a/llvm/test/Transforms/LoopVectorize/diag-disable_nonforced-msgs.ll
+++ /dev/null
@@ -1,39 +0,0 @@
-; This test checks that we emit only the correct debug messages and
-; optimization remark when the loop vectorizer is disabled by loop metadata
-; that requests no loop transformations.
-
-; REQUIRES: asserts
-; RUN: opt -passes=loop-vectorize -pass-remarks=loop-vectorize \
-; RUN:     -pass-remarks-missed=loop-vectorize \
-; RUN:     -pass-remarks-analysis=loop-vectorize -debug -disable-output \
-; RUN:     -force-vector-interleave=1 -force-vector-width=2 \
-; RUN:     < %s 2>&1 | FileCheck %s
-; CHECK-NOT: LV: We can vectorize this loop
-; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable.
-; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
-; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
-; CHECK-NOT: LV: Not vectorizing: Cannot prove legality
-; CHECK: LV: Loop hints: force=disabled
-; CHECK: LV: Not vectorizing: loop hasDisableAllTransformsHint.
-; CHECK: remark:
-; CHECK-SAME: loop not vectorized: loop transformations are disabled
-; CHECK: LV: Loop hints prevent vectorization
-define void @disable_nonforced(ptr nocapture %a, i32 %n) {
-entry:
-  br label %for.body
-
-for.body:
-  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
-  %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
-  %0 = trunc i64 %indvars.iv to i32
-  store i32 %0, ptr %arrayidx, align 4
-  %indvars.iv.next = add i64 %indvars.iv, 1
-  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
-  %exitcond = icmp eq i32 %lftr.wideiv, %n
-  br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0
-
-for.end:
-  ret void
-}
-
-!0 = !{!0, !{!"llvm.loop.disable_nonforced"}}
diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index b3b555bb11e8d..aacb0ce5191a8 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -59,3 +59,43 @@ exit:
 
 !0 = distinct !{!0, !1}
 !1 = !{!"llvm.loop.vectorize.enable", i1 false}
+
+; TEST 3
+; This test checks that we emit only the correct debug messages and
+; optimization remark when the loop vectorizer is disabled by loop metadata
+; that requests no loop transformations.
+
+; RUN: opt -passes=loop-vectorize -pass-remarks=loop-vectorize \
+; RUN:     -pass-remarks-missed=loop-vectorize \
+; RUN:     -pass-remarks-analysis=loop-vectorize -debug -disable-output \
+; RUN:     -force-vector-interleave=1 -force-vector-width=2 \
+; RUN:     < %s 2>&1 | FileCheck %s
+; CHECK-NOT: LV: We can vectorize this loop
+; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable.
+; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
+; CHECK-NOT: LV: Not vectorizing: Disabled/already vectorized
+; CHECK-NOT: LV: Not vectorizing: Cannot prove legality
+; CHECK: LV: Loop hints: force=disabled
+; CHECK: LV: Not vectorizing: loop hasDisableAllTransformsHint.
+; CHECK: remark:
+; CHECK-SAME: loop not vectorized: loop transformations are disabled
+; CHECK: LV: Loop hints prevent vectorization
+define void @disable_nonforced(ptr nocapture %a, i32 %n) {
+entry:
+  br label %for.body
+
+for.body:
+  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
+  %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
+  %0 = trunc i64 %indvars.iv to i32
+  store i32 %0, ptr %arrayidx, align 4
+  %indvars.iv.next = add i64 %indvars.iv, 1
+  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
+  %exitcond = icmp eq i32 %lftr.wideiv, %n
+  br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !2
+
+for.end:
+  ret void
+}
+
+!2 = !{!2, !{!"llvm.loop.disable_nonforced"}}

>From dcd926fc0f2c03cc3b9a99b959eb84b08419e9e1 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 8 Nov 2025 00:25:17 +0100
Subject: [PATCH 27/34] somehow a suggestion did not apply

---
 llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index a9216c1dcf080..c0e7f308a72e7 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -200,11 +200,6 @@ bool LoopVectorizeHints::allowVectorization(
                                     "MissedTransformsDisabled",
                                     "loop transformations are disabled", L);
     } else {
-      // This should be unreachable unless there is a bug.
-      reportDisallowedVectorization(
-          "disabled for an unknown reason", "MissedUnknown",
-          "unknown reason, please file a bug report on the LLVM issue tracker",
-          L);
       llvm_unreachable("loop vect disabled for an unknown reason");
     }
     return false;

>From 86515c5c82c7f503663a6cd7d02b722e6e14e6d1 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Mon, 10 Nov 2025 22:41:04 +0100
Subject: [PATCH 28/34] More reviewer suggestions, pt1

---
 .../llvm/Transforms/Vectorize/LoopVectorizationLegality.h   | 2 +-
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll       | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
index 971e4a6b0a33e..5e8cccef703b2 100644
--- a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
@@ -199,7 +199,7 @@ class LoopVectorizeHints {
 
   /// Reports a condition where loop vectorization is disallowed: prints
   /// \p DebugMsg for debugging purposes along with the corresponding
-  /// optimization remark \p RemarkName , with \p RemarkMsg as the user-facing
+  /// optimization remark \p RemarkName, with \p RemarkMsg as the user-facing
   /// message. The loop \p L is used for the location of the remark.
   void reportDisallowedVectorization(const StringRef DebugMsg,
                                      const StringRef RemarkName,
diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index aacb0ce5191a8..023533bf498a8 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -41,20 +41,20 @@
 ; FORCEDONLY-SAME: loop not vectorized: only vectorizing loops that explicitly request it
 ; FORCEDONLY: LV: Loop hints prevent vectorization
 
-define i64 @disabled_loop_vectorization(ptr %src) {
+define void @disabled_loop_vectorization(ptr %src) {
 entry:
   br label %loop
 
 loop:
   %iv = phi i64 [ 0, %entry ], [ %inc, %loop ]
   %arrayidx = getelementptr inbounds nuw double, ptr %src, i64 %iv
-  store double 1.234e+0, ptr %arrayidx, align 8
+  store double 0, ptr %arrayidx, align 8
   %inc = add nuw nsw i64 %iv, 1
   %exitcond.not = icmp eq i64 %inc, 15
   br i1 %exitcond.not, label %exit, label %loop, !llvm.loop !0
 
 exit:
-  ret i64 0
+  ret void
 }
 
 !0 = distinct !{!0, !1}

>From 5f7c8b0db2919e7af538e4a9189617b3f2612b47 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Mon, 10 Nov 2025 22:47:02 +0100
Subject: [PATCH 29/34] use CHECK-LABEL

---
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll          | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index 023533bf498a8..256307e3dfca9 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -7,6 +7,7 @@
 ; RUN:     -pass-remarks-missed=loop-vectorize \
 ; RUN:     -pass-remarks-analysis=loop-vectorize -debug -disable-output \
 ; RUN:     < %s 2>&1 | FileCheck --check-prefix=METADATA %s
+; METADATA-LABEL: disabled_loop_vectorization:
 ; METADATA-NOT: LV: We can vectorize this loop
 ; METADATA-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
 ; METADATA-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
@@ -30,6 +31,7 @@
 ; RUN:   -pass-remarks-missed=loop-vectorize \
 ; RUN:   -pass-remarks-analysis=loop-vectorize -debug -disable-output \
 ; RUN:   2>&1 | FileCheck --check-prefix=FORCEDONLY %s
+; FORCEDONLY-LABEL: disabled_loop_vectorization:
 ; FORCEDONLY-NOT: LV: We can vectorize this loop
 ; FORCEDONLY-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
 ; FORCEDONLY-NOT: LV: Not vectorizing: #pragma vectorize disable
@@ -70,6 +72,7 @@ exit:
 ; RUN:     -pass-remarks-analysis=loop-vectorize -debug -disable-output \
 ; RUN:     -force-vector-interleave=1 -force-vector-width=2 \
 ; RUN:     < %s 2>&1 | FileCheck %s
+; CHECK-LABEL: disable_nonforced:
 ; CHECK-NOT: LV: We can vectorize this loop
 ; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable.
 ; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set

>From 96d613630054a4964980c1fb5c7f7e460890bb6d Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Mon, 10 Nov 2025 23:25:58 +0100
Subject: [PATCH 30/34] fix check-label

---
 .../diag-disabled-vectorization-msgs.ll       | 26 +++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index 256307e3dfca9..2d259b3b5e0fe 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -3,11 +3,11 @@
 ; optimization remark when the loop vectorizer is disabled by loop metadata.
 
 ; REQUIRES: asserts
-; RUN: opt -passes=loop-vectorize -pass-remarks=loop-vectorize \
+; RUN: opt -S -passes=loop-vectorize -pass-remarks=loop-vectorize \
 ; RUN:     -pass-remarks-missed=loop-vectorize \
-; RUN:     -pass-remarks-analysis=loop-vectorize -debug -disable-output \
-; RUN:     < %s 2>&1 | FileCheck --check-prefix=METADATA %s
-; METADATA-LABEL: disabled_loop_vectorization:
+; RUN:     -pass-remarks-analysis=loop-vectorize -debug \
+; RUN:     < %s 2>&1 | FileCheck --dump-input=always --check-prefix=METADATA %s
+; METADATA-LABEL: 'disabled_loop_vectorization' from <stdin>
 ; METADATA-NOT: LV: We can vectorize this loop
 ; METADATA-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
 ; METADATA-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
@@ -26,12 +26,12 @@
 
 ; Strip metadata for FORCEDONLY run, keep it for METADATA run
 ; RUN: sed 's/,[[:space:]]*!llvm\.loop[[:space:]]*!0//' %s | \
-; RUN: opt -passes='loop-vectorize<vectorize-forced-only>' \
+; RUN: opt -S -passes='loop-vectorize<vectorize-forced-only>' \
 ; RUN:   -pass-remarks=loop-vectorize \
 ; RUN:   -pass-remarks-missed=loop-vectorize \
-; RUN:   -pass-remarks-analysis=loop-vectorize -debug -disable-output \
-; RUN:   2>&1 | FileCheck --check-prefix=FORCEDONLY %s
-; FORCEDONLY-LABEL: disabled_loop_vectorization:
+; RUN:   -pass-remarks-analysis=loop-vectorize -debug \
+; RUN:   2>&1 | FileCheck --dump-input=always --check-prefix=FORCEDONLY %s
+; FORCEDONLY-LABEL: 'disabled_loop_vectorization' from <stdin>
 ; FORCEDONLY-NOT: LV: We can vectorize this loop
 ; FORCEDONLY-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
 ; FORCEDONLY-NOT: LV: Not vectorizing: #pragma vectorize disable
@@ -50,7 +50,7 @@ entry:
 loop:
   %iv = phi i64 [ 0, %entry ], [ %inc, %loop ]
   %arrayidx = getelementptr inbounds nuw double, ptr %src, i64 %iv
-  store double 0, ptr %arrayidx, align 8
+  store double 0.0, ptr %arrayidx, align 8
   %inc = add nuw nsw i64 %iv, 1
   %exitcond.not = icmp eq i64 %inc, 15
   br i1 %exitcond.not, label %exit, label %loop, !llvm.loop !0
@@ -67,12 +67,12 @@ exit:
 ; optimization remark when the loop vectorizer is disabled by loop metadata
 ; that requests no loop transformations.
 
-; RUN: opt -passes=loop-vectorize -pass-remarks=loop-vectorize \
+; RUN: opt -S -passes=loop-vectorize -pass-remarks=loop-vectorize \
 ; RUN:     -pass-remarks-missed=loop-vectorize \
-; RUN:     -pass-remarks-analysis=loop-vectorize -debug -disable-output \
+; RUN:     -pass-remarks-analysis=loop-vectorize -debug \
 ; RUN:     -force-vector-interleave=1 -force-vector-width=2 \
-; RUN:     < %s 2>&1 | FileCheck %s
-; CHECK-LABEL: disable_nonforced:
+; RUN:     < %s 2>&1 | FileCheck --dump-input=always %s
+; CHECK-LABEL: 'disable_nonforced' from <stdin>
 ; CHECK-NOT: LV: We can vectorize this loop
 ; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable.
 ; CHECK-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set

>From 6c1932e5be7da75b09950bc130d937049ef034e9 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 15 Nov 2025 20:22:46 +0100
Subject: [PATCH 31/34] shorten loop control flow labels

---
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll  | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index 2d259b3b5e0fe..c2042d25a24b5 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -85,19 +85,19 @@ exit:
 ; CHECK: LV: Loop hints prevent vectorization
 define void @disable_nonforced(ptr nocapture %a, i32 %n) {
 entry:
-  br label %for.body
+  br label %loop
 
-for.body:
-  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
+loop:
+  %indvars.iv = phi i64 [ %indvars.iv.next, %loop ], [ 0, %entry ]
   %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
   %0 = trunc i64 %indvars.iv to i32
   store i32 %0, ptr %arrayidx, align 4
   %indvars.iv.next = add i64 %indvars.iv, 1
   %lftr.wideiv = trunc i64 %indvars.iv.next to i32
   %exitcond = icmp eq i32 %lftr.wideiv, %n
-  br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !2
+  br i1 %exitcond, label %end, label %loop, !llvm.loop !2
 
-for.end:
+end:
   ret void
 }
 

>From 8e0c12b4e50502dd20ea703d0a616008c467f6d1 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 15 Nov 2025 20:30:30 +0100
Subject: [PATCH 32/34] shorten %indvars.iv to %iv, make it 32 bits to remove
 truncates and simplify the test IR

---
 .../diag-disabled-vectorization-msgs.ll              | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index c2042d25a24b5..5b0500c17a384 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -88,13 +88,11 @@ entry:
   br label %loop
 
 loop:
-  %indvars.iv = phi i64 [ %indvars.iv.next, %loop ], [ 0, %entry ]
-  %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
-  %0 = trunc i64 %indvars.iv to i32
-  store i32 %0, ptr %arrayidx, align 4
-  %indvars.iv.next = add i64 %indvars.iv, 1
-  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
-  %exitcond = icmp eq i32 %lftr.wideiv, %n
+  %iv = phi i32 [ %iv.next, %loop ], [ 0, %entry ]
+  %arrayidx = getelementptr inbounds i32, ptr %a, i32 %iv
+  store i32 %iv, ptr %arrayidx, align 4
+  %iv.next = add i32 %iv, 1
+  %exitcond = icmp eq i32 %iv.next, %n
   br i1 %exitcond, label %end, label %loop, !llvm.loop !2
 
 end:

>From 1ec46e8e1db9695b6a2e9d1285a9024766b2afb0 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Sat, 15 Nov 2025 22:14:52 +0100
Subject: [PATCH 33/34] group all RUN lines at the top, reduce check
 duplication between Test 1&2

---
 .../diag-disabled-vectorization-msgs.ll       | 68 ++++++++-----------
 1 file changed, 30 insertions(+), 38 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index 5b0500c17a384..fca0ff7191851 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -1,48 +1,52 @@
+; REQUIRES: asserts
+
 ; TEST 1
-; This test checks that we emit only the correct debug messages and
+; Checks that we emit only the correct debug messages and
 ; optimization remark when the loop vectorizer is disabled by loop metadata.
-
-; REQUIRES: asserts
 ; RUN: opt -S -passes=loop-vectorize -pass-remarks=loop-vectorize \
 ; RUN:     -pass-remarks-missed=loop-vectorize \
 ; RUN:     -pass-remarks-analysis=loop-vectorize -debug \
-; RUN:     < %s 2>&1 | FileCheck --dump-input=always --check-prefix=METADATA %s
-; METADATA-LABEL: 'disabled_loop_vectorization' from <stdin>
-; METADATA-NOT: LV: We can vectorize this loop
-; METADATA-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
-; METADATA-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
-; METADATA-NOT: LV: Not vectorizing: Disabled/already vectorized
-; METADATA-NOT: LV: Not vectorizing: Cannot prove legality
-; METADATA: LV: Loop hints: force=disabled
-; METADATA: LV: Not vectorizing: #pragma vectorize disable.
-; METADATA: remark:
-; METADATA-SAME: loop not vectorized: vectorization is explicitly disabled
-; METADATA: LV: Loop hints prevent vectorization
-
+; RUN:     < %s 2>&1 | FileCheck --dump-input=always --check-prefixes=METADATA,BOTH %s
 ; TEST 2
-; This test checks that we emit only the correct debug messages and
+; Checks that we emit only the correct debug messages and
 ; optimization remark when the loop is not vectorized due to the 
 ; vectorize-forced-only pass option being set.
-
 ; Strip metadata for FORCEDONLY run, keep it for METADATA run
 ; RUN: sed 's/,[[:space:]]*!llvm\.loop[[:space:]]*!0//' %s | \
 ; RUN: opt -S -passes='loop-vectorize<vectorize-forced-only>' \
 ; RUN:   -pass-remarks=loop-vectorize \
 ; RUN:   -pass-remarks-missed=loop-vectorize \
 ; RUN:   -pass-remarks-analysis=loop-vectorize -debug \
-; RUN:   2>&1 | FileCheck --dump-input=always --check-prefix=FORCEDONLY %s
-; FORCEDONLY-LABEL: 'disabled_loop_vectorization' from <stdin>
-; FORCEDONLY-NOT: LV: We can vectorize this loop
-; FORCEDONLY-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
+; RUN:   2>&1 | FileCheck --dump-input=always --check-prefixes=FORCEDONLY,BOTH %s
+; TEST 3
+; Checks that we emit only the correct debug messages and
+; optimization remark when the loop vectorizer is disabled by loop metadata
+; that requests no loop transformations.
+; RUN: opt -S -passes=loop-vectorize -pass-remarks=loop-vectorize \
+; RUN:     -pass-remarks-missed=loop-vectorize \
+; RUN:     -pass-remarks-analysis=loop-vectorize -debug \
+; RUN:     -force-vector-interleave=1 -force-vector-width=2 \
+; RUN:     < %s 2>&1 | FileCheck --dump-input=always %s
+
+; BOTH-LABEL: 'disabled_loop_vectorization' from <stdin>
+; BOTH-NOT: LV: We can vectorize this loop
+; BOTH-NOT: LV: Not vectorizing: loop hasDisableAllTransformsHint
+; BOTH-NOT: LV: Not vectorizing: Disabled/already vectorized
+; BOTH-NOT: LV: Not vectorizing: Cannot prove legality
+;
+; METADATA-NOT: LV: Not vectorizing: VectorizeOnlyWhenForced is set
+; METADATA: LV: Loop hints: force=disabled
+; METADATA: LV: Not vectorizing: #pragma vectorize disable.
+; METADATA: remark:
+; METADATA-SAME: loop not vectorized: vectorization is explicitly disabled
+;
 ; FORCEDONLY-NOT: LV: Not vectorizing: #pragma vectorize disable
-; FORCEDONLY-NOT: LV: Not vectorizing: Disabled/already vectorized
-; FORCEDONLY-NOT: LV: Not vectorizing: Cannot prove legality
 ; FORCEDONLY: LV: Loop hints: force=?
 ; FORCEDONLY: LV: Not vectorizing: VectorizeOnlyWhenForced is set, and no #pragma vectorize enable
 ; FORCEDONLY: remark:
 ; FORCEDONLY-SAME: loop not vectorized: only vectorizing loops that explicitly request it
-; FORCEDONLY: LV: Loop hints prevent vectorization
-
+;
+; BOTH: LV: Loop hints prevent vectorization
 define void @disabled_loop_vectorization(ptr %src) {
 entry:
   br label %loop
@@ -58,20 +62,9 @@ loop:
 exit:
   ret void
 }
-
 !0 = distinct !{!0, !1}
 !1 = !{!"llvm.loop.vectorize.enable", i1 false}
 
-; TEST 3
-; This test checks that we emit only the correct debug messages and
-; optimization remark when the loop vectorizer is disabled by loop metadata
-; that requests no loop transformations.
-
-; RUN: opt -S -passes=loop-vectorize -pass-remarks=loop-vectorize \
-; RUN:     -pass-remarks-missed=loop-vectorize \
-; RUN:     -pass-remarks-analysis=loop-vectorize -debug \
-; RUN:     -force-vector-interleave=1 -force-vector-width=2 \
-; RUN:     < %s 2>&1 | FileCheck --dump-input=always %s
 ; CHECK-LABEL: 'disable_nonforced' from <stdin>
 ; CHECK-NOT: LV: We can vectorize this loop
 ; CHECK-NOT: LV: Not vectorizing: #pragma vectorize disable.
@@ -98,5 +91,4 @@ loop:
 end:
   ret void
 }
-
 !2 = !{!2, !{!"llvm.loop.disable_nonforced"}}

>From f530fd543f405e64ab1b37bdbdb8dd071009b459 Mon Sep 17 00:00:00 2001
From: GYT <tiborgyri at gmail.com>
Date: Mon, 17 Nov 2025 12:31:05 +0100
Subject: [PATCH 34/34] remove dump-input from FileCheck lines

---
 .../LoopVectorize/diag-disabled-vectorization-msgs.ll       | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
index fca0ff7191851..22f32cc4a40ae 100644
--- a/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
+++ b/llvm/test/Transforms/LoopVectorize/diag-disabled-vectorization-msgs.ll
@@ -6,7 +6,7 @@
 ; RUN: opt -S -passes=loop-vectorize -pass-remarks=loop-vectorize \
 ; RUN:     -pass-remarks-missed=loop-vectorize \
 ; RUN:     -pass-remarks-analysis=loop-vectorize -debug \
-; RUN:     < %s 2>&1 | FileCheck --dump-input=always --check-prefixes=METADATA,BOTH %s
+; RUN:     < %s 2>&1 | FileCheck --check-prefixes=METADATA,BOTH %s
 ; TEST 2
 ; Checks that we emit only the correct debug messages and
 ; optimization remark when the loop is not vectorized due to the 
@@ -17,7 +17,7 @@
 ; RUN:   -pass-remarks=loop-vectorize \
 ; RUN:   -pass-remarks-missed=loop-vectorize \
 ; RUN:   -pass-remarks-analysis=loop-vectorize -debug \
-; RUN:   2>&1 | FileCheck --dump-input=always --check-prefixes=FORCEDONLY,BOTH %s
+; RUN:   2>&1 | FileCheck --check-prefixes=FORCEDONLY,BOTH %s
 ; TEST 3
 ; Checks that we emit only the correct debug messages and
 ; optimization remark when the loop vectorizer is disabled by loop metadata
@@ -26,7 +26,7 @@
 ; RUN:     -pass-remarks-missed=loop-vectorize \
 ; RUN:     -pass-remarks-analysis=loop-vectorize -debug \
 ; RUN:     -force-vector-interleave=1 -force-vector-width=2 \
-; RUN:     < %s 2>&1 | FileCheck --dump-input=always %s
+; RUN:     < %s 2>&1 | FileCheck %s
 
 ; BOTH-LABEL: 'disabled_loop_vectorization' from <stdin>
 ; BOTH-NOT: LV: We can vectorize this loop



More information about the llvm-commits mailing list