@@ -51,5 +51,29 @@ TEST_F(VPPatternMatchTest, ScalarIVSteps) {
51
51
m_SpecificInt (2 ), m_Specific (VF))));
52
52
}
53
53
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
+ }
54
78
} // namespace
55
79
} // namespace llvm
0 commit comments