[llvm] [LoopVectorize] Add metadata to distinguish vectorized loop body from scalar remainder (PR #190258)

Adel Ejjeh via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 3 08:52:26 PDT 2026


================
@@ -25,13 +25,25 @@ static void warnAboutLeftoverTransformations(Loop *L,
                                              OptimizationRemarkEmitter *ORE) {
   if (hasUnrollTransformation(L) == TM_ForcedByUser) {
     LLVM_DEBUG(dbgs() << "Leftover unroll transformation\n");
-    ORE->emit(
-        DiagnosticInfoOptimizationFailure(DEBUG_TYPE,
-                                          "FailedRequestedUnrolling",
-                                          L->getStartLoc(), L->getHeader())
-        << "loop not unrolled: the optimizer was unable to perform the "
-           "requested transformation; the transformation might be disabled or "
-           "specified as part of an unsupported transformation ordering");
+    bool IsVectorBody =
+        getBooleanLoopAttribute(L, "llvm.loop.vectorize.vector_body");
+    bool IsScalarRemainder =
+        getBooleanLoopAttribute(L, "llvm.loop.vectorize.scalar_remainder");
+    const char *LoopKind = (IsVectorBody && IsScalarRemainder)
+                               ? "epilogue vectorized remainder loop"
+                           : IsScalarRemainder
+                               ? "scalar remainder loop after vectorization"
+                           : IsVectorBody ? "vectorized loop"
+                                          : "loop";
----------------
adelejjeh wrote:

I made a change. Let me know if that's what you meant! Fixed it in both WarnMissedTransforms.cpp and LoopUnroll.cpp

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


More information about the llvm-commits mailing list