@@ -38,6 +38,12 @@ class IRBuilderSpec : XCTestCase {
38
38
var g2 = builder. addGlobal ( " b " , type: IntType . int32)
39
39
g2. initializer = Int32 ( 1 )
40
40
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
+
41
47
// IRBUILDERARITH: define void @main() {
42
48
let main = builder. addFunction ( " main " ,
43
49
type: FunctionType ( argTypes: [ ] ,
@@ -51,6 +57,12 @@ class IRBuilderSpec : XCTestCase {
51
57
// IRBUILDERARITH-NEXT: [[B_LOAD:%[0-9]+]] = load i32, i32* @b
52
58
let vg2 = builder. buildLoad ( g2)
53
59
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
+
54
66
// IRBUILDERARITH-NEXT: {{%[0-9]+}} = add i32 [[A_LOAD]], [[B_LOAD]]
55
67
_ = builder. buildAdd ( vg1, vg2)
56
68
// IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub i32 [[A_LOAD]], [[B_LOAD]]
@@ -76,6 +88,17 @@ class IRBuilderSpec : XCTestCase {
76
88
// IRBUILDERARITH-NEXT: {{%[0-9]+}} = mul nuw i32 [[A_LOAD]], [[B_LOAD]]
77
89
_ = builder. buildMul ( vg1, vg2, overflowBehavior: . noUnsignedWrap)
78
90
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
+
79
102
// IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub i32 0, [[A_LOAD]]
80
103
_ = builder. buildNeg ( vg1, overflowBehavior: . default)
81
104
// IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub nuw i32 0, [[A_LOAD]]
0 commit comments