[llvm] [VPlan] Add VPPhiAccessors to provide interface for phi recipes (NFC) (PR #129388)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sat May 3 02:53:20 PDT 2025


================
@@ -790,6 +790,26 @@ InstructionCost VPBasicBlock::cost(ElementCount VF, VPCostContext &Ctx) {
   return Cost;
 }
 
+const VPBasicBlock *VPBasicBlock::getCFGPredecessor(unsigned Idx) const {
+  const VPBlockBase *Pred = nullptr;
+  if (getNumPredecessors() > 0) {
+    Pred = getPredecessors()[Idx];
+  } else {
+    auto *Region = getParent();
+    assert(Region && !Region->isReplicator() && Region->getEntry() == this &&
+           "must be in the entry block of a non-replicate region");
+    assert(
+        Idx < 2 && Region->getNumPredecessors() == 1 &&
+        "when placed in an entry block, only 2 incoming blocks are available");
+
+    // Idx ==  0 selects the predecessor of the region, Idx == 1 selects the
+    // region itself whose exiting block feeds the phi across the backedge.
+    Pred = Idx == 0 ? Region->getSinglePredecessor() : Region;
+  }
+
----------------
fhahn wrote:

Dropped, thanks

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


More information about the llvm-commits mailing list