@@ -20,14 +20,17 @@ using VPVerifierTest = VPlanTestBase;
20
20
namespace {
21
21
TEST_F (VPVerifierTest, VPInstructionUseBeforeDefSameBB) {
22
22
VPlan &Plan = getPlan ();
23
- VPInstruction *DefI = new VPInstruction (Instruction::Add, {});
23
+ VPValue *Zero = Plan.getOrAddLiveIn (ConstantInt::get (Type::getInt32Ty (C), 0 ));
24
+ VPInstruction *DefI = new VPInstruction (Instruction::Add, {Zero});
24
25
VPInstruction *UseI = new VPInstruction (Instruction::Sub, {DefI});
26
+ auto *CanIV = new VPCanonicalIVPHIRecipe (Zero, {});
25
27
26
28
VPBasicBlock *VPBB1 = Plan.getEntry ();
27
29
VPBB1->appendRecipe (UseI);
28
30
VPBB1->appendRecipe (DefI);
29
31
30
32
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock (" " );
33
+ VPBB2->appendRecipe (CanIV);
31
34
VPRegionBlock *R1 = Plan.createVPRegionBlock (VPBB2, VPBB2, " R1" );
32
35
VPBlockUtils::connectBlocks (VPBB1, R1);
33
36
VPBlockUtils::connectBlocks (R1, Plan.getScalarHeader ());
@@ -44,9 +47,10 @@ TEST_F(VPVerifierTest, VPInstructionUseBeforeDefSameBB) {
44
47
45
48
TEST_F (VPVerifierTest, VPInstructionUseBeforeDefDifferentBB) {
46
49
VPlan &Plan = getPlan ();
47
- VPInstruction *DefI = new VPInstruction (Instruction::Add, {});
50
+ VPValue *Zero = Plan.getOrAddLiveIn (ConstantInt::get (Type::getInt32Ty (C), 0 ));
51
+ VPInstruction *DefI = new VPInstruction (Instruction::Add, {Zero});
48
52
VPInstruction *UseI = new VPInstruction (Instruction::Sub, {DefI});
49
- auto *CanIV = new VPCanonicalIVPHIRecipe (UseI , {});
53
+ auto *CanIV = new VPCanonicalIVPHIRecipe (Zero , {});
50
54
VPInstruction *BranchOnCond =
51
55
new VPInstruction (VPInstruction::BranchOnCond, {CanIV});
52
56
@@ -73,23 +77,22 @@ TEST_F(VPVerifierTest, VPInstructionUseBeforeDefDifferentBB) {
73
77
}
74
78
75
79
TEST_F (VPVerifierTest, VPBlendUseBeforeDefDifferentBB) {
80
+ VPlan &Plan = getPlan ();
76
81
IntegerType *Int32 = IntegerType::get (C, 32 );
77
82
auto *Phi = PHINode::Create (Int32, 1 );
83
+ VPValue *Zero = Plan.getOrAddLiveIn (ConstantInt::get (Int32, 0 ));
78
84
79
- VPInstruction *I1 = new VPInstruction (Instruction::Add, {});
80
- VPInstruction *DefI = new VPInstruction (Instruction::Add, {});
81
- auto *CanIV = new VPCanonicalIVPHIRecipe (I1, {});
85
+ VPInstruction *DefI = new VPInstruction (Instruction::Add, {Zero});
86
+ auto *CanIV = new VPCanonicalIVPHIRecipe (Zero, {});
82
87
VPInstruction *BranchOnCond =
83
88
new VPInstruction (VPInstruction::BranchOnCond, {CanIV});
84
89
auto *Blend = new VPBlendRecipe (Phi, {DefI});
85
90
86
- VPlan &Plan = getPlan ();
87
91
VPBasicBlock *VPBB1 = Plan.getEntry ();
88
92
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock (" " );
89
93
VPBasicBlock *VPBB3 = Plan.createVPBasicBlock (" " );
90
94
VPBasicBlock *VPBB4 = Plan.createVPBasicBlock (" " );
91
95
92
- VPBB1->appendRecipe (I1);
93
96
VPBB2->appendRecipe (CanIV);
94
97
VPBB3->appendRecipe (Blend);
95
98
VPBB4->appendRecipe (DefI);
@@ -116,14 +119,15 @@ TEST_F(VPVerifierTest, VPBlendUseBeforeDefDifferentBB) {
116
119
}
117
120
118
121
TEST_F (VPVerifierTest, DuplicateSuccessorsOutsideRegion) {
119
- VPInstruction *I1 = new VPInstruction (Instruction::Add, {});
120
- auto *CanIV = new VPCanonicalIVPHIRecipe (I1, {});
122
+ VPlan &Plan = getPlan ();
123
+ VPValue *Zero = Plan.getOrAddLiveIn (ConstantInt::get (Type::getInt32Ty (C), 0 ));
124
+ VPInstruction *I1 = new VPInstruction (Instruction::Add, {Zero});
125
+ auto *CanIV = new VPCanonicalIVPHIRecipe (Zero, {});
121
126
VPInstruction *BranchOnCond =
122
127
new VPInstruction (VPInstruction::BranchOnCond, {CanIV});
123
128
VPInstruction *BranchOnCond2 =
124
129
new VPInstruction (VPInstruction::BranchOnCond, {I1});
125
130
126
- VPlan &Plan = getPlan ();
127
131
VPBasicBlock *VPBB1 = Plan.getEntry ();
128
132
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock (" " );
129
133
@@ -149,14 +153,15 @@ TEST_F(VPVerifierTest, DuplicateSuccessorsOutsideRegion) {
149
153
}
150
154
151
155
TEST_F (VPVerifierTest, DuplicateSuccessorsInsideRegion) {
152
- VPInstruction *I1 = new VPInstruction (Instruction::Add, {});
153
- auto *CanIV = new VPCanonicalIVPHIRecipe (I1, {});
156
+ VPlan &Plan = getPlan ();
157
+ VPValue *Zero = Plan.getOrAddLiveIn (ConstantInt::get (Type::getInt32Ty (C), 0 ));
158
+ VPInstruction *I1 = new VPInstruction (Instruction::Add, {Zero});
159
+ auto *CanIV = new VPCanonicalIVPHIRecipe (Zero, {});
154
160
VPInstruction *BranchOnCond =
155
161
new VPInstruction (VPInstruction::BranchOnCond, {CanIV});
156
162
VPInstruction *BranchOnCond2 =
157
163
new VPInstruction (VPInstruction::BranchOnCond, {I1});
158
164
159
- VPlan &Plan = getPlan ();
160
165
VPBasicBlock *VPBB1 = Plan.getEntry ();
161
166
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock (" " );
162
167
VPBasicBlock *VPBB3 = Plan.createVPBasicBlock (" " );
@@ -186,10 +191,15 @@ TEST_F(VPVerifierTest, DuplicateSuccessorsInsideRegion) {
186
191
187
192
TEST_F (VPVerifierTest, BlockOutsideRegionWithParent) {
188
193
VPlan &Plan = getPlan ();
194
+
189
195
VPBasicBlock *VPBB1 = Plan.getEntry ();
190
196
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock (" " );
191
197
192
- VPInstruction *DefI = new VPInstruction (Instruction::Add, {});
198
+ VPValue *Zero = Plan.getOrAddLiveIn (ConstantInt::get (Type::getInt32Ty (C), 0 ));
199
+ auto *CanIV = new VPCanonicalIVPHIRecipe (Zero, {});
200
+ VPBB2->appendRecipe (CanIV);
201
+
202
+ VPInstruction *DefI = new VPInstruction (Instruction::Add, {Zero});
193
203
VPInstruction *BranchOnCond =
194
204
new VPInstruction (VPInstruction::BranchOnCond, {DefI});
195
205
0 commit comments