1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s
4 declare <1 x i8> @llvm.usub.sat.v1i8(<1 x i8>, <1 x i8>)
5 declare <2 x i8> @llvm.usub.sat.v2i8(<2 x i8>, <2 x i8>)
6 declare <4 x i8> @llvm.usub.sat.v4i8(<4 x i8>, <4 x i8>)
7 declare <8 x i8> @llvm.usub.sat.v8i8(<8 x i8>, <8 x i8>)
8 declare <12 x i8> @llvm.usub.sat.v12i8(<12 x i8>, <12 x i8>)
9 declare <16 x i8> @llvm.usub.sat.v16i8(<16 x i8>, <16 x i8>)
10 declare <32 x i8> @llvm.usub.sat.v32i8(<32 x i8>, <32 x i8>)
11 declare <64 x i8> @llvm.usub.sat.v64i8(<64 x i8>, <64 x i8>)
13 declare <1 x i16> @llvm.usub.sat.v1i16(<1 x i16>, <1 x i16>)
14 declare <2 x i16> @llvm.usub.sat.v2i16(<2 x i16>, <2 x i16>)
15 declare <4 x i16> @llvm.usub.sat.v4i16(<4 x i16>, <4 x i16>)
16 declare <8 x i16> @llvm.usub.sat.v8i16(<8 x i16>, <8 x i16>)
17 declare <12 x i16> @llvm.usub.sat.v12i16(<12 x i16>, <12 x i16>)
18 declare <16 x i16> @llvm.usub.sat.v16i16(<16 x i16>, <16 x i16>)
19 declare <32 x i16> @llvm.usub.sat.v32i16(<32 x i16>, <32 x i16>)
21 declare <16 x i1> @llvm.usub.sat.v16i1(<16 x i1>, <16 x i1>)
22 declare <16 x i4> @llvm.usub.sat.v16i4(<16 x i4>, <16 x i4>)
24 declare <2 x i32> @llvm.usub.sat.v2i32(<2 x i32>, <2 x i32>)
25 declare <4 x i32> @llvm.usub.sat.v4i32(<4 x i32>, <4 x i32>)
26 declare <8 x i32> @llvm.usub.sat.v8i32(<8 x i32>, <8 x i32>)
27 declare <16 x i32> @llvm.usub.sat.v16i32(<16 x i32>, <16 x i32>)
28 declare <2 x i64> @llvm.usub.sat.v2i64(<2 x i64>, <2 x i64>)
29 declare <4 x i64> @llvm.usub.sat.v4i64(<4 x i64>, <4 x i64>)
30 declare <8 x i64> @llvm.usub.sat.v8i64(<8 x i64>, <8 x i64>)
32 declare <4 x i24> @llvm.usub.sat.v4i24(<4 x i24>, <4 x i24>)
33 declare <2 x i128> @llvm.usub.sat.v2i128(<2 x i128>, <2 x i128>)
36 define <16 x i8> @v16i8(<16 x i8> %x, <16 x i8> %y) nounwind {
39 ; CHECK-NEXT: umax v0.16b, v0.16b, v1.16b
40 ; CHECK-NEXT: sub v0.16b, v0.16b, v1.16b
42 %z = call <16 x i8> @llvm.usub.sat.v16i8(<16 x i8> %x, <16 x i8> %y)
46 define <32 x i8> @v32i8(<32 x i8> %x, <32 x i8> %y) nounwind {
49 ; CHECK-NEXT: umax v0.16b, v0.16b, v2.16b
50 ; CHECK-NEXT: umax v1.16b, v1.16b, v3.16b
51 ; CHECK-NEXT: sub v0.16b, v0.16b, v2.16b
52 ; CHECK-NEXT: sub v1.16b, v1.16b, v3.16b
54 %z = call <32 x i8> @llvm.usub.sat.v32i8(<32 x i8> %x, <32 x i8> %y)
58 define <64 x i8> @v64i8(<64 x i8> %x, <64 x i8> %y) nounwind {
61 ; CHECK-NEXT: umax v0.16b, v0.16b, v4.16b
62 ; CHECK-NEXT: umax v1.16b, v1.16b, v5.16b
63 ; CHECK-NEXT: umax v2.16b, v2.16b, v6.16b
64 ; CHECK-NEXT: umax v3.16b, v3.16b, v7.16b
65 ; CHECK-NEXT: sub v0.16b, v0.16b, v4.16b
66 ; CHECK-NEXT: sub v1.16b, v1.16b, v5.16b
67 ; CHECK-NEXT: sub v2.16b, v2.16b, v6.16b
68 ; CHECK-NEXT: sub v3.16b, v3.16b, v7.16b
70 %z = call <64 x i8> @llvm.usub.sat.v64i8(<64 x i8> %x, <64 x i8> %y)
74 define <8 x i16> @v8i16(<8 x i16> %x, <8 x i16> %y) nounwind {
77 ; CHECK-NEXT: umax v0.8h, v0.8h, v1.8h
78 ; CHECK-NEXT: sub v0.8h, v0.8h, v1.8h
80 %z = call <8 x i16> @llvm.usub.sat.v8i16(<8 x i16> %x, <8 x i16> %y)
84 define <16 x i16> @v16i16(<16 x i16> %x, <16 x i16> %y) nounwind {
85 ; CHECK-LABEL: v16i16:
87 ; CHECK-NEXT: umax v0.8h, v0.8h, v2.8h
88 ; CHECK-NEXT: umax v1.8h, v1.8h, v3.8h
89 ; CHECK-NEXT: sub v0.8h, v0.8h, v2.8h
90 ; CHECK-NEXT: sub v1.8h, v1.8h, v3.8h
92 %z = call <16 x i16> @llvm.usub.sat.v16i16(<16 x i16> %x, <16 x i16> %y)
96 define <32 x i16> @v32i16(<32 x i16> %x, <32 x i16> %y) nounwind {
97 ; CHECK-LABEL: v32i16:
99 ; CHECK-NEXT: umax v0.8h, v0.8h, v4.8h
100 ; CHECK-NEXT: umax v1.8h, v1.8h, v5.8h
101 ; CHECK-NEXT: umax v2.8h, v2.8h, v6.8h
102 ; CHECK-NEXT: umax v3.8h, v3.8h, v7.8h
103 ; CHECK-NEXT: sub v0.8h, v0.8h, v4.8h
104 ; CHECK-NEXT: sub v1.8h, v1.8h, v5.8h
105 ; CHECK-NEXT: sub v2.8h, v2.8h, v6.8h
106 ; CHECK-NEXT: sub v3.8h, v3.8h, v7.8h
108 %z = call <32 x i16> @llvm.usub.sat.v32i16(<32 x i16> %x, <32 x i16> %y)
112 define void @v8i8(<8 x i8>* %px, <8 x i8>* %py, <8 x i8>* %pz) nounwind {
115 ; CHECK-NEXT: ldr d0, [x0]
116 ; CHECK-NEXT: ldr d1, [x1]
117 ; CHECK-NEXT: umax v0.8b, v0.8b, v1.8b
118 ; CHECK-NEXT: sub v0.8b, v0.8b, v1.8b
119 ; CHECK-NEXT: str d0, [x2]
121 %x = load <8 x i8>, <8 x i8>* %px
122 %y = load <8 x i8>, <8 x i8>* %py
123 %z = call <8 x i8> @llvm.usub.sat.v8i8(<8 x i8> %x, <8 x i8> %y)
124 store <8 x i8> %z, <8 x i8>* %pz
128 define void @v4i8(<4 x i8>* %px, <4 x i8>* %py, <4 x i8>* %pz) nounwind {
131 ; CHECK-NEXT: ldrb w8, [x0]
132 ; CHECK-NEXT: ldrb w9, [x1]
133 ; CHECK-NEXT: ldrb w10, [x0, #1]
134 ; CHECK-NEXT: ldrb w11, [x1, #1]
135 ; CHECK-NEXT: fmov s0, w8
136 ; CHECK-NEXT: fmov s1, w9
137 ; CHECK-NEXT: ldrb w8, [x0, #2]
138 ; CHECK-NEXT: ldrb w9, [x1, #2]
139 ; CHECK-NEXT: mov v0.h[1], w10
140 ; CHECK-NEXT: mov v1.h[1], w11
141 ; CHECK-NEXT: ldrb w10, [x0, #3]
142 ; CHECK-NEXT: ldrb w11, [x1, #3]
143 ; CHECK-NEXT: mov v0.h[2], w8
144 ; CHECK-NEXT: mov v1.h[2], w9
145 ; CHECK-NEXT: mov v0.h[3], w10
146 ; CHECK-NEXT: mov v1.h[3], w11
147 ; CHECK-NEXT: shl v1.4h, v1.4h, #8
148 ; CHECK-NEXT: shl v0.4h, v0.4h, #8
149 ; CHECK-NEXT: umax v0.4h, v0.4h, v1.4h
150 ; CHECK-NEXT: sub v0.4h, v0.4h, v1.4h
151 ; CHECK-NEXT: ushr v0.4h, v0.4h, #8
152 ; CHECK-NEXT: xtn v0.8b, v0.8h
153 ; CHECK-NEXT: str s0, [x2]
155 %x = load <4 x i8>, <4 x i8>* %px
156 %y = load <4 x i8>, <4 x i8>* %py
157 %z = call <4 x i8> @llvm.usub.sat.v4i8(<4 x i8> %x, <4 x i8> %y)
158 store <4 x i8> %z, <4 x i8>* %pz
162 define void @v2i8(<2 x i8>* %px, <2 x i8>* %py, <2 x i8>* %pz) nounwind {
165 ; CHECK-NEXT: ldrb w8, [x0]
166 ; CHECK-NEXT: ldrb w9, [x1]
167 ; CHECK-NEXT: ldrb w10, [x0, #1]
168 ; CHECK-NEXT: ldrb w11, [x1, #1]
169 ; CHECK-NEXT: fmov s0, w8
170 ; CHECK-NEXT: fmov s1, w9
171 ; CHECK-NEXT: mov v0.s[1], w10
172 ; CHECK-NEXT: mov v1.s[1], w11
173 ; CHECK-NEXT: shl v1.2s, v1.2s, #24
174 ; CHECK-NEXT: shl v0.2s, v0.2s, #24
175 ; CHECK-NEXT: umax v0.2s, v0.2s, v1.2s
176 ; CHECK-NEXT: sub v0.2s, v0.2s, v1.2s
177 ; CHECK-NEXT: ushr v0.2s, v0.2s, #24
178 ; CHECK-NEXT: mov w8, v0.s[1]
179 ; CHECK-NEXT: fmov w9, s0
180 ; CHECK-NEXT: strb w8, [x2, #1]
181 ; CHECK-NEXT: strb w9, [x2]
183 %x = load <2 x i8>, <2 x i8>* %px
184 %y = load <2 x i8>, <2 x i8>* %py
185 %z = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %x, <2 x i8> %y)
186 store <2 x i8> %z, <2 x i8>* %pz
190 define void @v4i16(<4 x i16>* %px, <4 x i16>* %py, <4 x i16>* %pz) nounwind {
191 ; CHECK-LABEL: v4i16:
193 ; CHECK-NEXT: ldr d0, [x0]
194 ; CHECK-NEXT: ldr d1, [x1]
195 ; CHECK-NEXT: umax v0.4h, v0.4h, v1.4h
196 ; CHECK-NEXT: sub v0.4h, v0.4h, v1.4h
197 ; CHECK-NEXT: str d0, [x2]
199 %x = load <4 x i16>, <4 x i16>* %px
200 %y = load <4 x i16>, <4 x i16>* %py
201 %z = call <4 x i16> @llvm.usub.sat.v4i16(<4 x i16> %x, <4 x i16> %y)
202 store <4 x i16> %z, <4 x i16>* %pz
206 define void @v2i16(<2 x i16>* %px, <2 x i16>* %py, <2 x i16>* %pz) nounwind {
207 ; CHECK-LABEL: v2i16:
209 ; CHECK-NEXT: ldrh w8, [x0]
210 ; CHECK-NEXT: ldrh w9, [x1]
211 ; CHECK-NEXT: ldrh w10, [x0, #2]
212 ; CHECK-NEXT: ldrh w11, [x1, #2]
213 ; CHECK-NEXT: fmov s0, w8
214 ; CHECK-NEXT: fmov s1, w9
215 ; CHECK-NEXT: mov v0.s[1], w10
216 ; CHECK-NEXT: mov v1.s[1], w11
217 ; CHECK-NEXT: shl v1.2s, v1.2s, #16
218 ; CHECK-NEXT: shl v0.2s, v0.2s, #16
219 ; CHECK-NEXT: umax v0.2s, v0.2s, v1.2s
220 ; CHECK-NEXT: sub v0.2s, v0.2s, v1.2s
221 ; CHECK-NEXT: ushr v0.2s, v0.2s, #16
222 ; CHECK-NEXT: mov w8, v0.s[1]
223 ; CHECK-NEXT: fmov w9, s0
224 ; CHECK-NEXT: strh w8, [x2, #2]
225 ; CHECK-NEXT: strh w9, [x2]
227 %x = load <2 x i16>, <2 x i16>* %px
228 %y = load <2 x i16>, <2 x i16>* %py
229 %z = call <2 x i16> @llvm.usub.sat.v2i16(<2 x i16> %x, <2 x i16> %y)
230 store <2 x i16> %z, <2 x i16>* %pz
234 define <12 x i8> @v12i8(<12 x i8> %x, <12 x i8> %y) nounwind {
235 ; CHECK-LABEL: v12i8:
237 ; CHECK-NEXT: umax v0.16b, v0.16b, v1.16b
238 ; CHECK-NEXT: sub v0.16b, v0.16b, v1.16b
240 %z = call <12 x i8> @llvm.usub.sat.v12i8(<12 x i8> %x, <12 x i8> %y)
244 define void @v12i16(<12 x i16>* %px, <12 x i16>* %py, <12 x i16>* %pz) nounwind {
245 ; CHECK-LABEL: v12i16:
247 ; CHECK-NEXT: ldp q0, q1, [x0]
248 ; CHECK-NEXT: ldp q3, q2, [x1]
249 ; CHECK-NEXT: umax v1.8h, v1.8h, v2.8h
250 ; CHECK-NEXT: umax v0.8h, v0.8h, v3.8h
251 ; CHECK-NEXT: sub v1.8h, v1.8h, v2.8h
252 ; CHECK-NEXT: sub v0.8h, v0.8h, v3.8h
253 ; CHECK-NEXT: str q0, [x2]
254 ; CHECK-NEXT: str d1, [x2, #16]
256 %x = load <12 x i16>, <12 x i16>* %px
257 %y = load <12 x i16>, <12 x i16>* %py
258 %z = call <12 x i16> @llvm.usub.sat.v12i16(<12 x i16> %x, <12 x i16> %y)
259 store <12 x i16> %z, <12 x i16>* %pz
263 define void @v1i8(<1 x i8>* %px, <1 x i8>* %py, <1 x i8>* %pz) nounwind {
266 ; CHECK-NEXT: ldr b0, [x0]
267 ; CHECK-NEXT: ldr b1, [x1]
268 ; CHECK-NEXT: umax v0.8b, v0.8b, v1.8b
269 ; CHECK-NEXT: sub v0.8b, v0.8b, v1.8b
270 ; CHECK-NEXT: st1 { v0.b }[0], [x2]
272 %x = load <1 x i8>, <1 x i8>* %px
273 %y = load <1 x i8>, <1 x i8>* %py
274 %z = call <1 x i8> @llvm.usub.sat.v1i8(<1 x i8> %x, <1 x i8> %y)
275 store <1 x i8> %z, <1 x i8>* %pz
279 define void @v1i16(<1 x i16>* %px, <1 x i16>* %py, <1 x i16>* %pz) nounwind {
280 ; CHECK-LABEL: v1i16:
282 ; CHECK-NEXT: ldr h0, [x0]
283 ; CHECK-NEXT: ldr h1, [x1]
284 ; CHECK-NEXT: umax v0.4h, v0.4h, v1.4h
285 ; CHECK-NEXT: sub v0.4h, v0.4h, v1.4h
286 ; CHECK-NEXT: str h0, [x2]
288 %x = load <1 x i16>, <1 x i16>* %px
289 %y = load <1 x i16>, <1 x i16>* %py
290 %z = call <1 x i16> @llvm.usub.sat.v1i16(<1 x i16> %x, <1 x i16> %y)
291 store <1 x i16> %z, <1 x i16>* %pz
295 define <16 x i4> @v16i4(<16 x i4> %x, <16 x i4> %y) nounwind {
296 ; CHECK-LABEL: v16i4:
298 ; CHECK-NEXT: shl v1.16b, v1.16b, #4
299 ; CHECK-NEXT: shl v0.16b, v0.16b, #4
300 ; CHECK-NEXT: umax v0.16b, v0.16b, v1.16b
301 ; CHECK-NEXT: sub v0.16b, v0.16b, v1.16b
302 ; CHECK-NEXT: ushr v0.16b, v0.16b, #4
304 %z = call <16 x i4> @llvm.usub.sat.v16i4(<16 x i4> %x, <16 x i4> %y)
308 define <16 x i1> @v16i1(<16 x i1> %x, <16 x i1> %y) nounwind {
309 ; CHECK-LABEL: v16i1:
311 ; CHECK-NEXT: shl v1.16b, v1.16b, #7
312 ; CHECK-NEXT: shl v0.16b, v0.16b, #7
313 ; CHECK-NEXT: umax v0.16b, v0.16b, v1.16b
314 ; CHECK-NEXT: sub v0.16b, v0.16b, v1.16b
315 ; CHECK-NEXT: ushr v0.16b, v0.16b, #7
317 %z = call <16 x i1> @llvm.usub.sat.v16i1(<16 x i1> %x, <16 x i1> %y)
321 define <2 x i32> @v2i32(<2 x i32> %x, <2 x i32> %y) nounwind {
322 ; CHECK-LABEL: v2i32:
324 ; CHECK-NEXT: umax v0.2s, v0.2s, v1.2s
325 ; CHECK-NEXT: sub v0.2s, v0.2s, v1.2s
327 %z = call <2 x i32> @llvm.usub.sat.v2i32(<2 x i32> %x, <2 x i32> %y)
331 define <4 x i32> @v4i32(<4 x i32> %x, <4 x i32> %y) nounwind {
332 ; CHECK-LABEL: v4i32:
334 ; CHECK-NEXT: umax v0.4s, v0.4s, v1.4s
335 ; CHECK-NEXT: sub v0.4s, v0.4s, v1.4s
337 %z = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %x, <4 x i32> %y)
341 define <8 x i32> @v8i32(<8 x i32> %x, <8 x i32> %y) nounwind {
342 ; CHECK-LABEL: v8i32:
344 ; CHECK-NEXT: umax v0.4s, v0.4s, v2.4s
345 ; CHECK-NEXT: umax v1.4s, v1.4s, v3.4s
346 ; CHECK-NEXT: sub v0.4s, v0.4s, v2.4s
347 ; CHECK-NEXT: sub v1.4s, v1.4s, v3.4s
349 %z = call <8 x i32> @llvm.usub.sat.v8i32(<8 x i32> %x, <8 x i32> %y)
353 define <16 x i32> @v16i32(<16 x i32> %x, <16 x i32> %y) nounwind {
354 ; CHECK-LABEL: v16i32:
356 ; CHECK-NEXT: umax v0.4s, v0.4s, v4.4s
357 ; CHECK-NEXT: umax v1.4s, v1.4s, v5.4s
358 ; CHECK-NEXT: umax v2.4s, v2.4s, v6.4s
359 ; CHECK-NEXT: umax v3.4s, v3.4s, v7.4s
360 ; CHECK-NEXT: sub v0.4s, v0.4s, v4.4s
361 ; CHECK-NEXT: sub v1.4s, v1.4s, v5.4s
362 ; CHECK-NEXT: sub v2.4s, v2.4s, v6.4s
363 ; CHECK-NEXT: sub v3.4s, v3.4s, v7.4s
365 %z = call <16 x i32> @llvm.usub.sat.v16i32(<16 x i32> %x, <16 x i32> %y)
369 define <2 x i64> @v2i64(<2 x i64> %x, <2 x i64> %y) nounwind {
370 ; CHECK-LABEL: v2i64:
372 ; CHECK-NEXT: sub v1.2d, v0.2d, v1.2d
373 ; CHECK-NEXT: cmhi v0.2d, v1.2d, v0.2d
374 ; CHECK-NEXT: bic v0.16b, v1.16b, v0.16b
376 %z = call <2 x i64> @llvm.usub.sat.v2i64(<2 x i64> %x, <2 x i64> %y)
380 define <4 x i64> @v4i64(<4 x i64> %x, <4 x i64> %y) nounwind {
381 ; CHECK-LABEL: v4i64:
383 ; CHECK-NEXT: sub v2.2d, v0.2d, v2.2d
384 ; CHECK-NEXT: sub v3.2d, v1.2d, v3.2d
385 ; CHECK-NEXT: cmhi v0.2d, v2.2d, v0.2d
386 ; CHECK-NEXT: cmhi v1.2d, v3.2d, v1.2d
387 ; CHECK-NEXT: bic v0.16b, v2.16b, v0.16b
388 ; CHECK-NEXT: bic v1.16b, v3.16b, v1.16b
390 %z = call <4 x i64> @llvm.usub.sat.v4i64(<4 x i64> %x, <4 x i64> %y)
394 define <8 x i64> @v8i64(<8 x i64> %x, <8 x i64> %y) nounwind {
395 ; CHECK-LABEL: v8i64:
397 ; CHECK-NEXT: sub v4.2d, v0.2d, v4.2d
398 ; CHECK-NEXT: sub v5.2d, v1.2d, v5.2d
399 ; CHECK-NEXT: sub v6.2d, v2.2d, v6.2d
400 ; CHECK-NEXT: sub v7.2d, v3.2d, v7.2d
401 ; CHECK-NEXT: cmhi v0.2d, v4.2d, v0.2d
402 ; CHECK-NEXT: cmhi v1.2d, v5.2d, v1.2d
403 ; CHECK-NEXT: cmhi v2.2d, v6.2d, v2.2d
404 ; CHECK-NEXT: cmhi v3.2d, v7.2d, v3.2d
405 ; CHECK-NEXT: bic v0.16b, v4.16b, v0.16b
406 ; CHECK-NEXT: bic v1.16b, v5.16b, v1.16b
407 ; CHECK-NEXT: bic v2.16b, v6.16b, v2.16b
408 ; CHECK-NEXT: bic v3.16b, v7.16b, v3.16b
410 %z = call <8 x i64> @llvm.usub.sat.v8i64(<8 x i64> %x, <8 x i64> %y)
414 define <2 x i128> @v2i128(<2 x i128> %x, <2 x i128> %y) nounwind {
415 ; CHECK-LABEL: v2i128:
417 ; CHECK-NEXT: subs x8, x2, x6
418 ; CHECK-NEXT: sbcs x9, x3, x7
419 ; CHECK-NEXT: cmp x8, x2
420 ; CHECK-NEXT: cset w10, hi
421 ; CHECK-NEXT: cmp x9, x3
422 ; CHECK-NEXT: cset w11, hi
423 ; CHECK-NEXT: csel w10, w10, w11, eq
424 ; CHECK-NEXT: cmp w10, #0 // =0
425 ; CHECK-NEXT: csel x3, xzr, x9, ne
426 ; CHECK-NEXT: csel x2, xzr, x8, ne
427 ; CHECK-NEXT: subs x8, x0, x4
428 ; CHECK-NEXT: sbcs x9, x1, x5
429 ; CHECK-NEXT: cmp x8, x0
430 ; CHECK-NEXT: cset w10, hi
431 ; CHECK-NEXT: cmp x9, x1
432 ; CHECK-NEXT: cset w11, hi
433 ; CHECK-NEXT: csel w10, w10, w11, eq
434 ; CHECK-NEXT: cmp w10, #0 // =0
435 ; CHECK-NEXT: csel x8, xzr, x8, ne
436 ; CHECK-NEXT: csel x1, xzr, x9, ne
437 ; CHECK-NEXT: fmov d0, x8
438 ; CHECK-NEXT: mov v0.d[1], x1
439 ; CHECK-NEXT: fmov x0, d0
441 %z = call <2 x i128> @llvm.usub.sat.v2i128(<2 x i128> %x, <2 x i128> %y)