@@ -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: [ ] ,
@@ -46,44 +52,60 @@ class IRBuilderSpec : XCTestCase {
46
52
let entry = main. appendBasicBlock ( named: " entry " )
47
53
builder. positionAtEnd ( of: entry)
48
54
49
- // IRBUILDERARITH-NEXT: %0 = load i32, i32* @a
55
+ // IRBUILDERARITH-NEXT: [[A_LOAD:%[0-9]+]] = load i32, i32* @a
50
56
let vg1 = builder. buildLoad ( g1)
51
- // IRBUILDERARITH-NEXT: %1 = load i32, i32* @b
57
+ // IRBUILDERARITH-NEXT: [[B_LOAD:%[0-9]+]] = load i32, i32* @b
52
58
let vg2 = builder. buildLoad ( g2)
53
59
54
- // IRBUILDERARITH-NEXT: %2 = add i32 %0, %1
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
+
66
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = add i32 [[A_LOAD]], [[B_LOAD]]
55
67
_ = builder. buildAdd ( vg1, vg2)
56
- // IRBUILDERARITH-NEXT: %3 = sub i32 %0, %1
68
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub i32 [[A_LOAD]], [[B_LOAD]]
57
69
_ = builder. buildSub ( vg1, vg2)
58
- // IRBUILDERARITH-NEXT: %4 = mul i32 %0, %1
70
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = mul i32 [[A_LOAD]], [[B_LOAD]]
59
71
_ = builder. buildMul ( vg1, vg2)
60
- // IRBUILDERARITH-NEXT: %5 = sdiv i32 %0, %1
72
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sdiv i32 [[A_LOAD]], [[B_LOAD]]
61
73
_ = builder. buildDiv ( vg1, vg2, signed: true )
62
- // IRBUILDERARITH-NEXT: %6 = udiv i32 %0, %1
74
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = udiv i32 [[A_LOAD]], [[B_LOAD]]
63
75
_ = builder. buildDiv ( vg1, vg2, signed: false )
64
76
65
- // IRBUILDERARITH-NEXT: %7 = add nsw i32 %0, %1
77
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = add nsw i32 [[A_LOAD]], [[B_LOAD]]
66
78
_ = builder. buildAdd ( vg1, vg2, overflowBehavior: . noSignedWrap)
67
- // IRBUILDERARITH-NEXT: %8 = sub nsw i32 %0, %1
79
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub nsw i32 [[A_LOAD]], [[B_LOAD]]
68
80
_ = builder. buildSub ( vg1, vg2, overflowBehavior: . noSignedWrap)
69
- // IRBUILDERARITH-NEXT: %9 = mul nsw i32 %0, %1
81
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = mul nsw i32 [[A_LOAD]], [[B_LOAD]]
70
82
_ = builder. buildMul ( vg1, vg2, overflowBehavior: . noSignedWrap)
71
83
72
- // IRBUILDERARITH-NEXT: %10 = add nuw i32 %0, %1
84
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = add nuw i32 [[A_LOAD]], [[B_LOAD]]
73
85
_ = builder. buildAdd ( vg1, vg2, overflowBehavior: . noUnsignedWrap)
74
- // IRBUILDERARITH-NEXT: %11 = sub nuw i32 %0, %1
86
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub nuw i32 [[A_LOAD]], [[B_LOAD]]
75
87
_ = builder. buildSub ( vg1, vg2, overflowBehavior: . noUnsignedWrap)
76
- // IRBUILDERARITH-NEXT: %12 = mul nuw i32 %0, %1
88
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = mul nuw i32 [[A_LOAD]], [[B_LOAD]]
77
89
_ = builder. buildMul ( vg1, vg2, overflowBehavior: . noUnsignedWrap)
78
90
79
- // IRBUILDERARITH-NEXT: %13 = sub i32 0, %0
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
+
102
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub i32 0, [[A_LOAD]]
80
103
_ = builder. buildNeg ( vg1, overflowBehavior: . default)
81
- // IRBUILDERARITH-NEXT: %14 = sub nuw i32 0, %0
104
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub nuw i32 0, [[A_LOAD]]
82
105
_ = builder. buildNeg ( vg1, overflowBehavior: . noUnsignedWrap)
83
- // IRBUILDERARITH-NEXT: %15 = sub nsw i32 0, %0
106
+ // IRBUILDERARITH-NEXT: {{%[0-9]+}} = sub nsw i32 0, [[A_LOAD]]
84
107
_ = builder. buildNeg ( vg1, overflowBehavior: . noSignedWrap)
85
108
86
-
87
109
// IRBUILDERARITH-NEXT: ret void
88
110
builder. buildRetVoid ( )
89
111
// IRBUILDERARITH-NEXT: }
0 commit comments