[llvm] [VPlan] Enable vectorization of early-exit loops with unit-stride fault-only-first loads (PR #151300)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 12 00:53:29 PST 2025
================
@@ -3144,6 +3144,137 @@ void VPlanTransforms::addExplicitVectorLength(
Plan.setUF(1);
}
+void VPlanTransforms::adjustFFLoadEarlyExitForPoisonSafety(VPlan &Plan) {
+ using namespace SCEVPatternMatch;
+ VPBasicBlock *Header = Plan.getVectorLoopRegion()->getEntryBasicBlock();
+ VPWidenIntrinsicRecipe *LastFFLoad = nullptr;
+ for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
+ vp_depth_first_deep(Plan.getVectorLoopRegion())))
+ for (VPRecipeBase &R : *VPBB)
+ if (match(&R, m_Intrinsic<Intrinsic::vp_load_ff>(m_VPValue(), m_VPValue(),
+ m_VPValue()))) {
+ assert(!LastFFLoad && "Only one FFLoad is supported");
+ LastFFLoad = cast<VPWidenIntrinsicRecipe>(&R);
+ }
+
+ // Skip if no FFLoad.
+ if (!LastFFLoad)
+ return;
+
+ // Ensure FFLoad does not read past the remainder in the last iteration.
+ // Set AVL to min(VF, remainder).
----------------
lukel97 wrote:
I'm confused as to why we need to cap the AVL for vp.load.ff. The first lane should always be dereferenceable, and then it shouldn't be an issue if it tries to read the remainder lanes because it doesn't trap?
Is this more of an optimization to reduce VL so it's not overly large?
https://github.com/llvm/llvm-project/pull/151300
More information about the llvm-commits
mailing list