[llvm] [VPlan] Model branch cond to enter scalar epilogue in VPlan. (PR #92651)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 05:25:16 PDT 2024


================
@@ -651,16 +653,17 @@ static std::pair<VPBlockBase *, VPBlockBase *> cloneSESE(VPBlockBase *Entry);
 // Clone the CFG for all nodes in the single-entry-single-exit region reachable
 // from \p Entry, this includes cloning the blocks and their recipes. Operands
 // of cloned recipes will NOT be updated. Remapping of operands must be done
-// separately. Returns a pair with the the new entry and exiting blocks of the
-// cloned region.
+// separately. Returns a pair with the new entry and exiting blocks of the
+// cloned region. If \p Entry isn't part of a region, return nullptr for the exiting block.
 static std::pair<VPBlockBase *, VPBlockBase *> cloneSESE(VPBlockBase *Entry) {
   DenseMap<VPBlockBase *, VPBlockBase *> Old2NewVPBlocks;
   VPBlockBase *Exiting = nullptr;
+  bool InRegion = Entry->getParent();
   // First, clone blocks reachable from Entry.
   for (VPBlockBase *BB : vp_depth_first_shallow(Entry)) {
     VPBlockBase *NewBB = BB->clone();
     Old2NewVPBlocks[BB] = NewBB;
-    if (BB->getNumSuccessors() == 0) {
+    if (InRegion && BB->getNumSuccessors() == 0) {
----------------
ayalz wrote:

Even if Entry is not part of a region, it could have a single exit - which could be returned. Suffice to update the assert (!Exiting && InRegion && "Multiple exiting blocks from a region?"); ?

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


More information about the llvm-commits mailing list