1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -verify-machineinstrs < %s | FileCheck %s
4 define <vscale x 16 x i8> @select_nxv16i8(i1 %cond, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
5 ; CHECK-LABEL: select_nxv16i8:
7 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
8 ; CHECK-NEXT: sbfx x8, x0, #0, #1
9 ; CHECK-NEXT: whilelo p0.b, xzr, x8
10 ; CHECK-NEXT: sel z0.b, p0, z0.b, z1.b
12 %res = select i1 %cond, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b
13 ret <vscale x 16 x i8> %res
16 define <vscale x 8 x i16> @select_nxv8i16(i1 %cond, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b) {
17 ; CHECK-LABEL: select_nxv8i16:
19 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
20 ; CHECK-NEXT: sbfx x8, x0, #0, #1
21 ; CHECK-NEXT: whilelo p0.h, xzr, x8
22 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
24 %res = select i1 %cond, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b
25 ret <vscale x 8 x i16> %res
28 define <vscale x 4 x i32> @select_nxv4i32(i1 %cond, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
29 ; CHECK-LABEL: select_nxv4i32:
31 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
32 ; CHECK-NEXT: sbfx x8, x0, #0, #1
33 ; CHECK-NEXT: whilelo p0.s, xzr, x8
34 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
36 %res = select i1 %cond, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b
37 ret <vscale x 4 x i32> %res
40 define <vscale x 2 x i64> @select_nxv2i64(i1 %cond, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
41 ; CHECK-LABEL: select_nxv2i64:
43 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
44 ; CHECK-NEXT: sbfx x8, x0, #0, #1
45 ; CHECK-NEXT: whilelo p0.d, xzr, x8
46 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d
48 %res = select i1 %cond, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b
49 ret <vscale x 2 x i64> %res
52 define <vscale x 8 x half> @select_nxv8f16(i1 %cond, <vscale x 8 x half> %a, <vscale x 8 x half> %b) {
53 ; CHECK-LABEL: select_nxv8f16:
55 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
56 ; CHECK-NEXT: sbfx x8, x0, #0, #1
57 ; CHECK-NEXT: whilelo p0.h, xzr, x8
58 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
60 %res = select i1 %cond, <vscale x 8 x half> %a, <vscale x 8 x half> %b
61 ret <vscale x 8 x half> %res
64 define <vscale x 4 x float> @select_nxv4f32(i1 %cond, <vscale x 4 x float> %a, <vscale x 4 x float> %b) {
65 ; CHECK-LABEL: select_nxv4f32:
67 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
68 ; CHECK-NEXT: sbfx x8, x0, #0, #1
69 ; CHECK-NEXT: whilelo p0.s, xzr, x8
70 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
72 %res = select i1 %cond, <vscale x 4 x float> %a, <vscale x 4 x float> %b
73 ret <vscale x 4 x float> %res
76 define <vscale x 2 x double> @select_nxv2f64(i1 %cond, <vscale x 2 x double> %a, <vscale x 2 x double> %b) {
77 ; CHECK-LABEL: select_nxv2f64:
79 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
80 ; CHECK-NEXT: sbfx x8, x0, #0, #1
81 ; CHECK-NEXT: whilelo p0.d, xzr, x8
82 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d
84 %res = select i1 %cond, <vscale x 2 x double> %a, <vscale x 2 x double> %b
85 ret <vscale x 2 x double> %res
88 define <vscale x 16 x i1> @select_nxv16i1(i1 %cond, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
89 ; CHECK-LABEL: select_nxv16i1:
91 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
92 ; CHECK-NEXT: sbfx x8, x0, #0, #1
93 ; CHECK-NEXT: whilelo p2.b, xzr, x8
94 ; CHECK-NEXT: sel p0.b, p2, p0.b, p1.b
96 %res = select i1 %cond, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b
97 ret <vscale x 16 x i1> %res
100 define <vscale x 8 x i1> @select_nxv8i1(i1 %cond, <vscale x 8 x i1> %a, <vscale x 8 x i1> %b) {
101 ; CHECK-LABEL: select_nxv8i1:
103 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
104 ; CHECK-NEXT: sbfx x8, x0, #0, #1
105 ; CHECK-NEXT: whilelo p2.h, xzr, x8
106 ; CHECK-NEXT: sel p0.b, p2, p0.b, p1.b
108 %res = select i1 %cond, <vscale x 8 x i1> %a, <vscale x 8 x i1> %b
109 ret <vscale x 8 x i1> %res
112 define <vscale x 4 x i1> @select_nxv4i1(i1 %cond, <vscale x 4 x i1> %a, <vscale x 4 x i1> %b) {
113 ; CHECK-LABEL: select_nxv4i1:
115 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
116 ; CHECK-NEXT: sbfx x8, x0, #0, #1
117 ; CHECK-NEXT: whilelo p2.s, xzr, x8
118 ; CHECK-NEXT: sel p0.b, p2, p0.b, p1.b
120 %res = select i1 %cond, <vscale x 4 x i1> %a, <vscale x 4 x i1> %b
121 ret <vscale x 4 x i1> %res
124 define <vscale x 2 x i1> @select_nxv2i1(i1 %cond, <vscale x 2 x i1> %a, <vscale x 2 x i1> %b) {
125 ; CHECK-LABEL: select_nxv2i1:
127 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
128 ; CHECK-NEXT: sbfx x8, x0, #0, #1
129 ; CHECK-NEXT: whilelo p2.d, xzr, x8
130 ; CHECK-NEXT: sel p0.b, p2, p0.b, p1.b
132 %res = select i1 %cond, <vscale x 2 x i1> %a, <vscale x 2 x i1> %b
133 ret <vscale x 2 x i1> %res
136 ; Integer vector select
138 define <vscale x 16 x i8> @sel_nxv16i8(<vscale x 16 x i1> %p,
139 <vscale x 16 x i8> %dst,
140 <vscale x 16 x i8> %a) {
141 ; CHECK-LABEL: sel_nxv16i8:
142 ; CHECK: mov z0.b, p0/m, z1.b
144 %sel = select <vscale x 16 x i1> %p, <vscale x 16 x i8> %a, <vscale x 16 x i8> %dst
145 ret <vscale x 16 x i8> %sel
148 define <vscale x 8 x i16> @sel_nxv8i16(<vscale x 8 x i1> %p,
149 <vscale x 8 x i16> %dst,
150 <vscale x 8 x i16> %a) {
151 ; CHECK-LABEL: sel_nxv8i16:
152 ; CHECK: mov z0.h, p0/m, z1.h
154 %sel = select <vscale x 8 x i1> %p, <vscale x 8 x i16> %a, <vscale x 8 x i16> %dst
155 ret <vscale x 8 x i16> %sel
158 define <vscale x 4 x i32> @sel_nxv4i32(<vscale x 4 x i1> %p,
159 <vscale x 4 x i32> %dst,
160 <vscale x 4 x i32> %a) {
161 ; CHECK-LABEL: sel_nxv4i32:
162 ; CHECK: mov z0.s, p0/m, z1.s
164 %sel = select <vscale x 4 x i1> %p, <vscale x 4 x i32> %a, <vscale x 4 x i32> %dst
165 ret <vscale x 4 x i32> %sel
168 define <vscale x 2 x i64> @sel_nxv2i64(<vscale x 2 x i1> %p,
169 <vscale x 2 x i64> %dst,
170 <vscale x 2 x i64> %a) {
171 ; CHECK-LABEL: sel_nxv2i64:
172 ; CHECK: mov z0.d, p0/m, z1.d
174 %sel = select <vscale x 2 x i1> %p, <vscale x 2 x i64> %a, <vscale x 2 x i64> %dst
175 ret <vscale x 2 x i64> %sel
178 ; Floating point vector select
180 define <vscale x 8 x half> @sel_nxv8f16(<vscale x 8 x i1> %p,
181 <vscale x 8 x half> %dst,
182 <vscale x 8 x half> %a) {
183 ; CHECK-LABEL: sel_nxv8f16:
184 ; CHECK: mov z0.h, p0/m, z1.h
186 %sel = select <vscale x 8 x i1> %p, <vscale x 8 x half> %a, <vscale x 8 x half> %dst
187 ret <vscale x 8 x half> %sel
190 define <vscale x 4 x float> @sel_nxv4f32(<vscale x 4 x i1> %p,
191 <vscale x 4 x float> %dst,
192 <vscale x 4 x float> %a) {
193 ; CHECK-LABEL: sel_nxv4f32:
194 ; CHECK: mov z0.s, p0/m, z1.s
196 %sel = select <vscale x 4 x i1> %p, <vscale x 4 x float> %a, <vscale x 4 x float> %dst
197 ret <vscale x 4 x float> %sel
200 define <vscale x 2 x float> @sel_nxv2f32(<vscale x 2 x i1> %p,
201 <vscale x 2 x float> %dst,
202 <vscale x 2 x float> %a) {
203 ; CHECK-LABEL: sel_nxv2f32:
204 ; CHECK: mov z0.d, p0/m, z1.d
206 %sel = select <vscale x 2 x i1> %p, <vscale x 2 x float> %a, <vscale x 2 x float> %dst
207 ret <vscale x 2 x float> %sel
210 define <vscale x 2 x double> @sel_nxv8f64(<vscale x 2 x i1> %p,
211 <vscale x 2 x double> %dst,
212 <vscale x 2 x double> %a) {
213 ; CHECK-LABEL: sel_nxv8f64:
214 ; CHECK: mov z0.d, p0/m, z1.d
216 %sel = select <vscale x 2 x i1> %p, <vscale x 2 x double> %a, <vscale x 2 x double> %dst
217 ret <vscale x 2 x double> %sel
222 define <vscale x 2 x half> @icmp_select_nxv2f16(<vscale x 2 x half> %a, <vscale x 2 x half> %b, i64 %x0) {
223 ; CHECK-LABEL: icmp_select_nxv2f16
225 ; CHECK-NEXT: cmp x0, #0
226 ; CHECK-NEXT: cset w8, eq
227 ; CHECK-NEXT: sbfx x8, x8, #0, #1
228 ; CHECK-NEXT: whilelo p0.d, xzr, x8
229 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d
231 %mask = icmp eq i64 %x0, 0
232 %sel = select i1 %mask, <vscale x 2 x half> %a, <vscale x 2 x half> %b
233 ret <vscale x 2 x half> %sel
236 define <vscale x 2 x float> @icmp_select_nxv2f32(<vscale x 2 x float> %a, <vscale x 2 x float> %b, i64 %x0) {
237 ; CHECK-LABEL: icmp_select_nxv2f32
239 ; CHECK-NEXT: cmp x0, #0
240 ; CHECK-NEXT: cset w8, eq
241 ; CHECK-NEXT: sbfx x8, x8, #0, #1
242 ; CHECK-NEXT: whilelo p0.d, xzr, x8
243 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d
245 %mask = icmp eq i64 %x0, 0
246 %sel = select i1 %mask, <vscale x 2 x float> %a, <vscale x 2 x float> %b
247 ret <vscale x 2 x float> %sel
250 define <vscale x 2 x double> @icmp_select_nxv2f64(<vscale x 2 x double> %a, <vscale x 2 x double> %b, i64 %x0) {
251 ; CHECK-LABEL: icmp_select_nxv2f64
253 ; CHECK-NEXT: cmp x0, #0
254 ; CHECK-NEXT: cset w8, eq
255 ; CHECK-NEXT: sbfx x8, x8, #0, #1
256 ; CHECK-NEXT: whilelo p0.d, xzr, x8
257 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d
259 %mask = icmp eq i64 %x0, 0
260 %sel = select i1 %mask, <vscale x 2 x double> %a, <vscale x 2 x double> %b
261 ret <vscale x 2 x double> %sel
264 define <vscale x 4 x half> @icmp_select_nxv4f16(<vscale x 4 x half> %a, <vscale x 4 x half> %b, i64 %x0) {
265 ; CHECK-LABEL: icmp_select_nxv4f16
267 ; CHECK-NEXT: cmp x0, #0
268 ; CHECK-NEXT: cset w8, eq
269 ; CHECK-NEXT: sbfx x8, x8, #0, #1
270 ; CHECK-NEXT: whilelo p0.s, xzr, x8
271 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
273 %mask = icmp eq i64 %x0, 0
274 %sel = select i1 %mask, <vscale x 4 x half> %a, <vscale x 4 x half> %b
275 ret <vscale x 4 x half> %sel
278 define <vscale x 4 x float> @icmp_select_nxv4f32(<vscale x 4 x float> %a, <vscale x 4 x float> %b, i64 %x0) {
279 ; CHECK-LABEL: icmp_select_nxv4f32
281 ; CHECK-NEXT: cmp x0, #0
282 ; CHECK-NEXT: cset w8, eq
283 ; CHECK-NEXT: sbfx x8, x8, #0, #1
284 ; CHECK-NEXT: whilelo p0.s, xzr, x8
285 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
287 %mask = icmp eq i64 %x0, 0
288 %sel = select i1 %mask, <vscale x 4 x float> %a, <vscale x 4 x float> %b
289 ret <vscale x 4 x float> %sel
292 define <vscale x 8 x half> @icmp_select_nxv8f16(<vscale x 8 x half> %a, <vscale x 8 x half> %b, i64 %x0) {
293 ; CHECK-LABEL: icmp_select_nxv8f16
295 ; CHECK-NEXT: cmp x0, #0
296 ; CHECK-NEXT: cset w8, eq
297 ; CHECK-NEXT: sbfx x8, x8, #0, #1
298 ; CHECK-NEXT: whilelo p0.h, xzr, x8
299 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
301 %mask = icmp eq i64 %x0, 0
302 %sel = select i1 %mask, <vscale x 8 x half> %a, <vscale x 8 x half> %b
303 ret <vscale x 8 x half> %sel
306 define <vscale x 2 x i64> @icmp_select_nxv2i64(<vscale x 2 x i64> %a, <vscale x 2 x i64> %b, i64 %x0) {
307 ; CHECK-LABEL: icmp_select_nxv2i64
309 ; CHECK-NEXT: cmp x0, #0
310 ; CHECK-NEXT: cset w8, eq
311 ; CHECK-NEXT: sbfx x8, x8, #0, #1
312 ; CHECK-NEXT: whilelo p0.d, xzr, x8
313 ; CHECK-NEXT: sel z0.d, p0, z0.d, z1.d
315 %mask = icmp eq i64 %x0, 0
316 %sel = select i1 %mask, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b
317 ret <vscale x 2 x i64> %sel
320 define <vscale x 4 x i32> @icmp_select_nxv4i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b, i64 %x0) {
321 ; CHECK-LABEL: icmp_select_nxv4i32
323 ; CHECK-NEXT: cmp x0, #0
324 ; CHECK-NEXT: cset w8, eq
325 ; CHECK-NEXT: sbfx x8, x8, #0, #1
326 ; CHECK-NEXT: whilelo p0.s, xzr, x8
327 ; CHECK-NEXT: sel z0.s, p0, z0.s, z1.s
329 %mask = icmp eq i64 %x0, 0
330 %sel = select i1 %mask, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b
331 ret <vscale x 4 x i32> %sel
334 define <vscale x 8 x i16> @icmp_select_nxv8i16(<vscale x 8 x i16> %a, <vscale x 8 x i16> %b, i64 %x0) {
335 ; CHECK-LABEL: icmp_select_nxv8i16
337 ; CHECK-NEXT: cmp x0, #0
338 ; CHECK-NEXT: cset w8, eq
339 ; CHECK-NEXT: sbfx x8, x8, #0, #1
340 ; CHECK-NEXT: whilelo p0.h, xzr, x8
341 ; CHECK-NEXT: sel z0.h, p0, z0.h, z1.h
343 %mask = icmp eq i64 %x0, 0
344 %sel = select i1 %mask, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b
345 ret <vscale x 8 x i16> %sel
348 define <vscale x 16 x i8> @icmp_select_nxv16i8(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b, i64 %x0) {
349 ; CHECK-LABEL: icmp_select_nxv16i8
351 ; CHECK-NEXT: cmp x0, #0
352 ; CHECK-NEXT: cset w8, eq
353 ; CHECK-NEXT: sbfx x8, x8, #0, #1
354 ; CHECK-NEXT: whilelo p0.b, xzr, x8
355 ; CHECK-NEXT: sel z0.b, p0, z0.b, z1.b
357 %mask = icmp eq i64 %x0, 0
358 %sel = select i1 %mask, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b
359 ret <vscale x 16 x i8> %sel
362 define <vscale x 2 x i1> @icmp_select_nxv2i1(<vscale x 2 x i1> %a, <vscale x 2 x i1> %b, i64 %x0) {
363 ; CHECK-LABEL: icmp_select_nxv2i1
365 ; CHECK-NEXT: cmp x0, #0
366 ; CHECK-NEXT: cset w8, eq
367 ; CHECK-NEXT: sbfx x8, x8, #0, #1
368 ; CHECK-NEXT: whilelo p2.d, xzr, x8
369 ; CHECK-NEXT: sel p0.b, p2, p0.b, p1.b
371 %mask = icmp eq i64 %x0, 0
372 %sel = select i1 %mask, <vscale x 2 x i1> %a, <vscale x 2 x i1> %b
373 ret <vscale x 2 x i1> %sel
375 define <vscale x 4 x i1> @icmp_select_nxv4i1(<vscale x 4 x i1> %a, <vscale x 4 x i1> %b, i64 %x0) {
376 ; CHECK-LABEL: icmp_select_nxv4i1
378 ; CHECK-NEXT: cmp x0, #0
379 ; CHECK-NEXT: cset w8, eq
380 ; CHECK-NEXT: sbfx x8, x8, #0, #1
381 ; CHECK-NEXT: whilelo p2.s, xzr, x8
382 ; CHECK-NEXT: sel p0.b, p2, p0.b, p1.b
384 %mask = icmp eq i64 %x0, 0
385 %sel = select i1 %mask, <vscale x 4 x i1> %a, <vscale x 4 x i1> %b
386 ret <vscale x 4 x i1> %sel
388 define <vscale x 8 x i1> @icmp_select_nxv8i1(<vscale x 8 x i1> %a, <vscale x 8 x i1> %b, i64 %x0) {
389 ; CHECK-LABEL: icmp_select_nxv8i1
391 ; CHECK-NEXT: cmp x0, #0
392 ; CHECK-NEXT: cset w8, eq
393 ; CHECK-NEXT: sbfx x8, x8, #0, #1
394 ; CHECK-NEXT: whilelo p2.h, xzr, x8
395 ; CHECK-NEXT: sel p0.b, p2, p0.b, p1.b
397 %mask = icmp eq i64 %x0, 0
398 %sel = select i1 %mask, <vscale x 8 x i1> %a, <vscale x 8 x i1> %b
399 ret <vscale x 8 x i1> %sel
401 define <vscale x 16 x i1> @icmp_select_nxv16i1(<vscale x 16 x i1> %a, <vscale x 16 x i1> %b, i64 %x0) {
402 ; CHECK-LABEL: icmp_select_nxv16i1
404 ; CHECK-NEXT: cmp x0, #0
405 ; CHECK-NEXT: cset w8, eq
406 ; CHECK-NEXT: sbfx x8, x8, #0, #1
407 ; CHECK-NEXT: whilelo p2.b, xzr, x8
408 ; CHECK-NEXT: sel p0.b, p2, p0.b, p1.b
410 %mask = icmp eq i64 %x0, 0
411 %sel = select i1 %mask, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b
412 ret <vscale x 16 x i1> %sel