Skip to content

Commit e8a9716

Browse files
committed
[VPlan] Add unit-test
1 parent 440600d commit e8a9716

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

llvm/unittests/Transforms/Vectorize/VPlanPatternMatchTest.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,29 @@ TEST_F(VPPatternMatchTest, ScalarIVSteps) {
5151
m_SpecificInt(2), m_Specific(VF))));
5252
}
5353

54+
TEST_F(VPPatternMatchTest, GetElementPtr) {
55+
VPlan &Plan = getPlan();
56+
VPBasicBlock *VPBB = Plan.createVPBasicBlock("entry");
57+
VPBuilder Builder(VPBB);
58+
59+
IntegerType *I64Ty = IntegerType::get(C, 64);
60+
VPValue *One = Plan.getOrAddLiveIn(ConstantInt::get(I64Ty, 1));
61+
VPValue *Two = Plan.getOrAddLiveIn(ConstantInt::get(I64Ty, 2));
62+
VPValue *Ptr =
63+
Plan.getOrAddLiveIn(Constant::getNullValue(PointerType::get(C, 0)));
64+
65+
VPInstruction *PtrAdd = Builder.createPtrAdd(Ptr, One);
66+
VPInstruction *WidePtrAdd = Builder.createWidePtrAdd(Ptr, Two);
67+
68+
using namespace VPlanPatternMatch;
69+
ASSERT_TRUE(
70+
match(PtrAdd, m_GetElementPtr(m_Specific(Ptr), m_SpecificInt(1))));
71+
ASSERT_FALSE(
72+
match(PtrAdd, m_GetElementPtr(m_Specific(Ptr), m_SpecificInt(2))));
73+
ASSERT_TRUE(
74+
match(WidePtrAdd, m_GetElementPtr(m_Specific(Ptr), m_SpecificInt(2))));
75+
ASSERT_FALSE(
76+
match(WidePtrAdd, m_GetElementPtr(m_Specific(Ptr), m_SpecificInt(1))));
77+
}
5478
} // namespace
5579
} // namespace llvm

0 commit comments

Comments
 (0)