[llvm] [VPlan] Use ExitingIVValue for pointer inductions as well. (PR #180925)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 13 05:04:27 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");
----------------
fhahn wrote:

extracts for early exits are currently only created later, in handleEarlyExits. I'll see about unifying the creation + updating separately.

https://github.com/llvm/llvm-project/pull/180925


More information about the llvm-commits mailing list