[llvm] [VPlan] Add VPlan-based addMinIterCheck, replace ILV for non-epilogue. (PR #153643)

via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 23 04:32:02 PDT 2025


================
@@ -7327,6 +7257,17 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
       BestVPlan.resetTripCount(Exp);
     ExpSCEV->eraseFromParent();
   }
+  // SCEV expansion will add new instructions in the IRBB wrapped by Entry.
+  // Remove existing VPIRInstructions/VPIRPhi and re-create them to make sure
+  // all IR instructions are wrapped. Otherwise VPInstructions may be inserted
+  // at the wrong place.
+  for (VPRecipeBase &R : make_early_inc_range(*Entry)) {
+    if (!isa<VPIRInstruction, VPIRPhi>(&R))
+      continue;
+    R.eraseFromParent();
+  }
+  for (Instruction &I : drop_begin(reverse(*Entry->getIRBasicBlock())))
+    VPIRInstruction::create(I)->insertBefore(*Entry, Entry->begin());
 
----------------
ayalz wrote:

When vectorizing main loop with the epilog to be vectorized later, is EpilogueVectorizerMainLoop used instead of base ILV? Thought is to try and turn ILV::createVectorizedLoopSkeleton() unreachable (rather than pure virtual), as skeleton creation is essentially used only when both main and epilog are vectorized.

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


More information about the llvm-commits mailing list