1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
7 define <vscale x 16 x i8> @smax_i8_pos(<vscale x 16 x i8> %a) {
8 ; CHECK-LABEL: smax_i8_pos:
10 ; CHECK-NEXT: smax z0.b, z0.b, #27
12 %elt = insertelement <vscale x 16 x i8> undef, i8 27, i32 0
13 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
14 %cmp = icmp sgt <vscale x 16 x i8> %a, %splat
15 %res = select <vscale x 16 x i1> %cmp, <vscale x 16 x i8> %a, <vscale x 16 x i8> %splat
16 ret <vscale x 16 x i8> %res
19 define <vscale x 16 x i8> @smax_i8_neg(<vscale x 16 x i8> %a) {
20 ; CHECK-LABEL: smax_i8_neg:
22 ; CHECK-NEXT: smax z0.b, z0.b, #-58
24 %elt = insertelement <vscale x 16 x i8> undef, i8 -58, i32 0
25 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
26 %cmp = icmp sgt <vscale x 16 x i8> %a, %splat
27 %res = select <vscale x 16 x i1> %cmp, <vscale x 16 x i8> %a, <vscale x 16 x i8> %splat
28 ret <vscale x 16 x i8> %res
31 define <vscale x 8 x i16> @smax_i16_pos(<vscale x 8 x i16> %a) {
32 ; CHECK-LABEL: smax_i16_pos:
34 ; CHECK-NEXT: smax z0.h, z0.h, #27
36 %elt = insertelement <vscale x 8 x i16> undef, i16 27, i32 0
37 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
38 %cmp = icmp sgt <vscale x 8 x i16> %a, %splat
39 %res = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %a, <vscale x 8 x i16> %splat
40 ret <vscale x 8 x i16> %res
43 define <vscale x 8 x i16> @smax_i16_neg(<vscale x 8 x i16> %a) {
44 ; CHECK-LABEL: smax_i16_neg:
46 ; CHECK-NEXT: smax z0.h, z0.h, #-58
48 %elt = insertelement <vscale x 8 x i16> undef, i16 -58, i32 0
49 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
50 %cmp = icmp sgt <vscale x 8 x i16> %a, %splat
51 %res = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %a, <vscale x 8 x i16> %splat
52 ret <vscale x 8 x i16> %res
55 define <vscale x 8 x i16> @smax_i16_out_of_range(<vscale x 8 x i16> %a) {
56 ; CHECK-LABEL: smax_i16_out_of_range:
58 ; CHECK-NEXT: dupm z1.b, #0x1
59 ; CHECK-NEXT: ptrue p0.h
60 ; CHECK-NEXT: smax z0.h, p0/m, z0.h, z1.h
62 %elt = insertelement <vscale x 8 x i16> undef, i16 257, i32 0
63 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
64 %cmp = icmp sgt <vscale x 8 x i16> %a, %splat
65 %res = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %a, <vscale x 8 x i16> %splat
66 ret <vscale x 8 x i16> %res
69 define <vscale x 4 x i32> @smax_i32_pos(<vscale x 4 x i32> %a) {
70 ; CHECK-LABEL: smax_i32_pos:
72 ; CHECK-NEXT: smax z0.s, z0.s, #27
74 %elt = insertelement <vscale x 4 x i32> undef, i32 27, i32 0
75 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
76 %cmp = icmp sgt <vscale x 4 x i32> %a, %splat
77 %res = select <vscale x 4 x i1> %cmp, <vscale x 4 x i32> %a, <vscale x 4 x i32> %splat
78 ret <vscale x 4 x i32> %res
81 define <vscale x 4 x i32> @smax_i32_neg(<vscale x 4 x i32> %a) {
82 ; CHECK-LABEL: smax_i32_neg:
84 ; CHECK-NEXT: smax z0.s, z0.s, #-58
86 %elt = insertelement <vscale x 4 x i32> undef, i32 -58, i32 0
87 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
88 %cmp = icmp sgt <vscale x 4 x i32> %a, %splat
89 %res = select <vscale x 4 x i1> %cmp, <vscale x 4 x i32> %a, <vscale x 4 x i32> %splat
90 ret <vscale x 4 x i32> %res
93 define <vscale x 4 x i32> @smax_i32_out_of_range(<vscale x 4 x i32> %a) {
94 ; CHECK-LABEL: smax_i32_out_of_range:
96 ; CHECK-NEXT: mov z1.s, #-129 // =0xffffffffffffff7f
97 ; CHECK-NEXT: ptrue p0.s
98 ; CHECK-NEXT: smax z0.s, p0/m, z0.s, z1.s
100 %elt = insertelement <vscale x 4 x i32> undef, i32 -129, i32 0
101 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
102 %cmp = icmp sgt <vscale x 4 x i32> %a, %splat
103 %res = select <vscale x 4 x i1> %cmp, <vscale x 4 x i32> %a, <vscale x 4 x i32> %splat
104 ret <vscale x 4 x i32> %res
107 define <vscale x 2 x i64> @smax_i64_pos(<vscale x 2 x i64> %a) {
108 ; CHECK-LABEL: smax_i64_pos:
110 ; CHECK-NEXT: smax z0.d, z0.d, #27
112 %elt = insertelement <vscale x 2 x i64> undef, i64 27, i32 0
113 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
114 %cmp = icmp sgt <vscale x 2 x i64> %a, %splat
115 %res = select <vscale x 2 x i1> %cmp, <vscale x 2 x i64> %a, <vscale x 2 x i64> %splat
116 ret <vscale x 2 x i64> %res
119 define <vscale x 2 x i64> @smax_i64_neg(<vscale x 2 x i64> %a) {
120 ; CHECK-LABEL: smax_i64_neg:
122 ; CHECK-NEXT: smax z0.d, z0.d, #-58
124 %elt = insertelement <vscale x 2 x i64> undef, i64 -58, i32 0
125 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
126 %cmp = icmp sgt <vscale x 2 x i64> %a, %splat
127 %res = select <vscale x 2 x i1> %cmp, <vscale x 2 x i64> %a, <vscale x 2 x i64> %splat
128 ret <vscale x 2 x i64> %res
131 define <vscale x 2 x i64> @smax_i64_out_of_range(<vscale x 2 x i64> %a) {
132 ; CHECK-LABEL: smax_i64_out_of_range:
134 ; CHECK-NEXT: mov z1.d, #65535 // =0xffff
135 ; CHECK-NEXT: ptrue p0.d
136 ; CHECK-NEXT: smax z0.d, p0/m, z0.d, z1.d
138 %elt = insertelement <vscale x 2 x i64> undef, i64 65535, i32 0
139 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
140 %cmp = icmp sgt <vscale x 2 x i64> %a, %splat
141 %res = select <vscale x 2 x i1> %cmp, <vscale x 2 x i64> %a, <vscale x 2 x i64> %splat
142 ret <vscale x 2 x i64> %res
148 define <vscale x 16 x i8> @smin_i8_pos(<vscale x 16 x i8> %a) {
149 ; CHECK-LABEL: smin_i8_pos:
151 ; CHECK-NEXT: smin z0.b, z0.b, #27
153 %elt = insertelement <vscale x 16 x i8> undef, i8 27, i32 0
154 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
155 %cmp = icmp slt <vscale x 16 x i8> %a, %splat
156 %res = select <vscale x 16 x i1> %cmp, <vscale x 16 x i8> %a, <vscale x 16 x i8> %splat
157 ret <vscale x 16 x i8> %res
160 define <vscale x 16 x i8> @smin_i8_neg(<vscale x 16 x i8> %a) {
161 ; CHECK-LABEL: smin_i8_neg:
163 ; CHECK-NEXT: smin z0.b, z0.b, #-58
165 %elt = insertelement <vscale x 16 x i8> undef, i8 -58, i32 0
166 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
167 %cmp = icmp slt <vscale x 16 x i8> %a, %splat
168 %res = select <vscale x 16 x i1> %cmp, <vscale x 16 x i8> %a, <vscale x 16 x i8> %splat
169 ret <vscale x 16 x i8> %res
172 define <vscale x 8 x i16> @smin_i16_pos(<vscale x 8 x i16> %a) {
173 ; CHECK-LABEL: smin_i16_pos:
175 ; CHECK-NEXT: smin z0.h, z0.h, #27
177 %elt = insertelement <vscale x 8 x i16> undef, i16 27, i32 0
178 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
179 %cmp = icmp slt <vscale x 8 x i16> %a, %splat
180 %res = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %a, <vscale x 8 x i16> %splat
181 ret <vscale x 8 x i16> %res
184 define <vscale x 8 x i16> @smin_i16_neg(<vscale x 8 x i16> %a) {
185 ; CHECK-LABEL: smin_i16_neg:
187 ; CHECK-NEXT: smin z0.h, z0.h, #-58
189 %elt = insertelement <vscale x 8 x i16> undef, i16 -58, i32 0
190 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
191 %cmp = icmp slt <vscale x 8 x i16> %a, %splat
192 %res = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %a, <vscale x 8 x i16> %splat
193 ret <vscale x 8 x i16> %res
196 define <vscale x 8 x i16> @smin_i16_out_of_range(<vscale x 8 x i16> %a) {
197 ; CHECK-LABEL: smin_i16_out_of_range:
199 ; CHECK-NEXT: dupm z1.b, #0x1
200 ; CHECK-NEXT: ptrue p0.h
201 ; CHECK-NEXT: smin z0.h, p0/m, z0.h, z1.h
203 %elt = insertelement <vscale x 8 x i16> undef, i16 257, i32 0
204 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
205 %cmp = icmp slt <vscale x 8 x i16> %a, %splat
206 %res = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %a, <vscale x 8 x i16> %splat
207 ret <vscale x 8 x i16> %res
210 define <vscale x 4 x i32> @smin_i32_pos(<vscale x 4 x i32> %a) {
211 ; CHECK-LABEL: smin_i32_pos:
213 ; CHECK-NEXT: smin z0.s, z0.s, #27
215 %elt = insertelement <vscale x 4 x i32> undef, i32 27, i32 0
216 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
217 %cmp = icmp slt <vscale x 4 x i32> %a, %splat
218 %res = select <vscale x 4 x i1> %cmp, <vscale x 4 x i32> %a, <vscale x 4 x i32> %splat
219 ret <vscale x 4 x i32> %res
222 define <vscale x 4 x i32> @smin_i32_neg(<vscale x 4 x i32> %a) {
223 ; CHECK-LABEL: smin_i32_neg:
225 ; CHECK-NEXT: smin z0.s, z0.s, #-58
227 %elt = insertelement <vscale x 4 x i32> undef, i32 -58, i32 0
228 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
229 %cmp = icmp slt <vscale x 4 x i32> %a, %splat
230 %res = select <vscale x 4 x i1> %cmp, <vscale x 4 x i32> %a, <vscale x 4 x i32> %splat
231 ret <vscale x 4 x i32> %res
234 define <vscale x 4 x i32> @smin_i32_out_of_range(<vscale x 4 x i32> %a) {
235 ; CHECK-LABEL: smin_i32_out_of_range:
237 ; CHECK-NEXT: mov z1.s, #-129 // =0xffffffffffffff7f
238 ; CHECK-NEXT: ptrue p0.s
239 ; CHECK-NEXT: smin z0.s, p0/m, z0.s, z1.s
241 %elt = insertelement <vscale x 4 x i32> undef, i32 -129, i32 0
242 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
243 %cmp = icmp slt <vscale x 4 x i32> %a, %splat
244 %res = select <vscale x 4 x i1> %cmp, <vscale x 4 x i32> %a, <vscale x 4 x i32> %splat
245 ret <vscale x 4 x i32> %res
248 define <vscale x 2 x i64> @smin_i64_pos(<vscale x 2 x i64> %a) {
249 ; CHECK-LABEL: smin_i64_pos:
251 ; CHECK-NEXT: smin z0.d, z0.d, #27
253 %elt = insertelement <vscale x 2 x i64> undef, i64 27, i32 0
254 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
255 %cmp = icmp slt <vscale x 2 x i64> %a, %splat
256 %res = select <vscale x 2 x i1> %cmp, <vscale x 2 x i64> %a, <vscale x 2 x i64> %splat
257 ret <vscale x 2 x i64> %res
260 define <vscale x 2 x i64> @smin_i64_neg(<vscale x 2 x i64> %a) {
261 ; CHECK-LABEL: smin_i64_neg:
263 ; CHECK-NEXT: smin z0.d, z0.d, #-58
265 %elt = insertelement <vscale x 2 x i64> undef, i64 -58, i32 0
266 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
267 %cmp = icmp slt <vscale x 2 x i64> %a, %splat
268 %res = select <vscale x 2 x i1> %cmp, <vscale x 2 x i64> %a, <vscale x 2 x i64> %splat
269 ret <vscale x 2 x i64> %res
272 define <vscale x 2 x i64> @smin_i64_out_of_range(<vscale x 2 x i64> %a) {
273 ; CHECK-LABEL: smin_i64_out_of_range:
275 ; CHECK-NEXT: mov z1.d, #65535 // =0xffff
276 ; CHECK-NEXT: ptrue p0.d
277 ; CHECK-NEXT: smin z0.d, p0/m, z0.d, z1.d
279 %elt = insertelement <vscale x 2 x i64> undef, i64 65535, i32 0
280 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
281 %cmp = icmp slt <vscale x 2 x i64> %a, %splat
282 %res = select <vscale x 2 x i1> %cmp, <vscale x 2 x i64> %a, <vscale x 2 x i64> %splat
283 ret <vscale x 2 x i64> %res
289 define <vscale x 16 x i8> @umax_i8_pos(<vscale x 16 x i8> %a) {
290 ; CHECK-LABEL: umax_i8_pos:
292 ; CHECK-NEXT: umax z0.b, z0.b, #27
294 %elt = insertelement <vscale x 16 x i8> undef, i8 27, i32 0
295 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
296 %cmp = icmp ugt <vscale x 16 x i8> %a, %splat
297 %res = select <vscale x 16 x i1> %cmp, <vscale x 16 x i8> %a, <vscale x 16 x i8> %splat
298 ret <vscale x 16 x i8> %res
301 define <vscale x 16 x i8> @umax_i8_large(<vscale x 16 x i8> %a) {
302 ; CHECK-LABEL: umax_i8_large:
304 ; CHECK-NEXT: umax z0.b, z0.b, #129
306 %elt = insertelement <vscale x 16 x i8> undef, i8 129, i32 0
307 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
308 %cmp = icmp ugt <vscale x 16 x i8> %a, %splat
309 %res = select <vscale x 16 x i1> %cmp, <vscale x 16 x i8> %a, <vscale x 16 x i8> %splat
310 ret <vscale x 16 x i8> %res
313 define <vscale x 8 x i16> @umax_i16_pos(<vscale x 8 x i16> %a) {
314 ; CHECK-LABEL: umax_i16_pos:
316 ; CHECK-NEXT: umax z0.h, z0.h, #27
318 %elt = insertelement <vscale x 8 x i16> undef, i16 27, i32 0
319 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
320 %cmp = icmp ugt <vscale x 8 x i16> %a, %splat
321 %res = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %a, <vscale x 8 x i16> %splat
322 ret <vscale x 8 x i16> %res
325 define <vscale x 8 x i16> @umax_i16_out_of_range(<vscale x 8 x i16> %a) {
326 ; CHECK-LABEL: umax_i16_out_of_range:
328 ; CHECK-NEXT: dupm z1.b, #0x1
329 ; CHECK-NEXT: ptrue p0.h
330 ; CHECK-NEXT: umax z0.h, p0/m, z0.h, z1.h
332 %elt = insertelement <vscale x 8 x i16> undef, i16 257, i32 0
333 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
334 %cmp = icmp ugt <vscale x 8 x i16> %a, %splat
335 %res = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %a, <vscale x 8 x i16> %splat
336 ret <vscale x 8 x i16> %res
339 define <vscale x 4 x i32> @umax_i32_pos(<vscale x 4 x i32> %a) {
340 ; CHECK-LABEL: umax_i32_pos:
342 ; CHECK-NEXT: umax z0.s, z0.s, #27
344 %elt = insertelement <vscale x 4 x i32> undef, i32 27, i32 0
345 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
346 %cmp = icmp ugt <vscale x 4 x i32> %a, %splat
347 %res = select <vscale x 4 x i1> %cmp, <vscale x 4 x i32> %a, <vscale x 4 x i32> %splat
348 ret <vscale x 4 x i32> %res
351 define <vscale x 4 x i32> @umax_i32_out_of_range(<vscale x 4 x i32> %a) {
352 ; CHECK-LABEL: umax_i32_out_of_range:
354 ; CHECK-NEXT: mov w8, #257 // =0x101
355 ; CHECK-NEXT: ptrue p0.s
356 ; CHECK-NEXT: mov z1.s, w8
357 ; CHECK-NEXT: umax z0.s, p0/m, z0.s, z1.s
359 %elt = insertelement <vscale x 4 x i32> undef, i32 257, i32 0
360 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
361 %cmp = icmp ugt <vscale x 4 x i32> %a, %splat
362 %res = select <vscale x 4 x i1> %cmp, <vscale x 4 x i32> %a, <vscale x 4 x i32> %splat
363 ret <vscale x 4 x i32> %res
366 define <vscale x 2 x i64> @umax_i64_pos(<vscale x 2 x i64> %a) {
367 ; CHECK-LABEL: umax_i64_pos:
369 ; CHECK-NEXT: umax z0.d, z0.d, #27
371 %elt = insertelement <vscale x 2 x i64> undef, i64 27, i32 0
372 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
373 %cmp = icmp ugt <vscale x 2 x i64> %a, %splat
374 %res = select <vscale x 2 x i1> %cmp, <vscale x 2 x i64> %a, <vscale x 2 x i64> %splat
375 ret <vscale x 2 x i64> %res
378 define <vscale x 2 x i64> @umax_i64_out_of_range(<vscale x 2 x i64> %a) {
379 ; CHECK-LABEL: umax_i64_out_of_range:
381 ; CHECK-NEXT: mov z1.d, #65535 // =0xffff
382 ; CHECK-NEXT: ptrue p0.d
383 ; CHECK-NEXT: umax z0.d, p0/m, z0.d, z1.d
385 %elt = insertelement <vscale x 2 x i64> undef, i64 65535, i32 0
386 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
387 %cmp = icmp ugt <vscale x 2 x i64> %a, %splat
388 %res = select <vscale x 2 x i1> %cmp, <vscale x 2 x i64> %a, <vscale x 2 x i64> %splat
389 ret <vscale x 2 x i64> %res
395 define <vscale x 16 x i8> @umin_i8_pos(<vscale x 16 x i8> %a) {
396 ; CHECK-LABEL: umin_i8_pos:
398 ; CHECK-NEXT: umin z0.b, z0.b, #27
400 %elt = insertelement <vscale x 16 x i8> undef, i8 27, i32 0
401 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
402 %cmp = icmp ult <vscale x 16 x i8> %a, %splat
403 %res = select <vscale x 16 x i1> %cmp, <vscale x 16 x i8> %a, <vscale x 16 x i8> %splat
404 ret <vscale x 16 x i8> %res
407 define <vscale x 16 x i8> @umin_i8_large(<vscale x 16 x i8> %a) {
408 ; CHECK-LABEL: umin_i8_large:
410 ; CHECK-NEXT: umin z0.b, z0.b, #129
412 %elt = insertelement <vscale x 16 x i8> undef, i8 129, i32 0
413 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
414 %cmp = icmp ult <vscale x 16 x i8> %a, %splat
415 %res = select <vscale x 16 x i1> %cmp, <vscale x 16 x i8> %a, <vscale x 16 x i8> %splat
416 ret <vscale x 16 x i8> %res
419 define <vscale x 8 x i16> @umin_i16_pos(<vscale x 8 x i16> %a) {
420 ; CHECK-LABEL: umin_i16_pos:
422 ; CHECK-NEXT: umin z0.h, z0.h, #27
424 %elt = insertelement <vscale x 8 x i16> undef, i16 27, i32 0
425 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
426 %cmp = icmp ult <vscale x 8 x i16> %a, %splat
427 %res = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %a, <vscale x 8 x i16> %splat
428 ret <vscale x 8 x i16> %res
431 define <vscale x 8 x i16> @umin_i16_out_of_range(<vscale x 8 x i16> %a) {
432 ; CHECK-LABEL: umin_i16_out_of_range:
434 ; CHECK-NEXT: dupm z1.b, #0x1
435 ; CHECK-NEXT: ptrue p0.h
436 ; CHECK-NEXT: umin z0.h, p0/m, z0.h, z1.h
438 %elt = insertelement <vscale x 8 x i16> undef, i16 257, i32 0
439 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
440 %cmp = icmp ult <vscale x 8 x i16> %a, %splat
441 %res = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %a, <vscale x 8 x i16> %splat
442 ret <vscale x 8 x i16> %res
445 define <vscale x 4 x i32> @umin_i32_pos(<vscale x 4 x i32> %a) {
446 ; CHECK-LABEL: umin_i32_pos:
448 ; CHECK-NEXT: umin z0.s, z0.s, #27
450 %elt = insertelement <vscale x 4 x i32> undef, i32 27, i32 0
451 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
452 %cmp = icmp ult <vscale x 4 x i32> %a, %splat
453 %res = select <vscale x 4 x i1> %cmp, <vscale x 4 x i32> %a, <vscale x 4 x i32> %splat
454 ret <vscale x 4 x i32> %res
457 define <vscale x 4 x i32> @umin_i32_out_of_range(<vscale x 4 x i32> %a) {
458 ; CHECK-LABEL: umin_i32_out_of_range:
460 ; CHECK-NEXT: mov w8, #257 // =0x101
461 ; CHECK-NEXT: ptrue p0.s
462 ; CHECK-NEXT: mov z1.s, w8
463 ; CHECK-NEXT: umin z0.s, p0/m, z0.s, z1.s
465 %elt = insertelement <vscale x 4 x i32> undef, i32 257, i32 0
466 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
467 %cmp = icmp ult <vscale x 4 x i32> %a, %splat
468 %res = select <vscale x 4 x i1> %cmp, <vscale x 4 x i32> %a, <vscale x 4 x i32> %splat
469 ret <vscale x 4 x i32> %res
472 define <vscale x 2 x i64> @umin_i64_pos(<vscale x 2 x i64> %a) {
473 ; CHECK-LABEL: umin_i64_pos:
475 ; CHECK-NEXT: umin z0.d, z0.d, #27
477 %elt = insertelement <vscale x 2 x i64> undef, i64 27, i32 0
478 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
479 %cmp = icmp ult <vscale x 2 x i64> %a, %splat
480 %res = select <vscale x 2 x i1> %cmp, <vscale x 2 x i64> %a, <vscale x 2 x i64> %splat
481 ret <vscale x 2 x i64> %res
484 define <vscale x 2 x i64> @umin_i64_out_of_range(<vscale x 2 x i64> %a) {
485 ; CHECK-LABEL: umin_i64_out_of_range:
487 ; CHECK-NEXT: mov z1.d, #65535 // =0xffff
488 ; CHECK-NEXT: ptrue p0.d
489 ; CHECK-NEXT: umin z0.d, p0/m, z0.d, z1.d
491 %elt = insertelement <vscale x 2 x i64> undef, i64 65535, i32 0
492 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
493 %cmp = icmp ult <vscale x 2 x i64> %a, %splat
494 %res = select <vscale x 2 x i1> %cmp, <vscale x 2 x i64> %a, <vscale x 2 x i64> %splat
495 ret <vscale x 2 x i64> %res
501 define <vscale x 16 x i8> @mul_i8_neg(<vscale x 16 x i8> %a) {
502 ; CHECK-LABEL: mul_i8_neg:
504 ; CHECK-NEXT: mul z0.b, z0.b, #-17
506 %elt = insertelement <vscale x 16 x i8> undef, i8 -17, i32 0
507 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
508 %res = mul <vscale x 16 x i8> %a, %splat
509 ret <vscale x 16 x i8> %res
512 define <vscale x 16 x i8> @mul_i8_pos(<vscale x 16 x i8> %a) {
513 ; CHECK-LABEL: mul_i8_pos:
515 ; CHECK-NEXT: mul z0.b, z0.b, #105
517 %elt = insertelement <vscale x 16 x i8> undef, i8 105, i32 0
518 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
519 %res = mul <vscale x 16 x i8> %a, %splat
520 ret <vscale x 16 x i8> %res
523 define <vscale x 8 x i16> @mul_i16_neg(<vscale x 8 x i16> %a) {
524 ; CHECK-LABEL: mul_i16_neg:
526 ; CHECK-NEXT: mul z0.h, z0.h, #-17
528 %elt = insertelement <vscale x 8 x i16> undef, i16 -17, i32 0
529 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
530 %res = mul <vscale x 8 x i16> %a, %splat
531 ret <vscale x 8 x i16> %res
534 define <vscale x 8 x i16> @mul_i16_pos(<vscale x 8 x i16> %a) {
535 ; CHECK-LABEL: mul_i16_pos:
537 ; CHECK-NEXT: mul z0.h, z0.h, #105
539 %elt = insertelement <vscale x 8 x i16> undef, i16 105, i32 0
540 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
541 %res = mul <vscale x 8 x i16> %a, %splat
542 ret <vscale x 8 x i16> %res
545 define <vscale x 4 x i32> @mul_i32_neg(<vscale x 4 x i32> %a) {
546 ; CHECK-LABEL: mul_i32_neg:
548 ; CHECK-NEXT: mul z0.s, z0.s, #-17
550 %elt = insertelement <vscale x 4 x i32> undef, i32 -17, i32 0
551 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
552 %res = mul <vscale x 4 x i32> %a, %splat
553 ret <vscale x 4 x i32> %res
556 define <vscale x 4 x i32> @mul_i32_pos(<vscale x 4 x i32> %a) {
557 ; CHECK-LABEL: mul_i32_pos:
559 ; CHECK-NEXT: mul z0.s, z0.s, #105
561 %elt = insertelement <vscale x 4 x i32> undef, i32 105, i32 0
562 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
563 %res = mul <vscale x 4 x i32> %a, %splat
564 ret <vscale x 4 x i32> %res
567 define <vscale x 2 x i64> @mul_i64_neg(<vscale x 2 x i64> %a) {
568 ; CHECK-LABEL: mul_i64_neg:
570 ; CHECK-NEXT: mul z0.d, z0.d, #-17
572 %elt = insertelement <vscale x 2 x i64> undef, i64 -17, i32 0
573 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
574 %res = mul <vscale x 2 x i64> %a, %splat
575 ret <vscale x 2 x i64> %res
578 define <vscale x 2 x i64> @mul_i64_pos(<vscale x 2 x i64> %a) {
579 ; CHECK-LABEL: mul_i64_pos:
581 ; CHECK-NEXT: mul z0.d, z0.d, #105
583 %elt = insertelement <vscale x 2 x i64> undef, i64 105, i32 0
584 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
585 %res = mul <vscale x 2 x i64> %a, %splat
586 ret <vscale x 2 x i64> %res
589 define <vscale x 8 x i16> @mul_i16_range(<vscale x 8 x i16> %a) {
590 ; CHECK-LABEL: mul_i16_range:
592 ; CHECK-NEXT: mov z1.h, #255 // =0xff
593 ; CHECK-NEXT: ptrue p0.h
594 ; CHECK-NEXT: mul z0.h, p0/m, z0.h, z1.h
596 %elt = insertelement <vscale x 8 x i16> undef, i16 255, i32 0
597 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
598 %res = mul <vscale x 8 x i16> %a, %splat
599 ret <vscale x 8 x i16> %res
602 define <vscale x 4 x i32> @mul_i32_range(<vscale x 4 x i32> %a) {
603 ; CHECK-LABEL: mul_i32_range:
605 ; CHECK-NEXT: mov z1.s, #255 // =0xff
606 ; CHECK-NEXT: ptrue p0.s
607 ; CHECK-NEXT: mul z0.s, p0/m, z0.s, z1.s
609 %elt = insertelement <vscale x 4 x i32> undef, i32 255, i32 0
610 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
611 %res = mul <vscale x 4 x i32> %a, %splat
612 ret <vscale x 4 x i32> %res
615 define <vscale x 2 x i64> @mul_i64_range(<vscale x 2 x i64> %a) {
616 ; CHECK-LABEL: mul_i64_range:
618 ; CHECK-NEXT: mov z1.d, #255 // =0xff
619 ; CHECK-NEXT: ptrue p0.d
620 ; CHECK-NEXT: mul z0.d, p0/m, z0.d, z1.d
622 %elt = insertelement <vscale x 2 x i64> undef, i64 255, i32 0
623 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
624 %res = mul <vscale x 2 x i64> %a, %splat
625 ret <vscale x 2 x i64> %res
630 define <vscale x 16 x i8> @asr_i8(<vscale x 16 x i8> %a){
631 ; CHECK-LABEL: asr_i8:
633 ; CHECK-NEXT: asr z0.b, z0.b, #7
635 %elt = insertelement <vscale x 16 x i8> undef, i8 7, i32 0
636 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
637 %lshr = ashr <vscale x 16 x i8> %a, %splat
638 ret <vscale x 16 x i8> %lshr
641 define <vscale x 8 x i16> @asr_i16(<vscale x 8 x i16> %a){
642 ; CHECK-LABEL: asr_i16:
644 ; CHECK-NEXT: asr z0.h, z0.h, #15
646 %elt = insertelement <vscale x 8 x i16> undef, i16 15, i32 0
647 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
648 %ashr = ashr <vscale x 8 x i16> %a, %splat
649 ret <vscale x 8 x i16> %ashr
652 define <vscale x 4 x i32> @asr_i32(<vscale x 4 x i32> %a){
653 ; CHECK-LABEL: asr_i32:
655 ; CHECK-NEXT: asr z0.s, z0.s, #31
657 %elt = insertelement <vscale x 4 x i32> undef, i32 31, i32 0
658 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
659 %ashr = ashr <vscale x 4 x i32> %a, %splat
660 ret <vscale x 4 x i32> %ashr
663 define <vscale x 2 x i64> @asr_i64(<vscale x 2 x i64> %a){
664 ; CHECK-LABEL: asr_i64:
666 ; CHECK-NEXT: asr z0.d, z0.d, #63
668 %elt = insertelement <vscale x 2 x i64> undef, i64 63, i32 0
669 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
670 %ashr = ashr <vscale x 2 x i64> %a, %splat
671 ret <vscale x 2 x i64> %ashr
676 define <vscale x 16 x i8> @lsl_i8(<vscale x 16 x i8> %a){
677 ; CHECK-LABEL: lsl_i8:
679 ; CHECK-NEXT: lsl z0.b, z0.b, #7
681 %elt = insertelement <vscale x 16 x i8> undef, i8 7, i32 0
682 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
683 %shl = shl <vscale x 16 x i8> %a, %splat
684 ret <vscale x 16 x i8> %shl
687 define <vscale x 8 x i16> @lsl_i16(<vscale x 8 x i16> %a){
688 ; CHECK-LABEL: lsl_i16:
690 ; CHECK-NEXT: lsl z0.h, z0.h, #15
692 %elt = insertelement <vscale x 8 x i16> undef, i16 15, i32 0
693 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
694 %shl = shl <vscale x 8 x i16> %a, %splat
695 ret <vscale x 8 x i16> %shl
698 define <vscale x 4 x i32> @lsl_i32(<vscale x 4 x i32> %a){
699 ; CHECK-LABEL: lsl_i32:
701 ; CHECK-NEXT: lsl z0.s, z0.s, #31
703 %elt = insertelement <vscale x 4 x i32> undef, i32 31, i32 0
704 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
705 %shl = shl <vscale x 4 x i32> %a, %splat
706 ret <vscale x 4 x i32> %shl
709 define <vscale x 2 x i64> @lsl_i64(<vscale x 2 x i64> %a){
710 ; CHECK-LABEL: lsl_i64:
712 ; CHECK-NEXT: lsl z0.d, z0.d, #63
714 %elt = insertelement <vscale x 2 x i64> undef, i64 63, i32 0
715 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
716 %shl = shl <vscale x 2 x i64> %a, %splat
717 ret <vscale x 2 x i64> %shl
722 define <vscale x 16 x i8> @lsr_i8(<vscale x 16 x i8> %a){
723 ; CHECK-LABEL: lsr_i8:
725 ; CHECK-NEXT: lsr z0.b, z0.b, #7
727 %elt = insertelement <vscale x 16 x i8> undef, i8 7, i32 0
728 %splat = shufflevector <vscale x 16 x i8> %elt, <vscale x 16 x i8> undef, <vscale x 16 x i32> zeroinitializer
729 %lshr = lshr <vscale x 16 x i8> %a, %splat
730 ret <vscale x 16 x i8> %lshr
733 define <vscale x 8 x i16> @lsr_i16(<vscale x 8 x i16> %a){
734 ; CHECK-LABEL: lsr_i16:
736 ; CHECK-NEXT: lsr z0.h, z0.h, #15
738 %elt = insertelement <vscale x 8 x i16> undef, i16 15, i32 0
739 %splat = shufflevector <vscale x 8 x i16> %elt, <vscale x 8 x i16> undef, <vscale x 8 x i32> zeroinitializer
740 %lshr = lshr <vscale x 8 x i16> %a, %splat
741 ret <vscale x 8 x i16> %lshr
744 define <vscale x 4 x i32> @lsr_i32(<vscale x 4 x i32> %a){
745 ; CHECK-LABEL: lsr_i32:
747 ; CHECK-NEXT: lsr z0.s, z0.s, #31
749 %elt = insertelement <vscale x 4 x i32> undef, i32 31, i32 0
750 %splat = shufflevector <vscale x 4 x i32> %elt, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
751 %lshr = lshr <vscale x 4 x i32> %a, %splat
752 ret <vscale x 4 x i32> %lshr
755 define <vscale x 2 x i64> @lsr_i64(<vscale x 2 x i64> %a){
756 ; CHECK-LABEL: lsr_i64:
758 ; CHECK-NEXT: lsr z0.d, z0.d, #63
760 %elt = insertelement <vscale x 2 x i64> undef, i64 63, i32 0
761 %splat = shufflevector <vscale x 2 x i64> %elt, <vscale x 2 x i64> undef, <vscale x 2 x i32> zeroinitializer
762 %lshr = lshr <vscale x 2 x i64> %a, %splat
763 ret <vscale x 2 x i64> %lshr
766 define <vscale x 4 x i32> @sdiv_const(<vscale x 4 x i32> %a) #0 {
767 ; CHECK-LABEL: sdiv_const:
768 ; CHECK: // %bb.0: // %entry
769 ; CHECK-NEXT: mov z1.s, #3 // =0x3
770 ; CHECK-NEXT: ptrue p0.s
771 ; CHECK-NEXT: sdiv z0.s, p0/m, z0.s, z1.s
774 %div = sdiv <vscale x 4 x i32> %a, splat (i32 3)
775 ret <vscale x 4 x i32> %div
778 define <vscale x 4 x i32> @udiv_const(<vscale x 4 x i32> %a) #0 {
779 ; CHECK-LABEL: udiv_const:
780 ; CHECK: // %bb.0: // %entry
781 ; CHECK-NEXT: mov z1.s, #3 // =0x3
782 ; CHECK-NEXT: ptrue p0.s
783 ; CHECK-NEXT: udiv z0.s, p0/m, z0.s, z1.s
786 %div = udiv <vscale x 4 x i32> %a, splat (i32 3)
787 ret <vscale x 4 x i32> %div
793 define <vscale x 8 x i16> @uqsub(<vscale x 8 x i16> %a) {
794 ; CHECK-LABEL: uqsub:
796 ; CHECK-NEXT: uqsub z0.h, z0.h, #32768 // =0x8000
798 %cmp = icmp slt <vscale x 8 x i16> %a, zeroinitializer
799 %sub = xor <vscale x 8 x i16> %a, splat (i16 -32768)
800 %sel = select <vscale x 8 x i1> %cmp, <vscale x 8 x i16> %sub, <vscale x 8 x i16> zeroinitializer
801 ret <vscale x 8 x i16> %sel
804 attributes #0 = { minsize }