diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -2210,13 +2210,13 @@ /// to produce efficient output IR, including which branches, basic-blocks and /// output IR instructions to generate, and their cost. VPlan holds a /// Hierarchical-CFG of VPBasicBlocks and VPRegionBlocks rooted at an Entry -/// VPBlock. +/// VPBasicBlock. class VPlan { friend class VPlanPrinter; friend class VPSlotTracker; /// Hold the single entry to the Hierarchical CFG of the VPlan. - VPBlockBase *Entry; + VPBasicBlock *Entry; /// Holds the VFs applicable to this VPlan. SmallSetVector VFs; @@ -2260,7 +2260,7 @@ DenseMap SCEVToExpansion; public: - VPlan(VPBlockBase *Entry = nullptr) : Entry(Entry) { + VPlan(VPBasicBlock *Entry = nullptr) : Entry(Entry) { if (Entry) Entry->setPlan(this); } @@ -2275,10 +2275,10 @@ /// Generate the IR code for this VPlan. void execute(VPTransformState *State); - VPBlockBase *getEntry() { return Entry; } - const VPBlockBase *getEntry() const { return Entry; } + VPBasicBlock *getEntry() { return Entry; } + const VPBasicBlock *getEntry() const { return Entry; } - VPBlockBase *setEntry(VPBlockBase *Block) { + VPBasicBlock *setEntry(VPBasicBlock *Block) { Entry = Block; Block->setPlan(this); return Entry; diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -1137,7 +1137,7 @@ Expanded = Plan.getVPValueOrAddLiveIn(E->getValue()); else { - VPBasicBlock *Preheader = Plan.getEntry()->getEntryBasicBlock(); + VPBasicBlock *Preheader = Plan.getEntry(); Expanded = new VPExpandSCEVRecipe(Expr, SE); Preheader->appendRecipe(Expanded->getDefiningRecipe()); } diff --git a/llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp b/llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp --- a/llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp +++ b/llvm/unittests/Transforms/Vectorize/VPDomTreeTest.cpp @@ -15,6 +15,8 @@ namespace { TEST(VPDominatorTreeTest, DominanceNoRegionsTest) { + // VPBB0 + // | // R1 { // VPBB1 // / \ @@ -35,8 +37,10 @@ VPBlockUtils::connectBlocks(VPBB2, VPBB4); VPBlockUtils::connectBlocks(VPBB3, VPBB4); + VPBasicBlock *VPBB0 = new VPBasicBlock("VPBB0"); + VPBlockUtils::connectBlocks(VPBB0, VPBB0); VPlan Plan; - Plan.setEntry(R1); + Plan.setEntry(VPBB0); VPDominatorTree VPDT; VPDT.recalculate(Plan); @@ -68,6 +72,8 @@ TEST(VPDominatorTreeTest, DominanceRegionsTest) { { // 2 consecutive regions. + // VPBB0 + // | // R1 { // \ // R1BB1 _ @@ -104,8 +110,10 @@ VPBlockUtils::connectBlocks(R2BB1, R2BB2); VPBlockUtils::connectBlocks(R1, R2); + VPBasicBlock *VPBB0 = new VPBasicBlock("VPBB0"); + VPBlockUtils::connectBlocks(VPBB0, R1); VPlan Plan; - Plan.setEntry(R1); + Plan.setEntry(VPBB0); VPDominatorTree VPDT; VPDT.recalculate(Plan); diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp --- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp +++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp @@ -263,20 +263,6 @@ EXPECT_EQ(&Plan, VPBB4->getPlan()); } - { - // Region block is entry into VPlan. - VPBasicBlock *R1BB1 = new VPBasicBlock(); - VPBasicBlock *R1BB2 = new VPBasicBlock(); - VPRegionBlock *R1 = new VPRegionBlock(R1BB1, R1BB2, "R1"); - VPBlockUtils::connectBlocks(R1BB1, R1BB2); - - VPlan Plan; - Plan.setEntry(R1); - EXPECT_EQ(&Plan, R1->getPlan()); - EXPECT_EQ(&Plan, R1BB1->getPlan()); - EXPECT_EQ(&Plan, R1BB2->getPlan()); - } - { // VPBasicBlock is the entry into the VPlan, followed by a region. VPBasicBlock *R1BB1 = new VPBasicBlock(); @@ -359,6 +345,8 @@ { // 2 consecutive regions. + // VPBB0 + // | // R1 { // \ // R1BB1 @@ -449,7 +437,9 @@ // Use Plan to properly clean up created blocks. VPlan Plan; - Plan.setEntry(R1); + VPBasicBlock *VPBB0 = new VPBasicBlock("VPBB0"); + VPBlockUtils::connectBlocks(VPBB0, R1); + Plan.setEntry(VPBB0); } {