[llvm] [VPlan] Directly unroll VectorEndPointerRecipe (PR #172372)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 10 00:53:13 PST 2026


================
@@ -2913,10 +2913,19 @@ static VPRecipeBase *optimizeMaskToEVL(VPValue *HeaderMask,
 
   /// Adjust any end pointers so that they point to the end of EVL lanes not VF.
   auto AdjustEndPtr = [&CurRecipe, &EVL](VPValue *EndPtr) {
-    auto *EVLEndPtr = cast<VPVectorEndPointerRecipe>(EndPtr)->clone();
-    EVLEndPtr->insertBefore(&CurRecipe);
-    EVLEndPtr->setOperand(1, &EVL);
-    return EVLEndPtr;
+    auto *VEPR = cast<VPVectorEndPointerRecipe>(EndPtr);
+    VPBuilder Builder(&CurRecipe);
+    return Builder.createVectorEndPointerRecipe(
+        VEPR->getOperand(0), VEPR->getSourceElementType(), VEPR->getStride(),
+        VEPR->getGEPNoWrapFlags(), &EVL, VEPR->getDebugLoc());
+  };
+
+  auto m_VecEndPtrVF = [&Plan](VPValue *&Addr) { // NOLINT
+    return m_VecEndPtr(
+        m_VPValue(Addr),
+        m_c_Mul(
+            m_VPValue(),
----------------
lukel97 wrote:

I think this still needs to check that this is `-VPVectorEndPointerRecipe.Stride * (VF - 1)` and not just any arbitrary stride? Or we should make it an invariant and verify it in VPlanVerifier?

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


More information about the llvm-commits mailing list