[llvm] [VPlan] Add FinalIVValue VPInstruction. (PR #175651)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 19 05:36:00 PST 2026


================
@@ -700,6 +700,23 @@ void VPlanTransforms::createHeaderPhiRecipes(
     VPHeaderPHIRecipe *HeaderPhiR = CreateHeaderPhiRecipe(PhiR);
     HeaderPhiR->insertBefore(PhiR);
     PhiR->replaceAllUsesWith(HeaderPhiR);
+    if (isa<VPWidenIntOrFpInductionRecipe>(HeaderPhiR)) {
+      for (VPUser *U : PhiR->getOperand(1)->users()) {
+        if (!match(U, m_ExtractLastPart(m_VPValue())))
+          continue;
+        auto *ExtractLastPart = cast<VPInstruction>(U);
+        if (!match(ExtractLastPart->getSingleUser(),
+                   m_ExtractLastLane(m_VPValue())))
+          continue;
----------------
fhahn wrote:

We may not be able to detect that an operand of the extract-lane(extract-part()) operand is the increment of an induction in `optimizeLatchExitInductionUser`, because VPWidenIntOrFpInductionRecipe intentionally does not have the original increment as operand (it creates the increment itself).

`optimizeLatchExitInductionUser` can detect some cases, but some would be very cumbersome/impossible to easily detect. Here we know exactly that it is the increment because we can still check the backedge value.

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


More information about the llvm-commits mailing list