Skip to content

Commit f7b716d

Browse files
committed
Fix verifier unit tests by filling out stuff necessary for corrrect types
1 parent fe36dfe commit f7b716d

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ using VPVerifierTest = VPlanTestBase;
2020
namespace {
2121
TEST_F(VPVerifierTest, VPInstructionUseBeforeDefSameBB) {
2222
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});
2425
VPInstruction *UseI = new VPInstruction(Instruction::Sub, {DefI});
26+
auto *CanIV = new VPCanonicalIVPHIRecipe(Zero, {});
2527

2628
VPBasicBlock *VPBB1 = Plan.getEntry();
2729
VPBB1->appendRecipe(UseI);
2830
VPBB1->appendRecipe(DefI);
2931

3032
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock("");
33+
VPBB2->appendRecipe(CanIV);
3134
VPRegionBlock *R1 = Plan.createVPRegionBlock(VPBB2, VPBB2, "R1");
3235
VPBlockUtils::connectBlocks(VPBB1, R1);
3336
VPBlockUtils::connectBlocks(R1, Plan.getScalarHeader());
@@ -44,9 +47,10 @@ TEST_F(VPVerifierTest, VPInstructionUseBeforeDefSameBB) {
4447

4548
TEST_F(VPVerifierTest, VPInstructionUseBeforeDefDifferentBB) {
4649
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});
4852
VPInstruction *UseI = new VPInstruction(Instruction::Sub, {DefI});
49-
auto *CanIV = new VPCanonicalIVPHIRecipe(UseI, {});
53+
auto *CanIV = new VPCanonicalIVPHIRecipe(Zero, {});
5054
VPInstruction *BranchOnCond =
5155
new VPInstruction(VPInstruction::BranchOnCond, {CanIV});
5256

@@ -73,23 +77,22 @@ TEST_F(VPVerifierTest, VPInstructionUseBeforeDefDifferentBB) {
7377
}
7478

7579
TEST_F(VPVerifierTest, VPBlendUseBeforeDefDifferentBB) {
80+
VPlan &Plan = getPlan();
7681
IntegerType *Int32 = IntegerType::get(C, 32);
7782
auto *Phi = PHINode::Create(Int32, 1);
83+
VPValue *Zero = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 0));
7884

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, {});
8287
VPInstruction *BranchOnCond =
8388
new VPInstruction(VPInstruction::BranchOnCond, {CanIV});
8489
auto *Blend = new VPBlendRecipe(Phi, {DefI});
8590

86-
VPlan &Plan = getPlan();
8791
VPBasicBlock *VPBB1 = Plan.getEntry();
8892
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock("");
8993
VPBasicBlock *VPBB3 = Plan.createVPBasicBlock("");
9094
VPBasicBlock *VPBB4 = Plan.createVPBasicBlock("");
9195

92-
VPBB1->appendRecipe(I1);
9396
VPBB2->appendRecipe(CanIV);
9497
VPBB3->appendRecipe(Blend);
9598
VPBB4->appendRecipe(DefI);
@@ -116,14 +119,15 @@ TEST_F(VPVerifierTest, VPBlendUseBeforeDefDifferentBB) {
116119
}
117120

118121
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, {});
121126
VPInstruction *BranchOnCond =
122127
new VPInstruction(VPInstruction::BranchOnCond, {CanIV});
123128
VPInstruction *BranchOnCond2 =
124129
new VPInstruction(VPInstruction::BranchOnCond, {I1});
125130

126-
VPlan &Plan = getPlan();
127131
VPBasicBlock *VPBB1 = Plan.getEntry();
128132
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock("");
129133

@@ -149,14 +153,15 @@ TEST_F(VPVerifierTest, DuplicateSuccessorsOutsideRegion) {
149153
}
150154

151155
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, {});
154160
VPInstruction *BranchOnCond =
155161
new VPInstruction(VPInstruction::BranchOnCond, {CanIV});
156162
VPInstruction *BranchOnCond2 =
157163
new VPInstruction(VPInstruction::BranchOnCond, {I1});
158164

159-
VPlan &Plan = getPlan();
160165
VPBasicBlock *VPBB1 = Plan.getEntry();
161166
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock("");
162167
VPBasicBlock *VPBB3 = Plan.createVPBasicBlock("");
@@ -186,10 +191,15 @@ TEST_F(VPVerifierTest, DuplicateSuccessorsInsideRegion) {
186191

187192
TEST_F(VPVerifierTest, BlockOutsideRegionWithParent) {
188193
VPlan &Plan = getPlan();
194+
189195
VPBasicBlock *VPBB1 = Plan.getEntry();
190196
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock("");
191197

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});
193203
VPInstruction *BranchOnCond =
194204
new VPInstruction(VPInstruction::BranchOnCond, {DefI});
195205

0 commit comments

Comments
 (0)