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

via llvm-commits llvm-commits at lists.llvm.org
Fri May 2 01:54:25 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");
----------------
ayalz wrote:

```suggestion
        "loop region has a single predecessor (preheader), its entry block has 2 incoming blocks");
```
Perhaps better have the verifier assert loop regions have a single predecessor, than here.

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


More information about the llvm-commits mailing list