[llvm] [LV] Trim VFs that cause vector splitting when tail-folding with EVL (PR #222836)

Andrei Elovikov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 06:39:52 PDT 2026


================
@@ -653,3 +676,35 @@ void VPlanTransforms::convertEVLExitCond(VPlan &Plan) {
   LatchBr->setOperand(
       0, Builder.createICmp(CmpInst::ICMP_EQ, AVLNext, Plan.getZero(AVLTy)));
 }
+
+void VPlanTransforms::trimVFsCausingSplits(VPlan &Plan,
+                                           VPCostContext &CostCtx) {
+  if (!Plan.hasScalableVF())
+    return;
+
+  // Get the widest type in the vector region.
+  unsigned WidestType = 8;
+  VPRegionBlock *VectorLoop = Plan.getVectorLoopRegion();
+  for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
+           vp_depth_first_deep(VectorLoop->getEntry())))
+    for (VPRecipeBase &BaseR : make_range(VPBB->getFirstNonPhi(), VPBB->end()))
+      if (auto *R = dyn_cast<VPSingleDefRecipe>(&BaseR);
----------------
eas wrote:

Why single-def only? Can't we just iterate over all values defined by the recipe? Also, why VectorLoop only? What if I have a recipe with a wider type defined in the preheader that is used inside `VectorLoop`?

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


More information about the llvm-commits mailing list