[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:21 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);
----------------
david-arm wrote:

How do we know that the second operand of a phi in a vector loop is the resume value used in the middle block? Is this because we're assuming the second operand is always the PHI update and by definition the resume value must always be the update? If so, perhaps worth adding a comment explaining what's going on here to make life easier for the reader?

Also is operand 1 is the backedge value do we have a helper function for that we can call? It makes it a bit more readable, i.e. `VectorPhiR->getBackedgeValue()`

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


More information about the llvm-commits mailing list