[llvm] [LV]Initial support for safe distance in predicated DataWithEVL vectorization mode. (PR #102897)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 16:08:22 PDT 2024
================
@@ -1362,9 +1378,24 @@ bool VPlanTransforms::tryAddExplicitVectorLength(VPlan &Plan) {
// Create the ExplicitVectorLengthPhi recipe in the main loop.
auto *EVLPhi = new VPEVLBasedIVPHIRecipe(StartV, DebugLoc());
EVLPhi->insertAfter(CanonicalIVPHI);
- auto *VPEVL = new VPInstruction(VPInstruction::ExplicitVectorLength,
- {EVLPhi, Plan.getTripCount()});
- VPEVL->insertBefore(*Header, Header->getFirstNonPhi());
+ VPRecipeBase *AVL = EVLPhi;
+ if (MaxEVLSafeElements) {
+ VPValue *EVLSafe = Plan.getOrAddLiveIn(
+ ConstantInt::get(CanonicalIVPHI->getScalarType(), *MaxEVLSafeElements));
+ auto *Cmp = new VPInstruction(Instruction::ICmp, ICmpInst::ICMP_ULT, EVLPhi,
+ EVLSafe);
+ Cmp->insertBefore(*Header, Header->getFirstNonPhi());
+ AVL = new VPInstruction(Instruction::Select, {Cmp, EVLPhi, EVLSafe},
+ DebugLoc(), "safe_avl");
+ AVL->insertAfter(Cmp);
+ }
+ auto *VPEVL = new VPInstruction(
+ VPInstruction::ExplicitVectorLength,
+ {AVL->getVPSingleValue(), Plan.getTripCount()}, DebugLoc());
----------------
ayalz wrote:
nit: `DebugLoc()` can be added independently.
https://github.com/llvm/llvm-project/pull/102897
More information about the llvm-commits
mailing list