[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
Sat Nov 1 13:19:25 PDT 2025


================
@@ -182,14 +182,40 @@ 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");
----------------
TiborGY wrote:

Maybe, but not really? `reportVectorizationFailure` calls `createLVAnalysis` which always returns `OptimizationRemarkAnalysis`, and I feel like `OptimizationRemarkMissed` is more appropriate here. And FWIW `OptimizationRemarkMissed` is the preexisting behaviour for the subset of these messages that already existed before this PR.
I have added a new private function to `LoopVectorizeHints`, and refactored the new messages using it to make `allowVectorization` less repetitive. Let me know if you think this was a bad idea.

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


More information about the llvm-commits mailing list