8
8
// ===----------------------------------------------------------------------===//
9
9
10
10
#include " ../lib/Transforms/Vectorize/VPlan.h"
11
- #include " ../lib/Transforms/Vectorize/VPlanHCFGBuilder.h"
12
11
#include " ../lib/Transforms/Vectorize/VPlanHCFGTransforms.h"
13
- #include " llvm/AsmParser/Parser.h"
14
- #include " llvm/IR/Dominators.h"
12
+ #include " VPlanTestBase.h"
15
13
#include " gtest/gtest.h"
16
14
17
15
namespace llvm {
18
16
namespace {
19
17
20
- class VPlanHCFGTest : public testing ::Test {
21
- protected:
22
- std::unique_ptr<DominatorTree> DT;
23
- std::unique_ptr<LoopInfo> LI;
24
-
25
- VPlanHCFGTest () {}
26
-
27
- VPlanPtr doBuildPlan (BasicBlock *LoopHeader) {
28
- DT.reset (new DominatorTree (*LoopHeader->getParent ()));
29
- LI.reset (new LoopInfo (*DT));
30
-
31
- auto Plan = llvm::make_unique<VPlan>();
32
- VPlanHCFGBuilder HCFGBuilder (LI->getLoopFor (LoopHeader), LI.get ());
33
- HCFGBuilder.buildHierarchicalCFG (*Plan.get ());
34
- return Plan;
35
- }
36
- };
18
+ class VPlanHCFGTest : public VPlanTestBase {};
37
19
38
20
TEST_F (VPlanHCFGTest, testBuildHCFGInnerLoop) {
39
- LLVMContext Ctx;
40
21
const char *ModuleString =
41
22
" define void @f(i32* %A, i64 %N) {\n "
42
23
" entry:\n "
@@ -54,12 +35,11 @@ TEST_F(VPlanHCFGTest, testBuildHCFGInnerLoop) {
54
35
" ret void\n "
55
36
" }\n " ;
56
37
57
- SMDiagnostic Err;
58
- std::unique_ptr<Module> M = parseAssemblyString (ModuleString, Err, Ctx);
38
+ Module &M = parseModule (ModuleString);
59
39
60
- Function *F = M-> getFunction (" f" );
40
+ Function *F = M. getFunction (" f" );
61
41
BasicBlock *LoopHeader = F->getEntryBlock ().getSingleSuccessor ();
62
- auto Plan = doBuildPlan (LoopHeader);
42
+ auto Plan = buildHCFG (LoopHeader);
63
43
64
44
VPBasicBlock *Entry = Plan->getEntry ()->getEntryBasicBlock ();
65
45
EXPECT_NE (nullptr , Entry->getSingleSuccessor ());
@@ -115,7 +95,6 @@ TEST_F(VPlanHCFGTest, testBuildHCFGInnerLoop) {
115
95
}
116
96
117
97
TEST_F (VPlanHCFGTest, testVPInstructionToVPRecipesInner) {
118
- LLVMContext Ctx;
119
98
const char *ModuleString =
120
99
" define void @f(i32* %A, i64 %N) {\n "
121
100
" entry:\n "
@@ -133,12 +112,11 @@ TEST_F(VPlanHCFGTest, testVPInstructionToVPRecipesInner) {
133
112
" ret void\n "
134
113
" }\n " ;
135
114
136
- SMDiagnostic Err;
137
- std::unique_ptr<Module> M = parseAssemblyString (ModuleString, Err, Ctx);
115
+ Module &M = parseModule (ModuleString);
138
116
139
- Function *F = M-> getFunction (" f" );
117
+ Function *F = M. getFunction (" f" );
140
118
BasicBlock *LoopHeader = F->getEntryBlock ().getSingleSuccessor ();
141
- auto Plan = doBuildPlan (LoopHeader);
119
+ auto Plan = buildHCFG (LoopHeader);
142
120
143
121
LoopVectorizationLegality::InductionList Inductions;
144
122
SmallPtrSet<Instruction *, 1 > DeadInstructions;
0 commit comments