Skip to content

Commit 81363b6

Browse files
committed
[AArch64][GlobalISel] Pre-Commit Test Update for Legalize G_ABS Large Vector
1 parent bfef161 commit 81363b6

File tree

2 files changed

+370
-1
lines changed

2 files changed

+370
-1
lines changed

llvm/test/CodeGen/AArch64/abs.ll

Lines changed: 363 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,363 @@
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 -global-isel-abort=2 %s -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI
4+
5+
; CHECK-GI: warning: Instruction selection used fallback path for abs_v4i8
6+
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v32i8
7+
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v2i16
8+
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v16i16
9+
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v8i32
10+
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v4i64
11+
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v3i8
12+
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v7i8
13+
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v3i16
14+
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v7i16
15+
; CHECK-GI-NEXT: warning: Instruction selection used fallback path for abs_v3i32
16+
17+
; ===== Legal Scalars =====
18+
19+
define i8 @abs_i8(i8 %a){
20+
; CHECK-SD-LABEL: abs_i8:
21+
; CHECK-SD: // %bb.0: // %entry
22+
; CHECK-SD-NEXT: sxtb w8, w0
23+
; CHECK-SD-NEXT: cmp w8, #0
24+
; CHECK-SD-NEXT: cneg w0, w8, mi
25+
; CHECK-SD-NEXT: ret
26+
;
27+
; CHECK-GI-LABEL: abs_i8:
28+
; CHECK-GI: // %bb.0: // %entry
29+
; CHECK-GI-NEXT: sxtb w8, w0
30+
; CHECK-GI-NEXT: asr w8, w8, #7
31+
; CHECK-GI-NEXT: add w9, w0, w8
32+
; CHECK-GI-NEXT: eor w0, w9, w8
33+
; CHECK-GI-NEXT: ret
34+
entry:
35+
%res = call i8 @llvm.abs.i8(i8 %a, i1 0)
36+
ret i8 %res
37+
}
38+
declare i8 @llvm.abs.i8(i8, i1)
39+
40+
define i16 @abs_i16(i16 %a){
41+
; CHECK-SD-LABEL: abs_i16:
42+
; CHECK-SD: // %bb.0: // %entry
43+
; CHECK-SD-NEXT: sxth w8, w0
44+
; CHECK-SD-NEXT: cmp w8, #0
45+
; CHECK-SD-NEXT: cneg w0, w8, mi
46+
; CHECK-SD-NEXT: ret
47+
;
48+
; CHECK-GI-LABEL: abs_i16:
49+
; CHECK-GI: // %bb.0: // %entry
50+
; CHECK-GI-NEXT: sxth w8, w0
51+
; CHECK-GI-NEXT: asr w8, w8, #15
52+
; CHECK-GI-NEXT: add w9, w0, w8
53+
; CHECK-GI-NEXT: eor w0, w9, w8
54+
; CHECK-GI-NEXT: ret
55+
entry:
56+
%res = call i16 @llvm.abs.i16(i16 %a, i1 0)
57+
ret i16 %res
58+
}
59+
declare i16 @llvm.abs.i16(i16, i1)
60+
61+
define i32 @abs_i32(i32 %a){
62+
; CHECK-SD-LABEL: abs_i32:
63+
; CHECK-SD: // %bb.0: // %entry
64+
; CHECK-SD-NEXT: cmp w0, #0
65+
; CHECK-SD-NEXT: cneg w0, w0, mi
66+
; CHECK-SD-NEXT: ret
67+
;
68+
; CHECK-GI-LABEL: abs_i32:
69+
; CHECK-GI: // %bb.0: // %entry
70+
; CHECK-GI-NEXT: asr w8, w0, #31
71+
; CHECK-GI-NEXT: add w9, w0, w8
72+
; CHECK-GI-NEXT: eor w0, w9, w8
73+
; CHECK-GI-NEXT: ret
74+
entry:
75+
%res = call i32 @llvm.abs.i32(i32 %a, i1 0)
76+
ret i32 %res
77+
}
78+
declare i32 @llvm.abs.i32(i32, i1)
79+
80+
define i64 @abs_i64(i64 %a){
81+
; CHECK-SD-LABEL: abs_i64:
82+
; CHECK-SD: // %bb.0: // %entry
83+
; CHECK-SD-NEXT: cmp x0, #0
84+
; CHECK-SD-NEXT: cneg x0, x0, mi
85+
; CHECK-SD-NEXT: ret
86+
;
87+
; CHECK-GI-LABEL: abs_i64:
88+
; CHECK-GI: // %bb.0: // %entry
89+
; CHECK-GI-NEXT: asr x8, x0, #63
90+
; CHECK-GI-NEXT: add x9, x0, x8
91+
; CHECK-GI-NEXT: eor x0, x9, x8
92+
; CHECK-GI-NEXT: ret
93+
entry:
94+
%res = call i64 @llvm.abs.i64(i64 %a, i1 0)
95+
ret i64 %res
96+
}
97+
declare i64 @llvm.abs.i64(i64, i1)
98+
99+
define i128 @abs_i128(i128 %a){
100+
; CHECK-SD-LABEL: abs_i128:
101+
; CHECK-SD: // %bb.0: // %entry
102+
; CHECK-SD-NEXT: asr x8, x1, #63
103+
; CHECK-SD-NEXT: eor x9, x0, x8
104+
; CHECK-SD-NEXT: eor x10, x1, x8
105+
; CHECK-SD-NEXT: subs x0, x9, x8
106+
; CHECK-SD-NEXT: sbc x1, x10, x8
107+
; CHECK-SD-NEXT: ret
108+
;
109+
; CHECK-GI-LABEL: abs_i128:
110+
; CHECK-GI: // %bb.0: // %entry
111+
; CHECK-GI-NEXT: asr x8, x1, #63
112+
; CHECK-GI-NEXT: adds x9, x0, x8
113+
; CHECK-GI-NEXT: adc x10, x1, x8
114+
; CHECK-GI-NEXT: eor x0, x9, x8
115+
; CHECK-GI-NEXT: eor x1, x10, x8
116+
; CHECK-GI-NEXT: ret
117+
entry:
118+
%res = call i128 @llvm.abs.i128(i128 %a, i1 0)
119+
ret i128 %res
120+
}
121+
declare i128 @llvm.abs.i128(i128, i1)
122+
123+
; ===== Legal Vector Types =====
124+
125+
define <8 x i8> @abs_v8i8(<8 x i8> %a){
126+
; CHECK-LABEL: abs_v8i8:
127+
; CHECK: // %bb.0: // %entry
128+
; CHECK-NEXT: abs v0.8b, v0.8b
129+
; CHECK-NEXT: ret
130+
entry:
131+
%res = call <8 x i8> @llvm.abs.v8i8(<8 x i8> %a, i1 0)
132+
ret <8 x i8> %res
133+
}
134+
declare <8 x i8> @llvm.abs.v8i8(<8 x i8>, i1)
135+
136+
define <16 x i8> @abs_v16i8(<16 x i8> %a){
137+
; CHECK-LABEL: abs_v16i8:
138+
; CHECK: // %bb.0: // %entry
139+
; CHECK-NEXT: abs v0.16b, v0.16b
140+
; CHECK-NEXT: ret
141+
entry:
142+
%res = call <16 x i8> @llvm.abs.v16i8(<16 x i8> %a, i1 0)
143+
ret <16 x i8> %res
144+
}
145+
declare <16 x i8> @llvm.abs.v16i8(<16 x i8>, i1)
146+
147+
define <4 x i16> @abs_v4i16(<4 x i16> %a){
148+
; CHECK-LABEL: abs_v4i16:
149+
; CHECK: // %bb.0: // %entry
150+
; CHECK-NEXT: abs v0.4h, v0.4h
151+
; CHECK-NEXT: ret
152+
entry:
153+
%res = call <4 x i16> @llvm.abs.v4i16(<4 x i16> %a, i1 0)
154+
ret <4 x i16> %res
155+
}
156+
declare <4 x i16> @llvm.abs.v4i16(<4 x i16>, i1)
157+
158+
define <8 x i16> @abs_v8i16(<8 x i16> %a){
159+
; CHECK-LABEL: abs_v8i16:
160+
; CHECK: // %bb.0: // %entry
161+
; CHECK-NEXT: abs v0.8h, v0.8h
162+
; CHECK-NEXT: ret
163+
entry:
164+
%res = call <8 x i16> @llvm.abs.v8i16(<8 x i16> %a, i1 0)
165+
ret <8 x i16> %res
166+
}
167+
declare <8 x i16> @llvm.abs.v8i16(<8 x i16>, i1)
168+
169+
define <2 x i32> @abs_v2i32(<2 x i32> %a){
170+
; CHECK-LABEL: abs_v2i32:
171+
; CHECK: // %bb.0: // %entry
172+
; CHECK-NEXT: abs v0.2s, v0.2s
173+
; CHECK-NEXT: ret
174+
entry:
175+
%res = call <2 x i32> @llvm.abs.v2i32(<2 x i32> %a, i1 0)
176+
ret <2 x i32> %res
177+
}
178+
declare <2 x i32> @llvm.abs.v2i32(<2 x i32>, i1)
179+
180+
define <4 x i32> @abs_v4i32(<4 x i32> %a){
181+
; CHECK-LABEL: abs_v4i32:
182+
; CHECK: // %bb.0: // %entry
183+
; CHECK-NEXT: abs v0.4s, v0.4s
184+
; CHECK-NEXT: ret
185+
entry:
186+
%res = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %a, i1 0)
187+
ret <4 x i32> %res
188+
}
189+
declare <4 x i32> @llvm.abs.v4i32(<4 x i32>, i1)
190+
191+
define <2 x i64> @abs_v2i64(<2 x i64> %a){
192+
; CHECK-LABEL: abs_v2i64:
193+
; CHECK: // %bb.0: // %entry
194+
; CHECK-NEXT: abs v0.2d, v0.2d
195+
; CHECK-NEXT: ret
196+
entry:
197+
%res = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %a, i1 0)
198+
ret <2 x i64> %res
199+
}
200+
declare <2 x i64> @llvm.abs.v2i64(<2 x i64>, i1)
201+
202+
; ===== Smaller/Larger Width Vectors with Legal Element Sizes =====
203+
204+
define <4 x i8> @abs_v4i8(<4 x i8> %a){
205+
; CHECK-LABEL: abs_v4i8:
206+
; CHECK: // %bb.0: // %entry
207+
; CHECK-NEXT: shl v0.4h, v0.4h, #8
208+
; CHECK-NEXT: sshr v0.4h, v0.4h, #8
209+
; CHECK-NEXT: abs v0.4h, v0.4h
210+
; CHECK-NEXT: ret
211+
entry:
212+
%res = call <4 x i8> @llvm.abs.v4i8(<4 x i8> %a, i1 0)
213+
ret <4 x i8> %res
214+
}
215+
declare <4 x i8> @llvm.abs.v4i8(<4 x i8>, i1)
216+
217+
define <32 x i8> @abs_v32i8(<32 x i8> %a){
218+
; CHECK-LABEL: abs_v32i8:
219+
; CHECK: // %bb.0: // %entry
220+
; CHECK-NEXT: abs v0.16b, v0.16b
221+
; CHECK-NEXT: abs v1.16b, v1.16b
222+
; CHECK-NEXT: ret
223+
entry:
224+
%res = call <32 x i8> @llvm.abs.v32i8(<32 x i8> %a, i1 0)
225+
ret <32 x i8> %res
226+
}
227+
declare <32 x i8> @llvm.abs.v32i8(<32 x i8>, i1)
228+
229+
define <2 x i16> @abs_v2i16(<2 x i16> %a){
230+
; CHECK-LABEL: abs_v2i16:
231+
; CHECK: // %bb.0: // %entry
232+
; CHECK-NEXT: shl v0.2s, v0.2s, #16
233+
; CHECK-NEXT: sshr v0.2s, v0.2s, #16
234+
; CHECK-NEXT: abs v0.2s, v0.2s
235+
; CHECK-NEXT: ret
236+
entry:
237+
%res = call <2 x i16> @llvm.abs.v2i16(<2 x i16> %a, i1 0)
238+
ret <2 x i16> %res
239+
}
240+
declare <2 x i16> @llvm.abs.v2i16(<2 x i16>, i1)
241+
242+
define <16 x i16> @abs_v16i16(<16 x i16> %a){
243+
; CHECK-LABEL: abs_v16i16:
244+
; CHECK: // %bb.0: // %entry
245+
; CHECK-NEXT: abs v0.8h, v0.8h
246+
; CHECK-NEXT: abs v1.8h, v1.8h
247+
; CHECK-NEXT: ret
248+
entry:
249+
%res = call <16 x i16> @llvm.abs.v16i16(<16 x i16> %a, i1 0)
250+
ret <16 x i16> %res
251+
}
252+
declare <16 x i16> @llvm.abs.v16i16(<16 x i16>, i1)
253+
254+
define <1 x i32> @abs_v1i32(<1 x i32> %a){
255+
; CHECK-SD-LABEL: abs_v1i32:
256+
; CHECK-SD: // %bb.0: // %entry
257+
; CHECK-SD-NEXT: abs v0.2s, v0.2s
258+
; CHECK-SD-NEXT: ret
259+
;
260+
; CHECK-GI-LABEL: abs_v1i32:
261+
; CHECK-GI: // %bb.0: // %entry
262+
; CHECK-GI-NEXT: fmov x8, d0
263+
; CHECK-GI-NEXT: asr w9, w8, #31
264+
; CHECK-GI-NEXT: add w8, w8, w9
265+
; CHECK-GI-NEXT: eor w8, w8, w9
266+
; CHECK-GI-NEXT: fmov s0, w8
267+
; CHECK-GI-NEXT: mov v0.s[1], w8
268+
; CHECK-GI-NEXT: // kill: def $d0 killed $d0 killed $q0
269+
; CHECK-GI-NEXT: ret
270+
entry:
271+
%res = call <1 x i32> @llvm.abs.v1i32(<1 x i32> %a, i1 0)
272+
ret <1 x i32> %res
273+
}
274+
declare <1 x i32> @llvm.abs.v1i32(<1 x i32>, i1)
275+
276+
define <8 x i32> @abs_v8i32(<8 x i32> %a){
277+
; CHECK-LABEL: abs_v8i32:
278+
; CHECK: // %bb.0: // %entry
279+
; CHECK-NEXT: abs v0.4s, v0.4s
280+
; CHECK-NEXT: abs v1.4s, v1.4s
281+
; CHECK-NEXT: ret
282+
entry:
283+
%res = call <8 x i32> @llvm.abs.v8i32(<8 x i32> %a, i1 0)
284+
ret <8 x i32> %res
285+
}
286+
declare <8 x i32> @llvm.abs.v8i32(<8 x i32>, i1)
287+
288+
define <4 x i64> @abs_v4i64(<4 x i64> %a){
289+
; CHECK-LABEL: abs_v4i64:
290+
; CHECK: // %bb.0: // %entry
291+
; CHECK-NEXT: abs v0.2d, v0.2d
292+
; CHECK-NEXT: abs v1.2d, v1.2d
293+
; CHECK-NEXT: ret
294+
entry:
295+
%res = call <4 x i64> @llvm.abs.v4i64(<4 x i64> %a, i1 0)
296+
ret <4 x i64> %res
297+
}
298+
declare <4 x i64> @llvm.abs.v4i64(<4 x i64>, i1)
299+
300+
; ===== Vectors with Non-Pow 2 Widths =====
301+
302+
define <3 x i8> @abs_v3i8(<3 x i8> %a){
303+
; CHECK-LABEL: abs_v3i8:
304+
; CHECK: // %bb.0: // %entry
305+
; CHECK-NEXT: fmov s0, w0
306+
; CHECK-NEXT: mov v0.h[1], w1
307+
; CHECK-NEXT: mov v0.h[2], w2
308+
; CHECK-NEXT: shl v0.4h, v0.4h, #8
309+
; CHECK-NEXT: sshr v0.4h, v0.4h, #8
310+
; CHECK-NEXT: abs v0.4h, v0.4h
311+
; CHECK-NEXT: umov w0, v0.h[0]
312+
; CHECK-NEXT: umov w1, v0.h[1]
313+
; CHECK-NEXT: umov w2, v0.h[2]
314+
; CHECK-NEXT: ret
315+
entry:
316+
%res = call <3 x i8> @llvm.abs.v3i8(<3 x i8> %a, i1 0)
317+
ret <3 x i8> %res
318+
}
319+
declare <3 x i8> @llvm.abs.v3i8(<3 x i8>, i1)
320+
321+
define <7 x i8> @abs_v7i8(<7 x i8> %a){
322+
; CHECK-LABEL: abs_v7i8:
323+
; CHECK: // %bb.0: // %entry
324+
; CHECK-NEXT: abs v0.8b, v0.8b
325+
; CHECK-NEXT: ret
326+
entry:
327+
%res = call <7 x i8> @llvm.abs.v7i8(<7 x i8> %a, i1 0)
328+
ret <7 x i8> %res
329+
}
330+
declare <7 x i8> @llvm.abs.v7i8(<7 x i8>, i1)
331+
332+
define <3 x i16> @abs_v3i16(<3 x i16> %a){
333+
; CHECK-LABEL: abs_v3i16:
334+
; CHECK: // %bb.0: // %entry
335+
; CHECK-NEXT: abs v0.4h, v0.4h
336+
; CHECK-NEXT: ret
337+
entry:
338+
%res = call <3 x i16> @llvm.abs.v3i16(<3 x i16> %a, i1 0)
339+
ret <3 x i16> %res
340+
}
341+
declare <3 x i16> @llvm.abs.v3i16(<3 x i16>, i1)
342+
343+
define <7 x i16> @abs_v7i16(<7 x i16> %a){
344+
; CHECK-LABEL: abs_v7i16:
345+
; CHECK: // %bb.0: // %entry
346+
; CHECK-NEXT: abs v0.8h, v0.8h
347+
; CHECK-NEXT: ret
348+
entry:
349+
%res = call <7 x i16> @llvm.abs.v7i16(<7 x i16> %a, i1 0)
350+
ret <7 x i16> %res
351+
}
352+
declare <7 x i16> @llvm.abs.v7i16(<7 x i16>, i1)
353+
354+
define <3 x i32> @abs_v3i32(<3 x i32> %a){
355+
; CHECK-LABEL: abs_v3i32:
356+
; CHECK: // %bb.0: // %entry
357+
; CHECK-NEXT: abs v0.4s, v0.4s
358+
; CHECK-NEXT: ret
359+
entry:
360+
%res = call <3 x i32> @llvm.abs.v3i32(<3 x i32> %a, i1 0)
361+
ret <3 x i32> %res
362+
}
363+
declare <3 x i32> @llvm.abs.v3i32(<3 x i32>, i1)

llvm/test/CodeGen/AArch64/vecreduce-add.ll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -global-isel-abort=2 %s -o - 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI,CHECK-GI-BASE
55
; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -global-isel-abort=2 %s -o - -mattr=+dotprod 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI,CHECK-GI-DOT
66

7-
; CHECK-GI-BASE: warning: Instruction selection used fallback path for full
7+
; CHECK-GI-BASE: warning: Instruction selection used fallback path for test_udot_v24i8
8+
; CHECK-GI-BASE-NEXT: warning: Instruction selection used fallback path for test_udot_v48i8
9+
; CHECK-GI-BASE-NEXT: warning: Instruction selection used fallback path for test_sdot_v24i8
10+
; CHECK-GI-BASE-NEXT: warning: Instruction selection used fallback path for test_sdot_v48i8
11+
; CHECK-GI-BASE-NEXT: warning: Instruction selection used fallback path for full
12+
13+
; CHECK-GI-DOT: warning: Instruction selection used fallback path for full
814

915
define i32 @addv_v2i32(<2 x i32> %a) {
1016
; CHECK-LABEL: addv_v2i32:

0 commit comments

Comments
 (0)