[llvm] [VPlan] Introduce explicit ExtractFromEnd recipes for live-outs. (PR #100658)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 12:44:46 PDT 2024


================
@@ -8470,22 +8480,29 @@ static void addUsersInExitBlock(
     // live-outs.
     if ((isa<VPWidenIntOrFpInductionRecipe>(V) &&
          !cast<VPWidenIntOrFpInductionRecipe>(V)->getTruncInst()) ||
-        isa<VPWidenPointerInductionRecipe>(V) ||
+        isa<VPWidenPointerInductionRecipe, VPFirstOrderRecurrencePHIRecipe>(
+            V) ||
         (isa<Instruction>(IncomingValue) &&
          any_of(IncomingValue->users(), [&Inductions](User *U) {
            auto *P = dyn_cast<PHINode>(U);
            return P && Inductions.contains(P);
          })))
       continue;
-    Plan.addLiveOut(&ExitPhi, V);
+
+    VPValue *Ext = B.createNaryOp(
+        VPInstruction::ExtractFromEnd,
+        {V, Plan.getOrAddLiveIn(ConstantInt::get(
+                IntegerType::get(ExitBB->getContext(), 32), 1))});
+    Plan.addLiveOut(&ExitPhi, Ext);
   }
 }
 
 /// Feed a resume value for every FOR from the vector loop to the scalar loop,
 /// if middle block branches to scalar preheader, by introducing ExtractFromEnd
 /// and ResumePhi recipes in each, respectively, and a VPLiveOut which uses the
 /// latter and corresponds to the scalar header.
----------------
fhahn wrote:

Updated comment, thanks!

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


More information about the llvm-commits mailing list