[llvm] [VPlan] Optimize resume values of IVs together with other exit values. (PR #174239)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 07:02:23 PST 2026
================
@@ -562,12 +562,21 @@ static void addInitialSkeleton(VPlan &Plan, Type *InductionTy, DebugLoc IVDL,
createExtractsForLiveOuts(Plan, MiddleVPBB);
+ VPBuilder MiddleBuilder(MiddleVPBB, MiddleVPBB->getFirstNonPhi());
VPBuilder ScalarPHBuilder(ScalarPH);
for (const auto &[PhiR, ScalarPhiR] : zip_equal(
drop_begin(HeaderVPBB->phis()), Plan.getScalarHeader()->phis())) {
auto *VectorPhiR = cast<VPPhi>(&PhiR);
+ VPValue *ResumeFromVectorLoop = VectorPhiR->getOperand(1);
+ if (!isa<VPIRValue>(ResumeFromVectorLoop)) {
+ ResumeFromVectorLoop = MiddleBuilder.createNaryOp(
+ VPInstruction::ExtractLastPart, ResumeFromVectorLoop);
+ ResumeFromVectorLoop = MiddleBuilder.createNaryOp(
+ VPInstruction::ExtractLastLane, ResumeFromVectorLoop);
+ }
auto *ResumePhiR = ScalarPHBuilder.createScalarPhi(
- {VectorPhiR, VectorPhiR->getOperand(0)}, VectorPhiR->getDebugLoc());
+ {ResumeFromVectorLoop, VectorPhiR->getOperand(0)},
----------------
david-arm wrote:
What are the expected predecessors to match these incoming values? It looks like you're saying the first predecessor *must* be from the middle block, and the second predecessor must be the start value of the vector loop and so is the vector preheader?
Might be good to add some comments?
https://github.com/llvm/llvm-project/pull/174239
More information about the llvm-commits
mailing list