[llvm] [VPlan] Optimize resume values of IVs together with other exit values. (PR #174239)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 4 04:28:35 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)) {
----------------
fhahn wrote:

We could have de-generate phis in the the header, like `%p = phi [ 0, %entry ], [ 1, %latch ]`. But those now get simplified/folded earlier, so I removed the special code here

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


More information about the llvm-commits mailing list