[PATCH] D140511: [VPlan] Disconnect VPRegionBlock from successors in graph iterator(NFCI)

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 21 15:26:30 PST 2022


fhahn created this revision.
fhahn added reviewers: Ayal, gilr, rengolin.
Herald added subscribers: tschuett, psnobl, rogfer01, bollu, hiraditya.
Herald added a project: All.
fhahn requested review of this revision.
Herald added subscribers: pcwang-thead, vkmr.
Herald added a project: LLVM.

This updates the VPAllSuccessorsIterator to not connect the
VPRegionBlock itself to its successors. The successors are connected to
the exit block of the region. At the moment, this doesn't change any
exisint functionality.

But the new schema ensures the following property when used for
VPDominatorTree:

1. Entry & exit blocks of regions dominate the successors of the region.

This allows for convenient checking of dominance between defs and uses
that are not defined in the same region. I will share a follow-up patch
to use it for the VPDominatorTree soon.

Depends on D140500 <https://reviews.llvm.org/D140500>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140511

Files:
  llvm/lib/Transforms/Vectorize/VPlanCFG.h


Index: llvm/lib/Transforms/Vectorize/VPlanCFG.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlanCFG.h
+++ llvm/lib/Transforms/Vectorize/VPlanCFG.h
@@ -144,7 +144,8 @@
 /// entry node of VPRegionBlocks. Exit blocks of a region implicitly have their
 /// parent region's successors. This ensures all blocks in a region are visited
 /// before any blocks in a successor region when doing a reverse post-order
-// traversal of the graph.
+// traversal of the graph. Region blocks themselves are not directly connected
+// to their successors.
 template <typename BlockPtrTy>
 class VPAllSuccessorsIterator
     : public iterator_facade_base<VPAllSuccessorsIterator<BlockPtrTy>,
@@ -166,9 +167,8 @@
   /// both the const and non-const operator* implementations.
   template <typename T1> static T1 deref(T1 Block, unsigned SuccIdx) {
     if (auto *R = dyn_cast<VPRegionBlock>(Block)) {
-      if (SuccIdx == 0)
-        return R->getEntry();
-      SuccIdx--;
+      assert(SuccIdx == 0);
+      return R->getEntry();
     }
 
     // For exit blocks, use the next parent region with successors.
@@ -194,7 +194,7 @@
                                  : Block->getNumSuccessors();
 
     if (auto *R = dyn_cast<VPRegionBlock>(Block))
-      return {R, NumSuccessors + 1};
+      return {R, 1};
     return {Block, NumSuccessors};
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140511.484703.patch
Type: text/x-patch
Size: 1390 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221221/965bed5d/attachment.bin>


More information about the llvm-commits mailing list