[llvm] [VPlan] Use ExitingIVValue for pointer inductions as well. (PR #180925)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 12 05:28:12 PST 2026
================
@@ -624,9 +624,37 @@ createWidenInductionRecipe(PHINode *Phi, VPPhi *PhiR, VPIRValue *Start,
VPValue *Step =
vputils::getOrCreateVPValueForSCEVExpr(Plan, IndDesc.getStep());
- if (IndDesc.getKind() == InductionDescriptor::IK_PtrInduction)
- return new VPWidenPointerInductionRecipe(Phi, Start, Step, &Plan.getVFxUF(),
- IndDesc, DL);
+ VPValue *BackedgeVal = PhiR->getOperand(1);
+ // Replace live-out extracts of WideIV's backedge value by ExitingIVValue
+ // recipes. optimizeInductionExitUsers will later compute the proper
+ // DerivedIV.
+ auto ReplaceExtractsWithExitingIVValue = [&](VPHeaderPHIRecipe *WideIV) {
+ for (VPUser *U : to_vector(BackedgeVal->users())) {
+ if (!match(U, m_ExtractLastPart(m_VPValue())))
+ continue;
+ auto *ExtractLastPart = cast<VPInstruction>(U);
+ if (!match(ExtractLastPart->getSingleUser(),
+ m_ExtractLastLane(m_VPValue())))
+ continue;
+ auto *ExtractLastLane =
+ cast<VPInstruction>(ExtractLastPart->getSingleUser());
+ assert(is_contained(ExtractLastLane->getParent()->successors(),
+ Plan.getScalarPreheader()) &&
+ "last lane must be extracted in the middle block");
----------------
david-arm wrote:
What if there are early exits?
https://github.com/llvm/llvm-project/pull/180925
More information about the llvm-commits
mailing list