1 ; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+unimplemented-simd128 | FileCheck %s
3 ; Test that vector selects of various varieties lower correctly to bitselects.
5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
8 ; ==============================================================================
10 ; ==============================================================================
11 ; CHECK-LABEL: vselect_v16i8:
12 ; CHECK-NEXT: .functype vselect_v16i8 (v128, v128, v128) -> (v128){{$}}
13 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 7{{$}}
14 ; CHECK-NEXT: i8x16.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
15 ; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 7{{$}}
16 ; CHECK-NEXT: i8x16.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
17 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
18 ; CHECK-NEXT: return $pop[[R]]{{$}}
19 define <16 x i8> @vselect_v16i8(<16 x i1> %c, <16 x i8> %x, <16 x i8> %y) {
20 %res = select <16 x i1> %c, <16 x i8> %x, <16 x i8> %y
24 ; CHECK-LABEL: select_v16i8:
25 ; CHECK-NEXT: .functype select_v16i8 (i32, v128, v128) -> (v128){{$}}
26 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
27 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
28 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
29 ; CHECK-NEXT: i8x16.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
30 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
31 ; CHECK-NEXT: return $pop[[R]]{{$}}
32 define <16 x i8> @select_v16i8(i1 zeroext %c, <16 x i8> %x, <16 x i8> %y) {
33 %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
37 ; CHECK-LABEL: select_cmp_v16i8:
38 ; CHECK-NEXT: .functype select_cmp_v16i8 (i32, v128, v128) -> (v128){{$}}
39 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31
40 ; CHECK-NEXT: i32.shr_s $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
41 ; CHECK-NEXT: i8x16.splat $push[[L2:[0-9]+]]=, $pop[[L1]]{{$}}
42 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L2]]{{$}}
43 ; CHECK-NEXT: return $pop[[R]]{{$}}
44 define <16 x i8> @select_cmp_v16i8(i32 %i, <16 x i8> %x, <16 x i8> %y) {
45 %c = icmp slt i32 %i, 0
46 %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
50 ; CHECK-LABEL: select_ne_v16i8:
51 ; CHECK-NEXT: .functype select_ne_v16i8 (i32, v128, v128) -> (v128){{$}}
52 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
53 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
54 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
55 ; CHECK-NEXT: i8x16.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
56 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
57 ; CHECK-NEXT: return $pop[[R]]{{$}}
58 define <16 x i8> @select_ne_v16i8(i32 %i, <16 x i8> %x, <16 x i8> %y) {
59 %c = icmp ne i32 %i, 0
60 %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
64 ; CHECK-LABEL: select_eq_v16i8:
65 ; CHECK-NEXT: .functype select_eq_v16i8 (i32, v128, v128) -> (v128){{$}}
66 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
67 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, -1{{$}}
68 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
69 ; CHECK-NEXT: i8x16.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
70 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
71 ; CHECK-NEXT: return $pop[[R]]{{$}}
72 define <16 x i8> @select_eq_v16i8(i32 %i, <16 x i8> %x, <16 x i8> %y) {
73 %c = icmp eq i32 %i, 0
74 %res = select i1 %c, <16 x i8> %x, <16 x i8> %y
78 ; ==============================================================================
80 ; ==============================================================================
81 ; CHECK-LABEL: vselect_v8i16:
82 ; CHECK-NEXT: .functype vselect_v8i16 (v128, v128, v128) -> (v128){{$}}
83 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 15{{$}}
84 ; CHECK-NEXT: i16x8.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
85 ; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 15{{$}}
86 ; CHECK-NEXT: i16x8.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
87 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
88 ; CHECK-NEXT: return $pop[[R]]{{$}}
89 define <8 x i16> @vselect_v8i16(<8 x i1> %c, <8 x i16> %x, <8 x i16> %y) {
90 %res = select <8 x i1> %c, <8 x i16> %x, <8 x i16> %y
94 ; CHECK-LABEL: select_v8i16:
95 ; CHECK-NEXT: .functype select_v8i16 (i32, v128, v128) -> (v128){{$}}
96 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
97 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
98 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
99 ; CHECK-NEXT: i16x8.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
100 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
101 ; CHECK-NEXT: return $pop[[R]]{{$}}
102 define <8 x i16> @select_v8i16(i1 zeroext %c, <8 x i16> %x, <8 x i16> %y) {
103 %res = select i1 %c, <8 x i16> %x, <8 x i16> %y
107 ; CHECK-LABEL: select_cmp_v8i16:
108 ; CHECK-NEXT: .functype select_cmp_v8i16 (i32, v128, v128) -> (v128){{$}}
109 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31{{$}}
110 ; CHECK-NEXT: i32.shr_s $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
111 ; CHECK-NEXT: i16x8.splat $push[[L2:[0-9]+]]=, $pop[[L1]]{{$}}
112 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L2]]{{$}}
113 ; CHECK-NEXT: return $pop[[R]]{{$}}
114 define <8 x i16> @select_cmp_v8i16(i32 %i, <8 x i16> %x, <8 x i16> %y) {
115 %c = icmp slt i32 %i, 0
116 %res = select i1 %c, <8 x i16> %x, <8 x i16> %y
120 ; CHECK-LABEL: select_ne_v8i16:
121 ; CHECK-NEXT: .functype select_ne_v8i16 (i32, v128, v128) -> (v128){{$}}
122 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
123 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
124 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
125 ; CHECK-NEXT: i16x8.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
126 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
127 ; CHECK-NEXT: return $pop[[R]]{{$}}
128 define <8 x i16> @select_ne_v8i16(i32 %i, <8 x i16> %x, <8 x i16> %y) {
129 %c = icmp ne i32 %i, 0
130 %res = select i1 %c, <8 x i16> %x, <8 x i16> %y
134 ; CHECK-LABEL: select_eq_v8i16:
135 ; CHECK-NEXT: .functype select_eq_v8i16 (i32, v128, v128) -> (v128){{$}}
136 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
137 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, -1{{$}}
138 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
139 ; CHECK-NEXT: i16x8.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
140 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
141 ; CHECK-NEXT: return $pop[[R]]{{$}}
142 define <8 x i16> @select_eq_v8i16(i32 %i, <8 x i16> %x, <8 x i16> %y) {
143 %c = icmp eq i32 %i, 0
144 %res = select i1 %c, <8 x i16> %x, <8 x i16> %y
148 ; ==============================================================================
150 ; ==============================================================================
151 ; CHECK-LABEL: vselect_v4i32:
152 ; CHECK-NEXT: .functype vselect_v4i32 (v128, v128, v128) -> (v128){{$}}
153 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31{{$}}
154 ; CHECK-NEXT: i32x4.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
155 ; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 31{{$}}
156 ; CHECK-NEXT: i32x4.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
157 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
158 ; CHECK-NEXT: return $pop[[R]]{{$}}
159 define <4 x i32> @vselect_v4i32(<4 x i1> %c, <4 x i32> %x, <4 x i32> %y) {
160 %res = select <4 x i1> %c, <4 x i32> %x, <4 x i32> %y
165 ; CHECK-LABEL: select_v4i32:
166 ; CHECK-NEXT: .functype select_v4i32 (i32, v128, v128) -> (v128){{$}}
167 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
168 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
169 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
170 ; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
171 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
172 ; CHECK-NEXT: return $pop[[R]]{{$}}
173 define <4 x i32> @select_v4i32(i1 zeroext %c, <4 x i32> %x, <4 x i32> %y) {
174 %res = select i1 %c, <4 x i32> %x, <4 x i32> %y
178 ; CHECK-LABEL: select_cmp_v4i32:
179 ; CHECK-NEXT: .functype select_cmp_v4i32 (i32, v128, v128) -> (v128){{$}}
180 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31{{$}}
181 ; CHECK-NEXT: i32.shr_s $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
182 ; CHECK-NEXT: i32x4.splat $push[[L2:[0-9]+]]=, $pop[[L1]]{{$}}
183 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L2]]{{$}}
184 ; CHECK-NEXT: return $pop[[R]]{{$}}
185 define <4 x i32> @select_cmp_v4i32(i32 %i, <4 x i32> %x, <4 x i32> %y) {
186 %c = icmp slt i32 %i, 0
187 %res = select i1 %c, <4 x i32> %x, <4 x i32> %y
191 ; CHECK-LABEL: select_ne_v4i32:
192 ; CHECK-NEXT: .functype select_ne_v4i32 (i32, v128, v128) -> (v128){{$}}
193 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
194 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
195 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
196 ; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
197 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
198 ; CHECK-NEXT: return $pop[[R]]{{$}}
199 define <4 x i32> @select_ne_v4i32(i32 %i, <4 x i32> %x, <4 x i32> %y) {
200 %c = icmp ne i32 %i, 0
201 %res = select i1 %c, <4 x i32> %x, <4 x i32> %y
205 ; CHECK-LABEL: select_eq_v4i32:
206 ; CHECK-NEXT: .functype select_eq_v4i32 (i32, v128, v128) -> (v128){{$}}
207 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
208 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, -1{{$}}
209 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
210 ; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
211 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
212 ; CHECK-NEXT: return $pop[[R]]{{$}}
213 define <4 x i32> @select_eq_v4i32(i32 %i, <4 x i32> %x, <4 x i32> %y) {
214 %c = icmp eq i32 %i, 0
215 %res = select i1 %c, <4 x i32> %x, <4 x i32> %y
219 ; ==============================================================================
221 ; ==============================================================================
222 ; CHECK-LABEL: vselect_v2i64:
223 ; CHECK-NEXT: .functype vselect_v2i64 (v128, v128, v128) -> (v128){{$}}
224 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 63{{$}}
225 ; CHECK-NEXT: i64x2.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
226 ; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 63{{$}}
227 ; CHECK-NEXT: i64x2.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
228 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
229 ; CHECK-NEXT: return $pop[[R]]{{$}}
230 define <2 x i64> @vselect_v2i64(<2 x i1> %c, <2 x i64> %x, <2 x i64> %y) {
231 %res = select <2 x i1> %c, <2 x i64> %x, <2 x i64> %y
235 ; CHECK-LABEL: select_v2i64:
236 ; CHECK-NEXT: .functype select_v2i64 (i32, v128, v128) -> (v128){{$}}
237 ; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
238 ; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
239 ; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
240 ; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
241 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
242 ; CHECK-NEXT: return $pop[[R]]{{$}}
243 define <2 x i64> @select_v2i64(i1 zeroext %c, <2 x i64> %x, <2 x i64> %y) {
244 %res = select i1 %c, <2 x i64> %x, <2 x i64> %y
248 ; CHECK-LABEL: select_cmp_v2i64:
249 ; CHECK-NEXT: .functype select_cmp_v2i64 (i32, v128, v128) -> (v128){{$}}
250 ; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
251 ; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
252 ; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 0{{$}}
253 ; CHECK-NEXT: i32.lt_s $push[[L3:[0-9]+]]=, $0, $pop[[L2]]{{$}}
254 ; CHECK-NEXT: i64.select $push[[L4:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $pop[[L3]]{{$}}
255 ; CHECK-NEXT: i64x2.splat $push[[L5:[0-9]+]]=, $pop[[L4]]{{$}}
256 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L5]]{{$}}
257 ; CHECK-NEXT: return $pop[[R]]{{$}}
258 define <2 x i64> @select_cmp_v2i64(i32 %i, <2 x i64> %x, <2 x i64> %y) {
259 %c = icmp slt i32 %i, 0
260 %res = select i1 %c, <2 x i64> %x, <2 x i64> %y
264 ; CHECK-LABEL: select_ne_v2i64:
265 ; CHECK-NEXT: .functype select_ne_v2i64 (i32, v128, v128) -> (v128){{$}}
266 ; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
267 ; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
268 ; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
269 ; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
270 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
271 ; CHECK-NEXT: return $pop[[R]]{{$}}
272 define <2 x i64> @select_ne_v2i64(i32 %i, <2 x i64> %x, <2 x i64> %y) {
273 %c = icmp ne i32 %i, 0
274 %res = select i1 %c, <2 x i64> %x, <2 x i64> %y
278 ; CHECK-LABEL: select_eq_v2i64:
279 ; CHECK-NEXT: .functype select_eq_v2i64 (i32, v128, v128) -> (v128){{$}}
280 ; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, 0{{$}}
281 ; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, -1{{$}}
282 ; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
283 ; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
284 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
285 ; CHECK-NEXT: return $pop[[R]]{{$}}
286 define <2 x i64> @select_eq_v2i64(i32 %i, <2 x i64> %x, <2 x i64> %y) {
287 %c = icmp eq i32 %i, 0
288 %res = select i1 %c, <2 x i64> %x, <2 x i64> %y
292 ; ==============================================================================
294 ; ==============================================================================
295 ; CHECK-LABEL: vselect_v4f32:
296 ; CHECK-NEXT: .functype vselect_v4f32 (v128, v128, v128) -> (v128){{$}}
297 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31{{$}}
298 ; CHECK-NEXT: i32x4.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
299 ; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 31{{$}}
300 ; CHECK-NEXT: i32x4.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
301 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
302 ; CHECK-NEXT: return $pop[[R]]{{$}}
303 define <4 x float> @vselect_v4f32(<4 x i1> %c, <4 x float> %x, <4 x float> %y) {
304 %res = select <4 x i1> %c, <4 x float> %x, <4 x float> %y
308 ; CHECK-LABEL: select_v4f32:
309 ; CHECK-NEXT: .functype select_v4f32 (i32, v128, v128) -> (v128){{$}}
310 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
311 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
312 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
313 ; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
314 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
315 ; CHECK-NEXT: return $pop[[R]]{{$}}
316 define <4 x float> @select_v4f32(i1 zeroext %c, <4 x float> %x, <4 x float> %y) {
317 %res = select i1 %c, <4 x float> %x, <4 x float> %y
321 ; CHECK-LABEL: select_cmp_v4f32:
322 ; CHECK-NEXT: .functype select_cmp_v4f32 (i32, v128, v128) -> (v128){{$}}
323 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 31{{$}}
324 ; CHECK-NEXT: i32.shr_s $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
325 ; CHECK-NEXT: i32x4.splat $push[[L2:[0-9]+]]=, $pop[[L1]]{{$}}
326 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L2]]{{$}}
327 ; CHECK-NEXT: return $pop[[R]]{{$}}
328 define <4 x float> @select_cmp_v4f32(i32 %i, <4 x float> %x, <4 x float> %y) {
329 %c = icmp slt i32 %i, 0
330 %res = select i1 %c, <4 x float> %x, <4 x float> %y
334 ; CHECK-LABEL: select_ne_v4f32:
335 ; CHECK-NEXT: .functype select_ne_v4f32 (i32, v128, v128) -> (v128){{$}}
336 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, -1{{$}}
337 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, 0{{$}}
338 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
339 ; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
340 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
341 ; CHECK-NEXT: return $pop[[R]]{{$}}
342 define <4 x float> @select_ne_v4f32(i32 %i, <4 x float> %x, <4 x float> %y) {
343 %c = icmp ne i32 %i, 0
344 %res = select i1 %c, <4 x float> %x, <4 x float> %y
348 ; CHECK-LABEL: select_eq_v4f32:
349 ; CHECK-NEXT: .functype select_eq_v4f32 (i32, v128, v128) -> (v128){{$}}
350 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
351 ; CHECK-NEXT: i32.const $push[[L1:[0-9]+]]=, -1{{$}}
352 ; CHECK-NEXT: i32.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
353 ; CHECK-NEXT: i32x4.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
354 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
355 ; CHECK-NEXT: return $pop[[R]]{{$}}
356 define <4 x float> @select_eq_v4f32(i32 %i, <4 x float> %x, <4 x float> %y) {
357 %c = icmp eq i32 %i, 0
358 %res = select i1 %c, <4 x float> %x, <4 x float> %y
362 ; ==============================================================================
364 ; ==============================================================================
365 ; CHECK-LABEL: vselect_v2f64:
366 ; CHECK-NEXT: .functype vselect_v2f64 (v128, v128, v128) -> (v128){{$}}
367 ; CHECK-NEXT: i32.const $push[[L0:[0-9]+]]=, 63{{$}}
368 ; CHECK-NEXT: i64x2.shl $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
369 ; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 63{{$}}
370 ; CHECK-NEXT: i64x2.shr_s $push[[L3:[0-9]+]]=, $pop[[L1]], $pop[[L2]]{{$}}
371 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
372 ; CHECK-NEXT: return $pop[[R]]{{$}}
373 define <2 x double> @vselect_v2f64(<2 x i1> %c, <2 x double> %x, <2 x double> %y) {
374 %res = select <2 x i1> %c, <2 x double> %x, <2 x double> %y
375 ret <2 x double> %res
378 ; CHECK-LABEL: select_v2f64:
379 ; CHECK-NEXT: .functype select_v2f64 (i32, v128, v128) -> (v128){{$}}
380 ; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
381 ; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
382 ; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
383 ; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
384 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
385 ; CHECK-NEXT: return $pop[[R]]{{$}}
386 define <2 x double> @select_v2f64(i1 zeroext %c, <2 x double> %x, <2 x double> %y) {
387 %res = select i1 %c, <2 x double> %x, <2 x double> %y
388 ret <2 x double> %res
391 ; CHECK-LABEL: select_cmp_v2f64:
392 ; CHECK-NEXT: .functype select_cmp_v2f64 (i32, v128, v128) -> (v128){{$}}
393 ; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
394 ; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
395 ; CHECK-NEXT: i32.const $push[[L2:[0-9]+]]=, 0{{$}}
396 ; CHECK-NEXT: i32.lt_s $push[[L3:[0-9]+]]=, $0, $pop[[L2]]{{$}}
397 ; CHECK-NEXT: i64.select $push[[L4:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $pop[[L3]]{{$}}
398 ; CHECK-NEXT: i64x2.splat $push[[L5:[0-9]+]]=, $pop[[L4]]{{$}}
399 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L5]]{{$}}
400 ; CHECK-NEXT: return $pop[[R]]{{$}}
401 define <2 x double> @select_cmp_v2f64(i32 %i, <2 x double> %x, <2 x double> %y) {
402 %c = icmp slt i32 %i, 0
403 %res = select i1 %c, <2 x double> %x, <2 x double> %y
404 ret <2 x double> %res
407 ; CHECK-LABEL: select_ne_v2f64:
408 ; CHECK-NEXT: .functype select_ne_v2f64 (i32, v128, v128) -> (v128){{$}}
409 ; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, -1{{$}}
410 ; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, 0{{$}}
411 ; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
412 ; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
413 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
414 ; CHECK-NEXT: return $pop[[R]]{{$}}
415 define <2 x double> @select_ne_v2f64(i32 %i, <2 x double> %x, <2 x double> %y) {
416 %c = icmp ne i32 %i, 0
417 %res = select i1 %c, <2 x double> %x, <2 x double> %y
418 ret <2 x double> %res
421 ; CHECK-LABEL: select_eq_v2f64:
422 ; CHECK-NEXT: .functype select_eq_v2f64 (i32, v128, v128) -> (v128){{$}}
423 ; CHECK-NEXT: i64.const $push[[L0:[0-9]+]]=, 0{{$}}
424 ; CHECK-NEXT: i64.const $push[[L1:[0-9]+]]=, -1{{$}}
425 ; CHECK-NEXT: i64.select $push[[L2:[0-9]+]]=, $pop[[L0]], $pop[[L1]], $0{{$}}
426 ; CHECK-NEXT: i64x2.splat $push[[L3:[0-9]+]]=, $pop[[L2]]{{$}}
427 ; CHECK-NEXT: v128.bitselect $push[[R:[0-9]+]]=, $1, $2, $pop[[L3]]{{$}}
428 ; CHECK-NEXT: return $pop[[R]]{{$}}
429 define <2 x double> @select_eq_v2f64(i32 %i, <2 x double> %x, <2 x double> %y) {
430 %c = icmp eq i32 %i, 0
431 %res = select i1 %c, <2 x double> %x, <2 x double> %y
432 ret <2 x double> %res