1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc -mtriple=aarch64-none-linux-gnu %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SD
3 ; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-GI
5 ; ===== Legal Scalars =====
7 define i8 @abs_i8(i8 %a){
8 ; CHECK-SD-LABEL: abs_i8:
9 ; CHECK-SD: // %bb.0: // %entry
10 ; CHECK-SD-NEXT: sxtb w8, w0
11 ; CHECK-SD-NEXT: cmp w8, #0
12 ; CHECK-SD-NEXT: cneg w0, w8, mi
15 ; CHECK-GI-LABEL: abs_i8:
16 ; CHECK-GI: // %bb.0: // %entry
17 ; CHECK-GI-NEXT: sxtb w8, w0
18 ; CHECK-GI-NEXT: cmp w8, #0
19 ; CHECK-GI-NEXT: cneg w0, w0, le
22 %res = call i8 @llvm.abs.i8(i8 %a, i1 0)
25 declare i8 @llvm.abs.i8(i8, i1)
27 define i16 @abs_i16(i16 %a){
28 ; CHECK-SD-LABEL: abs_i16:
29 ; CHECK-SD: // %bb.0: // %entry
30 ; CHECK-SD-NEXT: sxth w8, w0
31 ; CHECK-SD-NEXT: cmp w8, #0
32 ; CHECK-SD-NEXT: cneg w0, w8, mi
35 ; CHECK-GI-LABEL: abs_i16:
36 ; CHECK-GI: // %bb.0: // %entry
37 ; CHECK-GI-NEXT: sxth w8, w0
38 ; CHECK-GI-NEXT: cmp w8, #0
39 ; CHECK-GI-NEXT: cneg w0, w0, le
42 %res = call i16 @llvm.abs.i16(i16 %a, i1 0)
45 declare i16 @llvm.abs.i16(i16, i1)
47 define i32 @abs_i32(i32 %a){
48 ; CHECK-SD-LABEL: abs_i32:
49 ; CHECK-SD: // %bb.0: // %entry
50 ; CHECK-SD-NEXT: cmp w0, #0
51 ; CHECK-SD-NEXT: cneg w0, w0, mi
54 ; CHECK-GI-LABEL: abs_i32:
55 ; CHECK-GI: // %bb.0: // %entry
56 ; CHECK-GI-NEXT: cmp w0, #0
57 ; CHECK-GI-NEXT: cneg w0, w0, le
60 %res = call i32 @llvm.abs.i32(i32 %a, i1 0)
63 declare i32 @llvm.abs.i32(i32, i1)
65 define i64 @abs_i64(i64 %a){
66 ; CHECK-SD-LABEL: abs_i64:
67 ; CHECK-SD: // %bb.0: // %entry
68 ; CHECK-SD-NEXT: cmp x0, #0
69 ; CHECK-SD-NEXT: cneg x0, x0, mi
72 ; CHECK-GI-LABEL: abs_i64:
73 ; CHECK-GI: // %bb.0: // %entry
74 ; CHECK-GI-NEXT: cmp x0, #0
75 ; CHECK-GI-NEXT: cneg x0, x0, le
78 %res = call i64 @llvm.abs.i64(i64 %a, i1 0)
81 declare i64 @llvm.abs.i64(i64, i1)
83 define i128 @abs_i128(i128 %a){
84 ; CHECK-SD-LABEL: abs_i128:
85 ; CHECK-SD: // %bb.0: // %entry
86 ; CHECK-SD-NEXT: asr x8, x1, #63
87 ; CHECK-SD-NEXT: eor x9, x0, x8
88 ; CHECK-SD-NEXT: eor x10, x1, x8
89 ; CHECK-SD-NEXT: subs x0, x9, x8
90 ; CHECK-SD-NEXT: sbc x1, x10, x8
93 ; CHECK-GI-LABEL: abs_i128:
94 ; CHECK-GI: // %bb.0: // %entry
95 ; CHECK-GI-NEXT: asr x8, x1, #63
96 ; CHECK-GI-NEXT: adds x9, x0, x8
97 ; CHECK-GI-NEXT: adc x10, x1, x8
98 ; CHECK-GI-NEXT: eor x0, x9, x8
99 ; CHECK-GI-NEXT: eor x1, x10, x8
102 %res = call i128 @llvm.abs.i128(i128 %a, i1 0)
105 declare i128 @llvm.abs.i128(i128, i1)
107 ; ===== Legal Vector Types =====
109 define <8 x i8> @abs_v8i8(<8 x i8> %a){
110 ; CHECK-LABEL: abs_v8i8:
111 ; CHECK: // %bb.0: // %entry
112 ; CHECK-NEXT: abs v0.8b, v0.8b
115 %res = call <8 x i8> @llvm.abs.v8i8(<8 x i8> %a, i1 0)
118 declare <8 x i8> @llvm.abs.v8i8(<8 x i8>, i1)
120 define <16 x i8> @abs_v16i8(<16 x i8> %a){
121 ; CHECK-LABEL: abs_v16i8:
122 ; CHECK: // %bb.0: // %entry
123 ; CHECK-NEXT: abs v0.16b, v0.16b
126 %res = call <16 x i8> @llvm.abs.v16i8(<16 x i8> %a, i1 0)
129 declare <16 x i8> @llvm.abs.v16i8(<16 x i8>, i1)
131 define <4 x i16> @abs_v4i16(<4 x i16> %a){
132 ; CHECK-LABEL: abs_v4i16:
133 ; CHECK: // %bb.0: // %entry
134 ; CHECK-NEXT: abs v0.4h, v0.4h
137 %res = call <4 x i16> @llvm.abs.v4i16(<4 x i16> %a, i1 0)
140 declare <4 x i16> @llvm.abs.v4i16(<4 x i16>, i1)
142 define <8 x i16> @abs_v8i16(<8 x i16> %a){
143 ; CHECK-LABEL: abs_v8i16:
144 ; CHECK: // %bb.0: // %entry
145 ; CHECK-NEXT: abs v0.8h, v0.8h
148 %res = call <8 x i16> @llvm.abs.v8i16(<8 x i16> %a, i1 0)
151 declare <8 x i16> @llvm.abs.v8i16(<8 x i16>, i1)
153 define <2 x i32> @abs_v2i32(<2 x i32> %a){
154 ; CHECK-LABEL: abs_v2i32:
155 ; CHECK: // %bb.0: // %entry
156 ; CHECK-NEXT: abs v0.2s, v0.2s
159 %res = call <2 x i32> @llvm.abs.v2i32(<2 x i32> %a, i1 0)
162 declare <2 x i32> @llvm.abs.v2i32(<2 x i32>, i1)
164 define <4 x i32> @abs_v4i32(<4 x i32> %a){
165 ; CHECK-LABEL: abs_v4i32:
166 ; CHECK: // %bb.0: // %entry
167 ; CHECK-NEXT: abs v0.4s, v0.4s
170 %res = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %a, i1 0)
173 declare <4 x i32> @llvm.abs.v4i32(<4 x i32>, i1)
175 define <2 x i64> @abs_v2i64(<2 x i64> %a){
176 ; CHECK-LABEL: abs_v2i64:
177 ; CHECK: // %bb.0: // %entry
178 ; CHECK-NEXT: abs v0.2d, v0.2d
181 %res = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %a, i1 0)
184 declare <2 x i64> @llvm.abs.v2i64(<2 x i64>, i1)
186 ; ===== Smaller/Larger Width Vectors with Legal Element Sizes =====
188 define <4 x i8> @abs_v4i8(<4 x i8> %a){
189 ; CHECK-LABEL: abs_v4i8:
190 ; CHECK: // %bb.0: // %entry
191 ; CHECK-NEXT: shl v0.4h, v0.4h, #8
192 ; CHECK-NEXT: sshr v0.4h, v0.4h, #8
193 ; CHECK-NEXT: abs v0.4h, v0.4h
196 %res = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %a, i1 0)
199 declare <4 x i8> @llvm.abs.v4i8(<4 x i8>, i1)
201 define <32 x i8> @abs_v32i8(<32 x i8> %a){
202 ; CHECK-LABEL: abs_v32i8:
203 ; CHECK: // %bb.0: // %entry
204 ; CHECK-NEXT: abs v0.16b, v0.16b
205 ; CHECK-NEXT: abs v1.16b, v1.16b
208 %res = call <32 x i8> @llvm.abs.v32i8(<32 x i8> %a, i1 0)
211 declare <32 x i8> @llvm.abs.v32i8(<32 x i8>, i1)
213 define <2 x i16> @abs_v2i16(<2 x i16> %a){
214 ; CHECK-LABEL: abs_v2i16:
215 ; CHECK: // %bb.0: // %entry
216 ; CHECK-NEXT: shl v0.2s, v0.2s, #16
217 ; CHECK-NEXT: sshr v0.2s, v0.2s, #16
218 ; CHECK-NEXT: abs v0.2s, v0.2s
221 %res = call <2 x i16> @llvm.abs.v2i16(<2 x i16> %a, i1 0)
224 declare <2 x i16> @llvm.abs.v2i16(<2 x i16>, i1)
226 define <16 x i16> @abs_v16i16(<16 x i16> %a){
227 ; CHECK-LABEL: abs_v16i16:
228 ; CHECK: // %bb.0: // %entry
229 ; CHECK-NEXT: abs v0.8h, v0.8h
230 ; CHECK-NEXT: abs v1.8h, v1.8h
233 %res = call <16 x i16> @llvm.abs.v16i16(<16 x i16> %a, i1 0)
236 declare <16 x i16> @llvm.abs.v16i16(<16 x i16>, i1)
238 define <1 x i32> @abs_v1i32(<1 x i32> %a){
239 ; CHECK-SD-LABEL: abs_v1i32:
240 ; CHECK-SD: // %bb.0: // %entry
241 ; CHECK-SD-NEXT: abs v0.2s, v0.2s
244 ; CHECK-GI-LABEL: abs_v1i32:
245 ; CHECK-GI: // %bb.0: // %entry
246 ; CHECK-GI-NEXT: fmov w8, s0
247 ; CHECK-GI-NEXT: fmov w9, s0
248 ; CHECK-GI-NEXT: cmp w8, #0
249 ; CHECK-GI-NEXT: cneg w8, w9, le
250 ; CHECK-GI-NEXT: mov v0.s[0], w8
251 ; CHECK-GI-NEXT: // kill: def $d0 killed $d0 killed $q0
254 %res = call <1 x i32> @llvm.abs.v1i32(<1 x i32> %a, i1 0)
257 declare <1 x i32> @llvm.abs.v1i32(<1 x i32>, i1)
259 define <8 x i32> @abs_v8i32(<8 x i32> %a){
260 ; CHECK-LABEL: abs_v8i32:
261 ; CHECK: // %bb.0: // %entry
262 ; CHECK-NEXT: abs v0.4s, v0.4s
263 ; CHECK-NEXT: abs v1.4s, v1.4s
266 %res = call <8 x i32> @llvm.abs.v8i32(<8 x i32> %a, i1 0)
269 declare <8 x i32> @llvm.abs.v8i32(<8 x i32>, i1)
271 define <4 x i64> @abs_v4i64(<4 x i64> %a){
272 ; CHECK-LABEL: abs_v4i64:
273 ; CHECK: // %bb.0: // %entry
274 ; CHECK-NEXT: abs v0.2d, v0.2d
275 ; CHECK-NEXT: abs v1.2d, v1.2d
278 %res = call <4 x i64> @llvm.abs.v4i64(<4 x i64> %a, i1 0)
281 declare <4 x i64> @llvm.abs.v4i64(<4 x i64>, i1)
283 define <2 x i128> @abs_v4i128(<2 x i128> %a){
284 ; CHECK-SD-LABEL: abs_v4i128:
285 ; CHECK-SD: // %bb.0: // %entry
286 ; CHECK-SD-NEXT: asr x8, x1, #63
287 ; CHECK-SD-NEXT: asr x9, x3, #63
288 ; CHECK-SD-NEXT: eor x10, x0, x8
289 ; CHECK-SD-NEXT: eor x11, x1, x8
290 ; CHECK-SD-NEXT: subs x0, x10, x8
291 ; CHECK-SD-NEXT: eor x10, x2, x9
292 ; CHECK-SD-NEXT: sbc x1, x11, x8
293 ; CHECK-SD-NEXT: eor x8, x3, x9
294 ; CHECK-SD-NEXT: subs x2, x10, x9
295 ; CHECK-SD-NEXT: sbc x3, x8, x9
298 ; CHECK-GI-LABEL: abs_v4i128:
299 ; CHECK-GI: // %bb.0: // %entry
300 ; CHECK-GI-NEXT: asr x8, x1, #63
301 ; CHECK-GI-NEXT: asr x9, x3, #63
302 ; CHECK-GI-NEXT: adds x10, x0, x8
303 ; CHECK-GI-NEXT: adc x11, x1, x8
304 ; CHECK-GI-NEXT: adds x12, x2, x9
305 ; CHECK-GI-NEXT: eor x0, x10, x8
306 ; CHECK-GI-NEXT: adc x13, x3, x9
307 ; CHECK-GI-NEXT: eor x1, x11, x8
308 ; CHECK-GI-NEXT: eor x2, x12, x9
309 ; CHECK-GI-NEXT: eor x3, x13, x9
312 %res = call <2 x i128> @llvm.abs.v2i128(<2 x i128> %a, i1 0)
315 declare <2 x i128> @llvm.abs.v2i128(<2 x i128>, i1)
317 ; ===== Vectors with Non-Pow 2 Widths =====
319 define <3 x i8> @abs_v3i8(<3 x i8> %a){
320 ; CHECK-SD-LABEL: abs_v3i8:
321 ; CHECK-SD: // %bb.0: // %entry
322 ; CHECK-SD-NEXT: fmov s0, w0
323 ; CHECK-SD-NEXT: mov v0.h[1], w1
324 ; CHECK-SD-NEXT: mov v0.h[2], w2
325 ; CHECK-SD-NEXT: shl v0.4h, v0.4h, #8
326 ; CHECK-SD-NEXT: sshr v0.4h, v0.4h, #8
327 ; CHECK-SD-NEXT: abs v0.4h, v0.4h
328 ; CHECK-SD-NEXT: umov w0, v0.h[0]
329 ; CHECK-SD-NEXT: umov w1, v0.h[1]
330 ; CHECK-SD-NEXT: umov w2, v0.h[2]
333 ; CHECK-GI-LABEL: abs_v3i8:
334 ; CHECK-GI: // %bb.0: // %entry
335 ; CHECK-GI-NEXT: fmov s0, w0
336 ; CHECK-GI-NEXT: mov v0.b[1], w1
337 ; CHECK-GI-NEXT: mov v0.b[2], w2
338 ; CHECK-GI-NEXT: abs v0.8b, v0.8b
339 ; CHECK-GI-NEXT: umov w0, v0.b[0]
340 ; CHECK-GI-NEXT: umov w1, v0.b[1]
341 ; CHECK-GI-NEXT: umov w2, v0.b[2]
344 %res = call <3 x i8> @llvm.abs.v3i8(<3 x i8> %a, i1 0)
347 declare <3 x i8> @llvm.abs.v3i8(<3 x i8>, i1)
349 define <7 x i8> @abs_v7i8(<7 x i8> %a){
350 ; CHECK-LABEL: abs_v7i8:
351 ; CHECK: // %bb.0: // %entry
352 ; CHECK-NEXT: abs v0.8b, v0.8b
355 %res = call <7 x i8> @llvm.abs.v7i8(<7 x i8> %a, i1 0)
358 declare <7 x i8> @llvm.abs.v7i8(<7 x i8>, i1)
360 define <3 x i16> @abs_v3i16(<3 x i16> %a){
361 ; CHECK-LABEL: abs_v3i16:
362 ; CHECK: // %bb.0: // %entry
363 ; CHECK-NEXT: abs v0.4h, v0.4h
366 %res = call <3 x i16> @llvm.abs.v3i16(<3 x i16> %a, i1 0)
369 declare <3 x i16> @llvm.abs.v3i16(<3 x i16>, i1)
371 define <7 x i16> @abs_v7i16(<7 x i16> %a){
372 ; CHECK-LABEL: abs_v7i16:
373 ; CHECK: // %bb.0: // %entry
374 ; CHECK-NEXT: abs v0.8h, v0.8h
377 %res = call <7 x i16> @llvm.abs.v7i16(<7 x i16> %a, i1 0)
380 declare <7 x i16> @llvm.abs.v7i16(<7 x i16>, i1)
382 define <3 x i32> @abs_v3i32(<3 x i32> %a){
383 ; CHECK-LABEL: abs_v3i32:
384 ; CHECK: // %bb.0: // %entry
385 ; CHECK-NEXT: abs v0.4s, v0.4s
388 %res = call <3 x i32> @llvm.abs.v3i32(<3 x i32> %a, i1 0)
391 declare <3 x i32> @llvm.abs.v3i32(<3 x i32>, i1)