[llvm] e70a2e8 - [VPlan] Allow same predecessor multiple times in the verifier. (NFC) (#192809)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 18 13:42:55 PDT 2026
Author: Florian Hahn
Date: 2026-04-18T21:42:50+01:00
New Revision: e70a2e84ce954c58c2da5bfbee7f69b8c2b1109d
URL: https://github.com/llvm/llvm-project/commit/e70a2e84ce954c58c2da5bfbee7f69b8c2b1109d
DIFF: https://github.com/llvm/llvm-project/commit/e70a2e84ce954c58c2da5bfbee7f69b8c2b1109d.diff
LOG: [VPlan] Allow same predecessor multiple times in the verifier. (NFC) (#192809)
IR instructions like switch lead to initial VPlans with blocks that have
the same predecessor multiple times. Allow it in the verifier.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp b/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
index 1dff1831c305c..ee1c7e3f16b2e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
@@ -314,17 +314,6 @@ bool VPlanVerifier::verifyVPBasicBlock(const VPBasicBlock *VPBB) {
return true;
}
-/// Utility function that checks whether \p VPBlockVec has duplicate
-/// VPBlockBases.
-static bool hasDuplicates(const SmallVectorImpl<VPBlockBase *> &VPBlockVec) {
- SmallDenseSet<const VPBlockBase *, 8> VPBlockSet;
- for (const auto *Block : VPBlockVec) {
- if (!VPBlockSet.insert(Block).second)
- return true;
- }
- return false;
-}
-
bool VPlanVerifier::verifyBlock(const VPBlockBase *VPB) {
auto *VPBB = dyn_cast<VPBasicBlock>(VPB);
// Check block's condition bit.
@@ -345,13 +334,6 @@ bool VPlanVerifier::verifyBlock(const VPBlockBase *VPB) {
// Check block's successors.
const auto &Successors = VPB->getSuccessors();
- // There must be only one instance of a successor in block's successor list.
- // TODO: This won't work for switch statements.
- if (hasDuplicates(Successors)) {
- errs() << "Multiple instances of the same successor.\n";
- return false;
- }
-
for (const VPBlockBase *Succ : Successors) {
// There must be a bi-directional link between block and successor.
const auto &SuccPreds = Succ->getPredecessors();
@@ -363,13 +345,6 @@ bool VPlanVerifier::verifyBlock(const VPBlockBase *VPB) {
// Check block's predecessors.
const auto &Predecessors = VPB->getPredecessors();
- // There must be only one instance of a predecessor in block's predecessor
- // list.
- // TODO: This won't work for switch statements.
- if (hasDuplicates(Predecessors)) {
- errs() << "Multiple instances of the same predecessor.\n";
- return false;
- }
for (const VPBlockBase *Pred : Predecessors) {
// Block and predecessor must be inside the same region.
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
index 2472e18b654e2..1bf3248da48b7 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp
@@ -224,14 +224,8 @@ TEST_F(VPVerifierTest, DuplicateSuccessorsOutsideRegion) {
VPBlockUtils::connectBlocks(R1, Plan.getScalarHeader());
-#if GTEST_HAS_STREAM_REDIRECTION
- ::testing::internal::CaptureStderr();
-#endif
- EXPECT_FALSE(verifyVPlanIsValid(Plan));
-#if GTEST_HAS_STREAM_REDIRECTION
- EXPECT_STREQ("Multiple instances of the same successor.\n",
- ::testing::internal::GetCapturedStderr().c_str());
-#endif
+ // Duplicate successors are allowed for blocks with conditional terminators.
+ EXPECT_TRUE(verifyVPlanIsValid(Plan));
}
TEST_F(VPVerifierTest, DuplicateSuccessorsInsideRegion) {
@@ -263,14 +257,8 @@ TEST_F(VPVerifierTest, DuplicateSuccessorsInsideRegion) {
VPBlockUtils::connectBlocks(R1, Plan.getScalarHeader());
-#if GTEST_HAS_STREAM_REDIRECTION
- ::testing::internal::CaptureStderr();
-#endif
- EXPECT_FALSE(verifyVPlanIsValid(Plan));
-#if GTEST_HAS_STREAM_REDIRECTION
- EXPECT_STREQ("Multiple instances of the same successor.\n",
- ::testing::internal::GetCapturedStderr().c_str());
-#endif
+ // Duplicate successors are allowed for blocks with conditional terminators.
+ EXPECT_TRUE(verifyVPlanIsValid(Plan));
}
TEST_F(VPVerifierTest, BlockOutsideRegionWithParent) {
More information about the llvm-commits
mailing list