[llvm] [VPlan] Introduce child regions as VPlan transform. (PR #129402)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 05:16:12 PDT 2025


================
@@ -648,6 +648,22 @@ bool VPBasicBlock::isExiting() const {
   return getParent() && getParent()->getExitingBasicBlock() == this;
 }
 
+std::optional<std::pair<VPBasicBlock *, VPBasicBlock *>>
+VPBasicBlock::isHeader(const VPDominatorTree &VPDT) const {
+  ArrayRef<VPBlockBase *> Preds = getPredecessors();
+  if (Preds.size() != 2)
+    return std::nullopt;
+
+  for (unsigned Idx : {0, 1}) {
+    auto *PreheaderVPBB = cast<VPBasicBlock>(Preds[Idx]);
+    auto *LatchVPBB = cast<VPBasicBlock>(Preds[1 - Idx]);
+    if (VPDT.dominates(PreheaderVPBB, this) && VPDT.dominates(this, LatchVPBB))
+      return {std::make_pair(PreheaderVPBB, LatchVPBB)};
+  }
----------------
fhahn wrote:

swapped the order, thanks

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


More information about the llvm-commits mailing list