@@ -38,6 +38,12 @@ class IRBuilderSpec : XCTestCase {
3838 var g2 = builder. addGlobal ( " b " , type: IntType . int32)
3939 g2. initializer = Int32 ( 1 )
4040
41+ // IRBUILDERARITH-NEXT: @vec1 = global <8 x i64> <i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1>
42+ // IRBUILDERARITH-NEXT: @vec2 = global <8 x i64> <i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2, i64 2>
43+ let vecTy = VectorType ( elementType: IntType . int32, count: 8 )
44+ let gVec1 = builder. addGlobal ( " vec1 " , initializer: vecTy. constant ( [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ] ) )
45+ let gVec2 = builder. addGlobal ( " vec2 " , initializer: vecTy. constant ( [ 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ] ) )
46+
4147 // IRBUILDERARITH: define void @main() {
4248 let main = builder. addFunction ( " main " ,
4349 type: FunctionType ( argTypes: [ ] ,
@@ -51,6 +57,12 @@ class IRBuilderSpec : XCTestCase {
5157 // IRBUILDERARITH-NEXT: [[B_LOAD:%[0-9]+]] = load i32, i32* @b
5258 let vg2 = builder. buildLoad ( g2)
5359
60+ // IRBUILDERARITH-NEXT: [[VEC1_LOAD:%[0-9]+]] = load <8 x i64>, <8 x i64>* @vec1
61+ let vgVec1 = builder. buildLoad ( gVec1)
62+
63+ // IRBUILDERARITH-NEXT: [[VEC2_LOAD:%[0-9]+]] = load <8 x i64>, <8 x i64>* @vec2
64+ let vgVec2 = builder. buildLoad ( gVec2)
65+
5466 // IRBUILDERARITH-NEXT: {{%[0-9]+}} = add i32 [[A_LOAD]], [[B_LOAD]]
5567 _ = builder. buildAdd ( vg1, vg2)
5668 // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub i32 [[A_LOAD]], [[B_LOAD]]
@@ -76,6 +88,17 @@ class IRBuilderSpec : XCTestCase {
7688 // IRBUILDERARITH-NEXT: {{%[0-9]+}} = mul nuw i32 [[A_LOAD]], [[B_LOAD]]
7789 _ = builder. buildMul ( vg1, vg2, overflowBehavior: . noUnsignedWrap)
7890
91+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = add <8 x i64> [[VEC1_LOAD]], [[VEC2_LOAD]]
92+ _ = builder. buildAdd ( vgVec1, vgVec2)
93+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub <8 x i64> [[VEC1_LOAD]], [[VEC2_LOAD]]
94+ _ = builder. buildSub ( vgVec1, vgVec2)
95+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = mul <8 x i64> [[VEC1_LOAD]], [[VEC2_LOAD]]
96+ _ = builder. buildMul ( vgVec1, vgVec2)
97+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sdiv <8 x i64> [[VEC1_LOAD]], [[VEC2_LOAD]]
98+ _ = builder. buildDiv ( vgVec1, vgVec2, signed: true )
99+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = udiv <8 x i64> [[VEC1_LOAD]], [[VEC2_LOAD]]
100+ _ = builder. buildDiv ( vgVec1, vgVec2, signed: false )
101+
79102 // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub i32 0, [[A_LOAD]]
80103 _ = builder. buildNeg ( vg1, overflowBehavior: . default)
81104 // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub nuw i32 0, [[A_LOAD]]
0 commit comments