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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 5 04:09:44 PDT 2024


================
@@ -8452,7 +8452,104 @@ static void addUsersInExitBlock(
            return P && Inductions.contains(P);
          })))
       continue;
-    Plan.addLiveOut(&ExitPhi, V);
+
+    auto MiddleVPBB =
+        cast<VPBasicBlock>(Plan.getVectorLoopRegion()->getSingleSuccessor());
+    VPBuilder B(MiddleVPBB);
+    if (auto *Terminator = MiddleVPBB->getTerminator()) {
+      auto *Condition = dyn_cast<VPInstruction>(Terminator->getOperand(0));
+      assert((!Condition || Condition->getParent() == MiddleVPBB) &&
+             "Condition expected in MiddleVPBB");
+      B.setInsertPoint(Condition ? Condition : Terminator);
+    }
+
+    VPValue *Ext;
+    if (auto *FOR = dyn_cast_or_null<VPFirstOrderRecurrencePHIRecipe>(
+            V->getDefiningRecipe())) {
+      // This is the second phase of vectorizing first-order recurrences. An
+      // overview of the transformation is described below. Suppose we have the
+      // following loop with some use after the loop of the last a[i-1],
----------------
fhahn wrote:

Moved to`addLiveOutsForFixedOrderRecurrences` , thanks!

There's a bit of duplication at the moment to figure out if live-outs are needed or not. This should go away with https://github.com/llvm/llvm-project/pull/100735 when this should be handled automatically by the exit block not existing in VPlan in those cases

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


More information about the llvm-commits mailing list