[llvm] [VPlan] Introduce child regions as VPlan transform. (PR #129402)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 7 02:20:47 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)};
+ }
----------------
ayalz wrote:
Simpler to unroll - check first and second predecessors, and then swap them and check again? Or canonicalize predecessor order earlier to be consistent with header phis as they are fixed.
https://github.com/llvm/llvm-project/pull/129402
More information about the llvm-commits
mailing list