[llvm] [LV] Only require a scalar epilogue for interleave groups actually widened as interleave accesses (PR #213904)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 25 08:50:51 PDT 2026
================
@@ -6739,6 +6724,20 @@ VPlanPtr LoopVectorizationPlanner::tryToBuildVPlan(VPlanPtr Plan,
InterleaveGroups.insert(IG);
}
+ bool RequiresScalarEpilogue =
+ CM.isEpilogueAllowed() && any_of(InterleaveGroups, [](auto *IG) {
+ return isa<LoadInst>(IG->getInsertPos()) &&
+ IG->requiresScalarEpilogue();
+ });
+ // Update the branch in the middle block if a scalar epilogue is required.
+ VPBasicBlock *MiddleVPBB = Plan->getMiddleBlock();
+ if (RequiresScalarEpilogue && MiddleVPBB->getNumSuccessors() == 2) {
+ auto *BranchOnCond = cast<VPInstruction>(MiddleVPBB->getTerminator());
+ assert(MiddleVPBB->getSuccessors()[1] == Plan->getScalarPreheader() &&
+ "second successor must be scalar preheader");
+ BranchOnCond->setOperand(0, Plan->getFalse());
+ }
----------------
fhahn wrote:
would it be possible to only se the condition once we formed interleave groups inthe VPlan, and check the IG recipes in the plan?
Otherwise we may unnecessarily require a scalar epilogue if we fail to form interleave groups for some reason.
https://github.com/llvm/llvm-project/pull/213904
More information about the llvm-commits
mailing list