[llvm] [LV] Don't access loop after executePlan in native path (NFC). (PR #191277)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 9 12:23:02 PDT 2026


https://github.com/fhahn created https://github.com/llvm/llvm-project/pull/191277

Bring native path in line with inner loop path: the loop may become invalid once we are able to remove the scalar loop in the native path as well. Match inner loop behavior by reporting vectorization before executePlan, and using F instead of L->getHeader()->getParent().

>From 8b2819d2a50dd58dfffd14352cd97bfd340a8dc3 Mon Sep 17 00:00:00 2001
From: Florian Hahn <flo at fhahn.com>
Date: Thu, 9 Apr 2026 16:27:06 +0100
Subject: [PATCH] [LV] Don't access loop after executePlan in native path
 (NFC).

Bring native path in line with inner loop path: the loop may become
invalid once we are able to remove the scalar loop in the native path as
well. Match inner loop behavior by reporting vectorization before
executePlan, and using F instead of L->getHeader()->getParent().
---
 llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 3aa35a9de7598..018895ab55bd8 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -8661,20 +8661,20 @@ static bool processLoopInVPlanNativePath(
     GeneratedRTChecks Checks(PSE, DT, LI, TTI, CM.CostKind);
     InnerLoopVectorizer LB(L, PSE, LI, DT, TTI, AC, VF.Width, /*UF=*/1, &CM,
                            Checks, BestPlan);
-    LLVM_DEBUG(dbgs() << "Vectorizing outer loop in \""
-                      << L->getHeader()->getParent()->getName() << "\"\n");
+    LLVM_DEBUG(dbgs() << "Vectorizing outer loop in \"" << F->getName()
+                      << "\"\n");
     LVP.addMinimumIterationCheck(BestPlan, VF.Width, /*UF=*/1,
                                  VF.MinProfitableTripCount);
     bool HasBranchWeights =
         hasBranchWeightMD(*L->getLoopLatch()->getTerminator());
     LVP.attachRuntimeChecks(BestPlan, Checks, HasBranchWeights);
 
+    reportVectorization(ORE, L, VF, 1);
+
     LVP.executePlan(VF.Width, /*UF=*/1, BestPlan, LB, DT);
   }
 
-  reportVectorization(ORE, L, VF, 1);
-
-  assert(!verifyFunction(*L->getHeader()->getParent(), &dbgs()));
+  assert(!verifyFunction(*F, &dbgs()));
   return true;
 }
 



More information about the llvm-commits mailing list