[PATCH] D140511: [VPlan] Disconnect VPRegionBlock from successors in graph iterator(NFCI)
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 17 04:48:41 PST 2023
fhahn updated this revision to Diff 489772.
fhahn marked 2 inline comments as done.
fhahn added a comment.
Address latest comments and rebase on top of fixes for independent suggestions.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140511/new/
https://reviews.llvm.org/D140511
Files:
llvm/lib/Transforms/Vectorize/VPlanCFG.h
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
Index: llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
===================================================================
--- llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -398,9 +398,8 @@
SmallVector<const VPBlockBase *> FromIterator(
VPAllSuccessorsIterator<VPBlockBase *>(R1),
VPAllSuccessorsIterator<VPBlockBase *>::end(R1));
- EXPECT_EQ(2u, FromIterator.size());
+ EXPECT_EQ(1u, FromIterator.size());
EXPECT_EQ(R1BB1, FromIterator[0]);
- EXPECT_EQ(R2, FromIterator[1]);
// Depth-first.
VPBlockRecursiveTraversalWrapper<VPBlockBase *> Start(R1);
Index: llvm/lib/Transforms/Vectorize/VPlanCFG.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlanCFG.h
+++ llvm/lib/Transforms/Vectorize/VPlanCFG.h
@@ -144,7 +144,9 @@
/// 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 traverse only their entries
+// directly and not their successors. Those will be traversed when a region's
+// exiting block is traversed
template <typename BlockPtrTy>
class VPAllSuccessorsIterator
: public iterator_facade_base<VPAllSuccessorsIterator<BlockPtrTy>,
@@ -166,9 +168,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.
@@ -188,12 +189,12 @@
}
static VPAllSuccessorsIterator end(BlockPtrTy Block) {
+ if (auto *R = dyn_cast<VPRegionBlock>(Block))
+ return {R, 1};
+
BlockPtrTy ParentWithSuccs = getBlockWithSuccs(Block);
unsigned NumSuccessors =
ParentWithSuccs ? ParentWithSuccs->getNumSuccessors() : 0;
-
- if (auto *R = dyn_cast<VPRegionBlock>(Block))
- return {R, NumSuccessors + 1};
return {Block, NumSuccessors};
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140511.489772.patch
Type: text/x-patch
Size: 2354 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230117/cc0f61a6/attachment.bin>
More information about the llvm-commits
mailing list