From 0558fe3bbf575f562e8bde4cb73cf47e0b6a8153 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 24 Oct 2024 14:49:08 -0700 Subject: [PATCH] [VPlan] Update unit tests to use getVectorLoopRegion (NFC). Use getVectorLoopRegion to retrieve the vector loop header instead of relying on getting the successor of the entry block. This makes sure the code still works correctly as more parts of the skeleton are modeled in VPlan. --- .../Transforms/Vectorize/VPlanHCFGTest.cpp | 4 ++-- .../Transforms/Vectorize/VPlanSlpTest.cpp | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp index 00a3c737c0e47a..01d630124a4bbd 100644 --- a/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp +++ b/llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp @@ -50,7 +50,7 @@ TEST_F(VPlanHCFGTest, testBuildHCFGInnerLoop) { // Check that the region following the preheader is a single basic-block // region (loop). - VPBasicBlock *VecBB = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *VecBB = Plan->getVectorLoopRegion()->getEntryBasicBlock(); EXPECT_EQ(8u, VecBB->size()); EXPECT_EQ(0u, VecBB->getNumPredecessors()); EXPECT_EQ(0u, VecBB->getNumSuccessors()); @@ -193,7 +193,7 @@ TEST_F(VPlanHCFGTest, testVPInstructionToVPRecipesInner) { // Check that the region following the preheader is a single basic-block // region (loop). - VPBasicBlock *VecBB = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *VecBB = Plan->getVectorLoopRegion()->getEntryBasicBlock(); EXPECT_EQ(8u, VecBB->size()); EXPECT_EQ(0u, VecBB->getNumPredecessors()); EXPECT_EQ(0u, VecBB->getNumSuccessors()); diff --git a/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp index 910fc24455a6c2..1b993b63898caa 100644 --- a/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp +++ b/llvm/unittests/Transforms/Vectorize/VPlanSlpTest.cpp @@ -99,7 +99,7 @@ TEST_F(VPlanSlpTest, testSlpSimple_2) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(Body->begin(), 12)); VPInstruction *Store2 = cast(&*std::next(Body->begin(), 14)); @@ -171,7 +171,7 @@ TEST_F(VPlanSlpTest, testSlpSimple_3) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(Body->begin(), 12)); VPInstruction *Store2 = cast(&*std::next(Body->begin(), 14)); @@ -243,7 +243,7 @@ TEST_F(VPlanSlpTest, testSlpReuse_1) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(Body->begin(), 8)); VPInstruction *Store2 = cast(&*std::next(Body->begin(), 10)); @@ -307,7 +307,7 @@ TEST_F(VPlanSlpTest, testSlpReuse_2) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(Body->begin(), 5)); VPInstruction *Store2 = cast(&*std::next(Body->begin(), 10)); @@ -444,7 +444,7 @@ TEST_F(VPlanSlpTest, testSlpReorder_1) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(Body->begin(), 24)); VPInstruction *Store2 = cast(&*std::next(Body->begin(), 26)); @@ -516,7 +516,7 @@ TEST_F(VPlanSlpTest, testSlpReorder_2) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(Body->begin(), 24)); VPInstruction *Store2 = cast(&*std::next(Body->begin(), 26)); @@ -588,7 +588,7 @@ TEST_F(VPlanSlpTest, testSlpReorder_3) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(Body->begin(), 24)); VPInstruction *Store2 = cast(&*std::next(Body->begin(), 26)); @@ -664,7 +664,7 @@ TEST_F(VPlanSlpTest, testSlpReorder_4) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(Body->begin(), 24)); VPInstruction *Store2 = cast(&*std::next(Body->begin(), 26)); @@ -725,7 +725,7 @@ TEST_F(VPlanSlpTest, testInstrsInDifferentBBs) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPBasicBlock *BB2 = Body->getSingleSuccessor()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(BB2->begin(), 3)); @@ -788,7 +788,7 @@ TEST_F(VPlanSlpTest, testInstrsInDifferentBBs2) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPBasicBlock *BB2 = Body->getSingleSuccessor()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(BB2->begin(), 1)); @@ -848,7 +848,7 @@ TEST_F(VPlanSlpTest, testSlpAtomicLoad) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(Body->begin(), 12)); VPInstruction *Store2 = cast(&*std::next(Body->begin(), 14)); @@ -907,7 +907,7 @@ TEST_F(VPlanSlpTest, testSlpAtomicStore) { VPBlockBase *Entry = Plan->getEntry()->getEntryBasicBlock(); EXPECT_NE(nullptr, Entry->getSingleSuccessor()); - VPBasicBlock *Body = Entry->getSingleSuccessor()->getEntryBasicBlock(); + VPBasicBlock *Body = Plan->getVectorLoopRegion()->getEntryBasicBlock(); VPInstruction *Store1 = cast(&*std::next(Body->begin(), 12)); VPInstruction *Store2 = cast(&*std::next(Body->begin(), 14));