7
7
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
8
8
target triple = "wasm32-unknown-unknown"
9
9
10
- ; CHECK-LABEL: same_const_one_replaced_i8x16:
11
- ; CHECK-NEXT: .functype same_const_one_replaced_i8x16 (i32) -> (v128)
12
- ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 42
13
- ; CHECK-NEXT: i16x8.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
14
- ; CHECK-NEXT: i16x8.replace_lane $push[[L2:[0-9]+]]=, $pop[[L1]], 5, $0
15
- ; CHECK-NEXT: return $pop[[L2]]
16
- define <8 x i16 > @same_const_one_replaced_i8x16 (i16 %x ) {
10
+ ; CHECK-LABEL: same_const_one_replaced_i16x8:
11
+ ; CHECK-NEXT: .functype same_const_one_replaced_i16x8 (i32) -> (v128)
12
+ ; CHECK-NEXT: v128.const $push[[L0:[0-9]+]]=, 42, 42, 42, 42, 42, 0, 42, 42
13
+ ; CHECK-NEXT: i16x8.replace_lane $push[[L1:[0-9]+]]=, $pop[[L0]], 5, $0
14
+ ; CHECK-NEXT: return $pop[[L1]]
15
+ define <8 x i16 > @same_const_one_replaced_i16x8 (i16 %x ) {
17
16
%v = insertelement
18
17
<8 x i16 > <i16 42 , i16 42 , i16 42 , i16 42 , i16 42 , i16 42 , i16 42 , i16 42 >,
19
18
i16 %x ,
20
19
i32 5
21
20
ret <8 x i16 > %v
22
21
}
23
22
24
- ; CHECK-LABEL: different_const_one_replaced_i8x16 :
25
- ; CHECK-NEXT: .functype different_const_one_replaced_i8x16 (i32) -> (v128)
23
+ ; CHECK-LABEL: different_const_one_replaced_i16x8 :
24
+ ; CHECK-NEXT: .functype different_const_one_replaced_i16x8 (i32) -> (v128)
26
25
; CHECK-NEXT: v128.const $push[[L0:[0-9]+]]=, 1, -2, 3, -4, 5, 0, 7, -8
27
26
; CHECK-NEXT: i16x8.replace_lane $push[[L1:[0-9]+]]=, $pop[[L0]], 5, $0
28
27
; CHECK-NEXT: return $pop[[L1]]
29
- define <8 x i16 > @different_const_one_replaced_i8x16 (i16 %x ) {
28
+ define <8 x i16 > @different_const_one_replaced_i16x8 (i16 %x ) {
30
29
%v = insertelement
31
30
<8 x i16 > <i16 1 , i16 -2 , i16 3 , i16 -4 , i16 5 , i16 -6 , i16 7 , i16 -8 >,
32
31
i16 %x ,
@@ -36,10 +35,9 @@ define <8 x i16> @different_const_one_replaced_i8x16(i16 %x) {
36
35
37
36
; CHECK-LABEL: same_const_one_replaced_f32x4:
38
37
; CHECK-NEXT: .functype same_const_one_replaced_f32x4 (f32) -> (v128)
39
- ; CHECK-NEXT: f32.const $push[[L0:[0-9]+]]=, 0x1.5p5
40
- ; CHECK-NEXT: f32x4.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
41
- ; CHECK-NEXT: f32x4.replace_lane $push[[L2:[0-9]+]]=, $pop[[L1]], 2, $0
42
- ; CHECK-NEXT: return $pop[[L2]]
38
+ ; CHECK-NEXT: v128.const $push[[L0:[0-9]+]]=, 0x1.5p5, 0x1.5p5, 0x0p0, 0x1.5p5
39
+ ; CHECK-NEXT: f32x4.replace_lane $push[[L1:[0-9]+]]=, $pop[[L0]], 2, $0
40
+ ; CHECK-NEXT: return $pop[[L1]]
43
41
define <4 x float > @same_const_one_replaced_f32x4 (float %x ) {
44
42
%v = insertelement
45
43
<4 x float > <float 42 ., float 42 ., float 42 ., float 42 .>,
@@ -63,11 +61,8 @@ define <4 x float> @different_const_one_replaced_f32x4(float %x) {
63
61
64
62
; CHECK-LABEL: splat_common_const_i32x4:
65
63
; CHECK-NEXT: .functype splat_common_const_i32x4 () -> (v128)
66
- ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 3
67
- ; CHECK-NEXT: i32x4.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
68
- ; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 1
69
- ; CHECK-NEXT: i32x4.replace_lane $push[[L3:[0-9]+]]=, $pop[[L1]], 3, $pop[[L2]]
70
- ; CHECK-NEXT: return $pop[[L3]]
64
+ ; CHECK-NEXT: v128.const $push[[L0:[0-9]+]]=, 0, 3, 3, 1
65
+ ; CHECK-NEXT: return $pop[[L0]]
71
66
define <4 x i32 > @splat_common_const_i32x4 () {
72
67
ret <4 x i32 > <i32 undef , i32 3 , i32 3 , i32 1 >
73
68
}
@@ -92,11 +87,159 @@ define <8 x i16> @splat_common_arg_i16x8(i16 %a, i16 %b, i16 %c) {
92
87
ret <8 x i16 > %v7
93
88
}
94
89
90
+ ; CHECK-LABEL: swizzle_one_i8x16:
91
+ ; CHECK-NEXT: .functype swizzle_one_i8x16 (v128, v128) -> (v128)
92
+ ; CHECK-NEXT: v8x16.swizzle $push[[L0:[0-9]+]]=, $0, $1
93
+ ; CHECK-NEXT: return $pop[[L0]]
94
+ define <16 x i8 > @swizzle_one_i8x16 (<16 x i8 > %src , <16 x i8 > %mask ) {
95
+ %m0 = extractelement <16 x i8 > %mask , i32 0
96
+ %s0 = extractelement <16 x i8 > %src , i8 %m0
97
+ %v0 = insertelement <16 x i8 > undef , i8 %s0 , i32 0
98
+ ret <16 x i8 > %v0
99
+ }
100
+
101
+ ; CHECK-LABEL: swizzle_all_i8x16:
102
+ ; CHECK-NEXT: .functype swizzle_all_i8x16 (v128, v128) -> (v128)
103
+ ; CHECK-NEXT: v8x16.swizzle $push[[L0:[0-9]+]]=, $0, $1
104
+ ; CHECK-NEXT: return $pop[[L0]]
105
+ define <16 x i8 > @swizzle_all_i8x16 (<16 x i8 > %src , <16 x i8 > %mask ) {
106
+ %m0 = extractelement <16 x i8 > %mask , i32 0
107
+ %s0 = extractelement <16 x i8 > %src , i8 %m0
108
+ %v0 = insertelement <16 x i8 > undef , i8 %s0 , i32 0
109
+ %m1 = extractelement <16 x i8 > %mask , i32 1
110
+ %s1 = extractelement <16 x i8 > %src , i8 %m1
111
+ %v1 = insertelement <16 x i8 > %v0 , i8 %s1 , i32 1
112
+ %m2 = extractelement <16 x i8 > %mask , i32 2
113
+ %s2 = extractelement <16 x i8 > %src , i8 %m2
114
+ %v2 = insertelement <16 x i8 > %v1 , i8 %s2 , i32 2
115
+ %m3 = extractelement <16 x i8 > %mask , i32 3
116
+ %s3 = extractelement <16 x i8 > %src , i8 %m3
117
+ %v3 = insertelement <16 x i8 > %v2 , i8 %s3 , i32 3
118
+ %m4 = extractelement <16 x i8 > %mask , i32 4
119
+ %s4 = extractelement <16 x i8 > %src , i8 %m4
120
+ %v4 = insertelement <16 x i8 > %v3 , i8 %s4 , i32 4
121
+ %m5 = extractelement <16 x i8 > %mask , i32 5
122
+ %s5 = extractelement <16 x i8 > %src , i8 %m5
123
+ %v5 = insertelement <16 x i8 > %v4 , i8 %s5 , i32 5
124
+ %m6 = extractelement <16 x i8 > %mask , i32 6
125
+ %s6 = extractelement <16 x i8 > %src , i8 %m6
126
+ %v6 = insertelement <16 x i8 > %v5 , i8 %s6 , i32 6
127
+ %m7 = extractelement <16 x i8 > %mask , i32 7
128
+ %s7 = extractelement <16 x i8 > %src , i8 %m7
129
+ %v7 = insertelement <16 x i8 > %v6 , i8 %s7 , i32 7
130
+ %m8 = extractelement <16 x i8 > %mask , i32 8
131
+ %s8 = extractelement <16 x i8 > %src , i8 %m8
132
+ %v8 = insertelement <16 x i8 > %v7 , i8 %s8 , i32 8
133
+ %m9 = extractelement <16 x i8 > %mask , i32 9
134
+ %s9 = extractelement <16 x i8 > %src , i8 %m9
135
+ %v9 = insertelement <16 x i8 > %v8 , i8 %s9 , i32 9
136
+ %m10 = extractelement <16 x i8 > %mask , i32 10
137
+ %s10 = extractelement <16 x i8 > %src , i8 %m10
138
+ %v10 = insertelement <16 x i8 > %v9 , i8 %s10 , i32 10
139
+ %m11 = extractelement <16 x i8 > %mask , i32 11
140
+ %s11 = extractelement <16 x i8 > %src , i8 %m11
141
+ %v11 = insertelement <16 x i8 > %v10 , i8 %s11 , i32 11
142
+ %m12 = extractelement <16 x i8 > %mask , i32 12
143
+ %s12 = extractelement <16 x i8 > %src , i8 %m12
144
+ %v12 = insertelement <16 x i8 > %v11 , i8 %s12 , i32 12
145
+ %m13 = extractelement <16 x i8 > %mask , i32 13
146
+ %s13 = extractelement <16 x i8 > %src , i8 %m13
147
+ %v13 = insertelement <16 x i8 > %v12 , i8 %s13 , i32 13
148
+ %m14 = extractelement <16 x i8 > %mask , i32 14
149
+ %s14 = extractelement <16 x i8 > %src , i8 %m14
150
+ %v14 = insertelement <16 x i8 > %v13 , i8 %s14 , i32 14
151
+ %m15 = extractelement <16 x i8 > %mask , i32 15
152
+ %s15 = extractelement <16 x i8 > %src , i8 %m15
153
+ %v15 = insertelement <16 x i8 > %v14 , i8 %s15 , i32 15
154
+ ret <16 x i8 > %v15
155
+ }
156
+
157
+ ; CHECK-LABEL: swizzle_one_i16x8:
158
+ ; CHECK-NEXT: .functype swizzle_one_i16x8 (v128, v128) -> (v128)
159
+ ; CHECK-NOT: swizzle
160
+ ; CHECK: return
161
+ define <8 x i16 > @swizzle_one_i16x8 (<8 x i16 > %src , <8 x i16 > %mask ) {
162
+ %m0 = extractelement <8 x i16 > %mask , i32 0
163
+ %s0 = extractelement <8 x i16 > %src , i16 %m0
164
+ %v0 = insertelement <8 x i16 > undef , i16 %s0 , i32 0
165
+ ret <8 x i16 > %v0
166
+ }
167
+
168
+ ; CHECK-LABEL: mashup_swizzle_i8x16:
169
+ ; CHECK-NEXT: .functype mashup_swizzle_i8x16 (v128, v128, i32) -> (v128)
170
+ ; CHECK-NEXT: v8x16.swizzle $push[[L0:[0-9]+]]=, $0, $1
171
+ ; CHECK: i8x16.replace_lane
172
+ ; CHECK: i8x16.replace_lane
173
+ ; CHECK: i8x16.replace_lane
174
+ ; CHECK: i8x16.replace_lane
175
+ ; CHECK: return
176
+ define <16 x i8 > @mashup_swizzle_i8x16 (<16 x i8 > %src , <16 x i8 > %mask , i8 %splatted ) {
177
+ ; swizzle 0
178
+ %m0 = extractelement <16 x i8 > %mask , i32 0
179
+ %s0 = extractelement <16 x i8 > %src , i8 %m0
180
+ %v0 = insertelement <16 x i8 > undef , i8 %s0 , i32 0
181
+ ; swizzle 7
182
+ %m1 = extractelement <16 x i8 > %mask , i32 7
183
+ %s1 = extractelement <16 x i8 > %src , i8 %m1
184
+ %v1 = insertelement <16 x i8 > %v0 , i8 %s1 , i32 7
185
+ ; splat 3
186
+ %v2 = insertelement <16 x i8 > %v1 , i8 %splatted , i32 3
187
+ ; splat 12
188
+ %v3 = insertelement <16 x i8 > %v2 , i8 %splatted , i32 12
189
+ ; const 4
190
+ %v4 = insertelement <16 x i8 > %v3 , i8 42 , i32 4
191
+ ; const 14
192
+ %v5 = insertelement <16 x i8 > %v4 , i8 42 , i32 14
193
+ ret <16 x i8 > %v5
194
+ }
195
+
196
+ ; CHECK-LABEL: mashup_const_i8x16:
197
+ ; CHECK-NEXT: .functype mashup_const_i8x16 (v128, v128, i32) -> (v128)
198
+ ; CHECK: v128.const $push[[L0:[0-9]+]]=, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 0
199
+ ; CHECK: i8x16.replace_lane
200
+ ; CHECK: i8x16.replace_lane
201
+ ; CHECK: i8x16.replace_lane
202
+ ; CHECK: return
203
+ define <16 x i8 > @mashup_const_i8x16 (<16 x i8 > %src , <16 x i8 > %mask , i8 %splatted ) {
204
+ ; swizzle 0
205
+ %m0 = extractelement <16 x i8 > %mask , i32 0
206
+ %s0 = extractelement <16 x i8 > %src , i8 %m0
207
+ %v0 = insertelement <16 x i8 > undef , i8 %s0 , i32 0
208
+ ; splat 3
209
+ %v1 = insertelement <16 x i8 > %v0 , i8 %splatted , i32 3
210
+ ; splat 12
211
+ %v2 = insertelement <16 x i8 > %v1 , i8 %splatted , i32 12
212
+ ; const 4
213
+ %v3 = insertelement <16 x i8 > %v2 , i8 42 , i32 4
214
+ ; const 14
215
+ %v4 = insertelement <16 x i8 > %v3 , i8 42 , i32 14
216
+ ret <16 x i8 > %v4
217
+ }
218
+
219
+ ; CHECK-LABEL: mashup_splat_i8x16:
220
+ ; CHECK-NEXT: .functype mashup_splat_i8x16 (v128, v128, i32) -> (v128)
221
+ ; CHECK: i8x16.splat $push[[L0:[0-9]+]]=, $2
222
+ ; CHECK: i8x16.replace_lane
223
+ ; CHECK: i8x16.replace_lane
224
+ ; CHECK: return
225
+ define <16 x i8 > @mashup_splat_i8x16 (<16 x i8 > %src , <16 x i8 > %mask , i8 %splatted ) {
226
+ ; swizzle 0
227
+ %m0 = extractelement <16 x i8 > %mask , i32 0
228
+ %s0 = extractelement <16 x i8 > %src , i8 %m0
229
+ %v0 = insertelement <16 x i8 > undef , i8 %s0 , i32 0
230
+ ; splat 3
231
+ %v1 = insertelement <16 x i8 > %v0 , i8 %splatted , i32 3
232
+ ; splat 12
233
+ %v2 = insertelement <16 x i8 > %v1 , i8 %splatted , i32 12
234
+ ; const 4
235
+ %v3 = insertelement <16 x i8 > %v2 , i8 42 , i32 4
236
+ ret <16 x i8 > %v3
237
+ }
238
+
95
239
; CHECK-LABEL: undef_const_insert_f32x4:
96
240
; CHECK-NEXT: .functype undef_const_insert_f32x4 () -> (v128)
97
- ; CHECK-NEXT: f32.const $push[[L0:[0-9]+]]=, 0x1.5p5
98
- ; CHECK-NEXT: f32x4.splat $push[[L1:[0-9]+]]=, $pop[[L0]]
99
- ; CHECK-NEXT: return $pop[[L1]]
241
+ ; CHECK-NEXT: v128.const $push[[L0:[0-9]+]]=, 0x0p0, 0x1.5p5, 0x0p0, 0x0p0
242
+ ; CHECK-NEXT: return $pop[[L0]]
100
243
define <4 x float > @undef_const_insert_f32x4 () {
101
244
%v = insertelement <4 x float > undef , float 42 ., i32 1
102
245
ret <4 x float > %v
0 commit comments