1 ; RUN: llc -aarch64-sve-vector-bits-min=128 -asm-verbose=0 < %s | FileCheck %s -check-prefix=NO_SVE
2 ; RUN: llc -aarch64-sve-vector-bits-min=256 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_EQ_256
3 ; RUN: llc -aarch64-sve-vector-bits-min=384 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK
4 ; RUN: llc -aarch64-sve-vector-bits-min=512 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512
5 ; RUN: llc -aarch64-sve-vector-bits-min=640 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512
6 ; RUN: llc -aarch64-sve-vector-bits-min=768 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512
7 ; RUN: llc -aarch64-sve-vector-bits-min=896 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512
8 ; RUN: llc -aarch64-sve-vector-bits-min=1024 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512,VBITS_GE_1024
9 ; RUN: llc -aarch64-sve-vector-bits-min=1152 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512,VBITS_GE_1024
10 ; RUN: llc -aarch64-sve-vector-bits-min=1280 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512,VBITS_GE_1024
11 ; RUN: llc -aarch64-sve-vector-bits-min=1408 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512,VBITS_GE_1024
12 ; RUN: llc -aarch64-sve-vector-bits-min=1536 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512,VBITS_GE_1024
13 ; RUN: llc -aarch64-sve-vector-bits-min=1664 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512,VBITS_GE_1024
14 ; RUN: llc -aarch64-sve-vector-bits-min=1792 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512,VBITS_GE_1024
15 ; RUN: llc -aarch64-sve-vector-bits-min=1920 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512,VBITS_GE_1024
16 ; RUN: llc -aarch64-sve-vector-bits-min=2048 -asm-verbose=0 < %s | FileCheck %s -check-prefixes=CHECK,VBITS_GE_512,VBITS_GE_1024,VBITS_GE_2048
18 target triple = "aarch64-unknown-linux-gnu"
20 ; Don't use SVE when its registers are no bigger than NEON.
27 define <8 x i8> @bitreverse_v8i8(<8 x i8> %op) #0 {
28 ; CHECK-LABEL: bitreverse_v8i8:
29 ; CHECK: ptrue [[PG:p[0-9]+]].b, vl8
30 ; CHECK-NEXT: rbit z0.b, [[PG]]/m, z0.b
32 %res = call <8 x i8> @llvm.bitreverse.v8i8(<8 x i8> %op)
36 define <16 x i8> @bitreverse_v16i8(<16 x i8> %op) #0 {
37 ; CHECK-LABEL: bitreverse_v16i8:
38 ; CHECK: ptrue [[PG:p[0-9]+]].b, vl16
39 ; CHECK-NEXT: rbit z0.b, [[PG]]/m, z0.b
41 %res = call <16 x i8> @llvm.bitreverse.v16i8(<16 x i8> %op)
45 define void @bitreverse_v32i8(<32 x i8>* %a) #0 {
46 ; CHECK-LABEL: bitreverse_v32i8:
47 ; CHECK: ptrue [[PG:p[0-9]+]].b, vl32
48 ; CHECK-NEXT: ld1b { [[OP:z[0-9]+]].b }, [[PG]]/z, [x0]
49 ; CHECK-NEXT: rbit [[RES:z[0-9]+]].b, [[PG]]/m, [[OP]].b
50 ; CHECK-NEXT: st1b { [[RES]].b }, [[PG]], [x0]
52 %op = load <32 x i8>, <32 x i8>* %a
53 %res = call <32 x i8> @llvm.bitreverse.v32i8(<32 x i8> %op)
54 store <32 x i8> %res, <32 x i8>* %a
58 define void @bitreverse_v64i8(<64 x i8>* %a) #0 {
59 ; CHECK-LABEL: bitreverse_v64i8:
60 ; VBITS_GE_512: ptrue [[PG:p[0-9]+]].b, vl64
61 ; VBITS_GE_512-NEXT: ld1b { [[OP:z[0-9]+]].b }, [[PG]]/z, [x0]
62 ; VBITS_GE_512-NEXT: rbit [[RES:z[0-9]+]].b, [[PG]]/m, [[OP]].b
63 ; VBITS_GE_512-NEXT: st1b { [[RES]].b }, [[PG]], [x0]
64 ; VBITS_GE_512-NEXT: ret
66 ; Ensure sensible type legalisation.
67 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].b, vl32
68 ; VBITS_EQ_256-DAG: mov w[[NUMELTS:[0-9]+]], #32
69 ; VBITS_EQ_256-DAG: ld1b { [[OP_LO:z[0-9]+]].b }, [[PG]]/z, [x0]
70 ; VBITS_EQ_256-DAG: ld1b { [[OP_HI:z[0-9]+]].b }, [[PG]]/z, [x0, x[[NUMELTS]]]
71 ; VBITS_EQ_256-DAG: rbit [[RES_LO:z[0-9]+]].b, [[PG]]/m, [[OP_LO]].b
72 ; VBITS_EQ_256-DAG: rbit [[RES_HI:z[0-9]+]].b, [[PG]]/m, [[OP_HI]].b
73 ; VBITS_EQ_256-DAG: st1b { [[RES_LO]].b }, [[PG]], [x0]
74 ; VBITS_EQ_256-DAG: st1b { [[RES_HI]].b }, [[PG]], [x0, x[[NUMELTS]]]
75 ; VBITS_EQ_256-NEXT: ret
76 %op = load <64 x i8>, <64 x i8>* %a
77 %res = call <64 x i8> @llvm.bitreverse.v64i8(<64 x i8> %op)
78 store <64 x i8> %res, <64 x i8>* %a
82 define void @bitreverse_v128i8(<128 x i8>* %a) #0 {
83 ; CHECK-LABEL: bitreverse_v128i8:
84 ; VBITS_GE_1024: ptrue [[PG:p[0-9]+]].b, vl128
85 ; VBITS_GE_1024-NEXT: ld1b { [[OP:z[0-9]+]].b }, [[PG]]/z, [x0]
86 ; VBITS_GE_1024-NEXT: rbit [[RES:z[0-9]+]].b, [[PG]]/m, [[OP]].b
87 ; VBITS_GE_1024-NEXT: st1b { [[RES]].b }, [[PG]], [x0]
88 ; VBITS_GE_1024-NEXT: ret
89 %op = load <128 x i8>, <128 x i8>* %a
90 %res = call <128 x i8> @llvm.bitreverse.v128i8(<128 x i8> %op)
91 store <128 x i8> %res, <128 x i8>* %a
95 define void @bitreverse_v256i8(<256 x i8>* %a) #0 {
96 ; CHECK-LABEL: bitreverse_v256i8:
97 ; VBITS_GE_2048: ptrue [[PG:p[0-9]+]].b, vl256
98 ; VBITS_GE_2048-NEXT: ld1b { [[OP:z[0-9]+]].b }, [[PG]]/z, [x0]
99 ; VBITS_GE_2048-NEXT: rbit [[RES:z[0-9]+]].b, [[PG]]/m, [[OP]].b
100 ; VBITS_GE_2048-NEXT: st1b { [[RES]].b }, [[PG]], [x0]
101 ; VBITS_GE_2048-NEXT: ret
102 %op = load <256 x i8>, <256 x i8>* %a
103 %res = call <256 x i8> @llvm.bitreverse.v256i8(<256 x i8> %op)
104 store <256 x i8> %res, <256 x i8>* %a
108 define <4 x i16> @bitreverse_v4i16(<4 x i16> %op) #0 {
109 ; CHECK-LABEL: bitreverse_v4i16:
110 ; CHECK: ptrue [[PG:p[0-9]+]].h, vl4
111 ; CHECK-NEXT: rbit z0.h, [[PG]]/m, z0.h
113 %res = call <4 x i16> @llvm.bitreverse.v4i16(<4 x i16> %op)
117 define <8 x i16> @bitreverse_v8i16(<8 x i16> %op) #0 {
118 ; CHECK-LABEL: bitreverse_v8i16:
119 ; CHECK: ptrue [[PG:p[0-9]+]].h, vl8
120 ; CHECK-NEXT: rbit z0.h, [[PG]]/m, z0.h
122 %res = call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> %op)
126 define void @bitreverse_v16i16(<16 x i16>* %a) #0 {
127 ; CHECK-LABEL: bitreverse_v16i16:
128 ; CHECK: ptrue [[PG:p[0-9]+]].h, vl16
129 ; CHECK-NEXT: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
130 ; CHECK-NEXT: rbit [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
131 ; CHECK-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
133 %op = load <16 x i16>, <16 x i16>* %a
134 %res = call <16 x i16> @llvm.bitreverse.v16i16(<16 x i16> %op)
135 store <16 x i16> %res, <16 x i16>* %a
139 define void @bitreverse_v32i16(<32 x i16>* %a) #0 {
140 ; CHECK-LABEL: bitreverse_v32i16:
141 ; VBITS_GE_512: ptrue [[PG:p[0-9]+]].h, vl32
142 ; VBITS_GE_512-NEXT: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
143 ; VBITS_GE_512-NEXT: rbit [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
144 ; VBITS_GE_512-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
145 ; VBITS_GE_512-NEXT: ret
147 ; Ensure sensible type legalisation.
148 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].h, vl16
149 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #16
150 ; VBITS_EQ_256-DAG: ld1h { [[OP_LO:z[0-9]+]].h }, [[PG]]/z, [x0]
151 ; VBITS_EQ_256-DAG: ld1h { [[OP_HI:z[0-9]+]].h }, [[PG]]/z, [x0, x[[NUMELTS]], lsl #1]
152 ; VBITS_EQ_256-DAG: rbit [[RES_LO:z[0-9]+]].h, [[PG]]/m, [[OP_LO]].h
153 ; VBITS_EQ_256-DAG: rbit [[RES_HI:z[0-9]+]].h, [[PG]]/m, [[OP_HI]].h
154 ; VBITS_EQ_256-DAG: st1h { [[RES_LO]].h }, [[PG]], [x0]
155 ; VBITS_EQ_256-DAG: st1h { [[RES_HI]].h }, [[PG]], [x0, x[[NUMELTS]], lsl #1]
156 ; VBITS_EQ_256-NEXT: ret
157 %op = load <32 x i16>, <32 x i16>* %a
158 %res = call <32 x i16> @llvm.bitreverse.v32i16(<32 x i16> %op)
159 store <32 x i16> %res, <32 x i16>* %a
163 define void @bitreverse_v64i16(<64 x i16>* %a) #0 {
164 ; CHECK-LABEL: bitreverse_v64i16:
165 ; VBITS_GE_1024: ptrue [[PG:p[0-9]+]].h, vl64
166 ; VBITS_GE_1024-NEXT: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
167 ; VBITS_GE_1024-NEXT: rbit [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
168 ; VBITS_GE_1024-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
169 ; VBITS_GE_1024-NEXT: ret
170 %op = load <64 x i16>, <64 x i16>* %a
171 %res = call <64 x i16> @llvm.bitreverse.v64i16(<64 x i16> %op)
172 store <64 x i16> %res, <64 x i16>* %a
176 define void @bitreverse_v128i16(<128 x i16>* %a) #0 {
177 ; CHECK-LABEL: bitreverse_v128i16:
178 ; VBITS_GE_2048: ptrue [[PG:p[0-9]+]].h, vl128
179 ; VBITS_GE_2048-NEXT: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
180 ; VBITS_GE_2048-NEXT: rbit [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
181 ; VBITS_GE_2048-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
182 ; VBITS_GE_2048-NEXT: ret
183 %op = load <128 x i16>, <128 x i16>* %a
184 %res = call <128 x i16> @llvm.bitreverse.v128i16(<128 x i16> %op)
185 store <128 x i16> %res, <128 x i16>* %a
189 define <2 x i32> @bitreverse_v2i32(<2 x i32> %op) #0 {
190 ; CHECK-LABEL: bitreverse_v2i32:
191 ; CHECK: ptrue [[PG:p[0-9]+]].s, vl2
192 ; CHECK-NEXT: rbit z0.s, [[PG]]/m, z0.s
194 %res = call <2 x i32> @llvm.bitreverse.v2i32(<2 x i32> %op)
198 define <4 x i32> @bitreverse_v4i32(<4 x i32> %op) #0 {
199 ; CHECK-LABEL: bitreverse_v4i32:
200 ; CHECK: ptrue [[PG:p[0-9]+]].s, vl4
201 ; CHECK-NEXT: rbit z0.s, [[PG]]/m, z0.s
203 %res = call <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> %op)
207 define void @bitreverse_v8i32(<8 x i32>* %a) #0 {
208 ; CHECK-LABEL: bitreverse_v8i32:
209 ; CHECK: ptrue [[PG:p[0-9]+]].s, vl8
210 ; CHECK-NEXT: ld1w { [[OP:z[0-9]+]].s }, [[PG]]/z, [x0]
211 ; CHECK-NEXT: rbit [[RES:z[0-9]+]].s, [[PG]]/m, [[OP]].s
212 ; CHECK-NEXT: st1w { [[RES]].s }, [[PG]], [x0]
214 %op = load <8 x i32>, <8 x i32>* %a
215 %res = call <8 x i32> @llvm.bitreverse.v8i32(<8 x i32> %op)
216 store <8 x i32> %res, <8 x i32>* %a
220 define void @bitreverse_v16i32(<16 x i32>* %a) #0 {
221 ; CHECK-LABEL: bitreverse_v16i32:
222 ; VBITS_GE_512: ptrue [[PG:p[0-9]+]].s, vl16
223 ; VBITS_GE_512-NEXT: ld1w { [[OP:z[0-9]+]].s }, [[PG]]/z, [x0]
224 ; VBITS_GE_512-NEXT: rbit [[RES:z[0-9]+]].s, [[PG]]/m, [[OP]].s
225 ; VBITS_GE_512-NEXT: st1w { [[RES]].s }, [[PG]], [x0]
226 ; VBITS_GE_512-NEXT: ret
228 ; Ensure sensible type legalisation.
229 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].s, vl8
230 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #8
231 ; VBITS_EQ_256-DAG: ld1w { [[OP_LO:z[0-9]+]].s }, [[PG]]/z, [x0]
232 ; VBITS_EQ_256-DAG: ld1w { [[OP_HI:z[0-9]+]].s }, [[PG]]/z, [x0, x[[NUMELTS]], lsl #2]
233 ; VBITS_EQ_256-DAG: rbit [[RES_LO:z[0-9]+]].s, [[PG]]/m, [[OP_LO]].s
234 ; VBITS_EQ_256-DAG: rbit [[RES_HI:z[0-9]+]].s, [[PG]]/m, [[OP_HI]].s
235 ; VBITS_EQ_256-DAG: st1w { [[RES_LO]].s }, [[PG]], [x0]
236 ; VBITS_EQ_256-DAG: st1w { [[RES_HI]].s }, [[PG]], [x0, x[[NUMELTS]], lsl #2]
237 ; VBITS_EQ_256-NEXT: ret
238 %op = load <16 x i32>, <16 x i32>* %a
239 %res = call <16 x i32> @llvm.bitreverse.v16i32(<16 x i32> %op)
240 store <16 x i32> %res, <16 x i32>* %a
244 define void @bitreverse_v32i32(<32 x i32>* %a) #0 {
245 ; CHECK-LABEL: bitreverse_v32i32:
246 ; VBITS_GE_1024: ptrue [[PG:p[0-9]+]].s, vl32
247 ; VBITS_GE_1024-NEXT: ld1w { [[OP:z[0-9]+]].s }, [[PG]]/z, [x0]
248 ; VBITS_GE_1024-NEXT: rbit [[RES:z[0-9]+]].s, [[PG]]/m, [[OP]].s
249 ; VBITS_GE_1024-NEXT: st1w { [[RES]].s }, [[PG]], [x0]
250 ; VBITS_GE_1024-NEXT: ret
251 %op = load <32 x i32>, <32 x i32>* %a
252 %res = call <32 x i32> @llvm.bitreverse.v32i32(<32 x i32> %op)
253 store <32 x i32> %res, <32 x i32>* %a
257 define void @bitreverse_v64i32(<64 x i32>* %a) #0 {
258 ; CHECK-LABEL: bitreverse_v64i32:
259 ; VBITS_GE_2048: ptrue [[PG:p[0-9]+]].s, vl64
260 ; VBITS_GE_2048-NEXT: ld1w { [[OP:z[0-9]+]].s }, [[PG]]/z, [x0]
261 ; VBITS_GE_2048-NEXT: rbit [[RES:z[0-9]+]].s, [[PG]]/m, [[OP]].s
262 ; VBITS_GE_2048-NEXT: st1w { [[RES]].s }, [[PG]], [x0]
263 ; VBITS_GE_2048-NEXT: ret
264 %op = load <64 x i32>, <64 x i32>* %a
265 %res = call <64 x i32> @llvm.bitreverse.v64i32(<64 x i32> %op)
266 store <64 x i32> %res, <64 x i32>* %a
270 define <1 x i64> @bitreverse_v1i64(<1 x i64> %op) #0 {
271 ; CHECK-LABEL: bitreverse_v1i64:
272 ; CHECK: ptrue [[PG:p[0-9]+]].d, vl1
273 ; CHECK-NEXT: rbit z0.d, [[PG]]/m, z0.d
275 %res = call <1 x i64> @llvm.bitreverse.v1i64(<1 x i64> %op)
279 define <2 x i64> @bitreverse_v2i64(<2 x i64> %op) #0 {
280 ; CHECK-LABEL: bitreverse_v2i64:
281 ; CHECK: ptrue [[PG:p[0-9]+]].d, vl2
282 ; CHECK-NEXT: rbit z0.d, [[PG]]/m, z0.d
284 %res = call <2 x i64> @llvm.bitreverse.v2i64(<2 x i64> %op)
288 define void @bitreverse_v4i64(<4 x i64>* %a) #0 {
289 ; CHECK-LABEL: bitreverse_v4i64:
290 ; CHECK: ptrue [[PG:p[0-9]+]].d, vl4
291 ; CHECK-NEXT: ld1d { [[OP:z[0-9]+]].d }, [[PG]]/z, [x0]
292 ; CHECK-NEXT: rbit [[RES:z[0-9]+]].d, [[PG]]/m, [[OP]].d
293 ; CHECK-NEXT: st1d { [[RES]].d }, [[PG]], [x0]
295 %op = load <4 x i64>, <4 x i64>* %a
296 %res = call <4 x i64> @llvm.bitreverse.v4i64(<4 x i64> %op)
297 store <4 x i64> %res, <4 x i64>* %a
301 define void @bitreverse_v8i64(<8 x i64>* %a) #0 {
302 ; CHECK-LABEL: bitreverse_v8i64:
303 ; VBITS_GE_512: ptrue [[PG:p[0-9]+]].d, vl8
304 ; VBITS_GE_512-NEXT: ld1d { [[OP:z[0-9]+]].d }, [[PG]]/z, [x0]
305 ; VBITS_GE_512-NEXT: rbit [[RES:z[0-9]+]].d, [[PG]]/m, [[OP]].d
306 ; VBITS_GE_512-NEXT: st1d { [[RES]].d }, [[PG]], [x0]
307 ; VBITS_GE_512-NEXT: ret
309 ; Ensure sensible type legalisation.
310 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].d, vl4
311 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #4
312 ; VBITS_EQ_256-DAG: ld1d { [[OP_LO:z[0-9]+]].d }, [[PG]]/z, [x0]
313 ; VBITS_EQ_256-DAG: ld1d { [[OP_HI:z[0-9]+]].d }, [[PG]]/z, [x0, x[[NUMELTS]], lsl #3]
314 ; VBITS_EQ_256-DAG: rbit [[RES_LO:z[0-9]+]].d, [[PG]]/m, [[OP_LO]].d
315 ; VBITS_EQ_256-DAG: rbit [[RES_HI:z[0-9]+]].d, [[PG]]/m, [[OP_HI]].d
316 ; VBITS_EQ_256-DAG: st1d { [[RES_LO]].d }, [[PG]], [x0]
317 ; VBITS_EQ_256-DAG: st1d { [[RES_HI]].d }, [[PG]], [x0, x[[NUMELTS]], lsl #3]
318 ; VBITS_EQ_256-NEXT: ret
319 %op = load <8 x i64>, <8 x i64>* %a
320 %res = call <8 x i64> @llvm.bitreverse.v8i64(<8 x i64> %op)
321 store <8 x i64> %res, <8 x i64>* %a
325 define void @bitreverse_v16i64(<16 x i64>* %a) #0 {
326 ; CHECK-LABEL: bitreverse_v16i64:
327 ; VBITS_GE_1024: ptrue [[PG:p[0-9]+]].d, vl16
328 ; VBITS_GE_1024-NEXT: ld1d { [[OP:z[0-9]+]].d }, [[PG]]/z, [x0]
329 ; VBITS_GE_1024-NEXT: rbit [[RES:z[0-9]+]].d, [[PG]]/m, [[OP]].d
330 ; VBITS_GE_1024-NEXT: st1d { [[RES]].d }, [[PG]], [x0]
331 ; VBITS_GE_1024-NEXT: ret
332 %op = load <16 x i64>, <16 x i64>* %a
333 %res = call <16 x i64> @llvm.bitreverse.v16i64(<16 x i64> %op)
334 store <16 x i64> %res, <16 x i64>* %a
338 define void @bitreverse_v32i64(<32 x i64>* %a) #0 {
339 ; CHECK-LABEL: bitreverse_v32i64:
340 ; VBITS_GE_2048: ptrue [[PG:p[0-9]+]].d, vl32
341 ; VBITS_GE_2048-NEXT: ld1d { [[OP:z[0-9]+]].d }, [[PG]]/z, [x0]
342 ; VBITS_GE_2048-NEXT: rbit [[RES:z[0-9]+]].d, [[PG]]/m, [[OP]].d
343 ; VBITS_GE_2048-NEXT: st1d { [[RES]].d }, [[PG]], [x0]
344 ; VBITS_GE_2048-NEXT: ret
345 %op = load <32 x i64>, <32 x i64>* %a
346 %res = call <32 x i64> @llvm.bitreverse.v32i64(<32 x i64> %op)
347 store <32 x i64> %res, <32 x i64>* %a
355 ; Don't use SVE for 64-bit vectors.
356 define <4 x i16> @bswap_v4i16(<4 x i16> %op) #0 {
357 ; CHECK-LABEL: bswap_v4i16:
358 ; CHECK: rev16 v0.8b, v0.8b
360 %res = call <4 x i16> @llvm.bswap.v4i16(<4 x i16> %op)
364 ; Don't use SVE for 128-bit vectors.
365 define <8 x i16> @bswap_v8i16(<8 x i16> %op) #0 {
366 ; CHECK-LABEL: bswap_v8i16:
367 ; CHECK: rev16 v0.16b, v0.16b
369 %res = call <8 x i16> @llvm.bswap.v8i16(<8 x i16> %op)
373 define void @bswap_v16i16(<16 x i16>* %a) #0 {
374 ; CHECK-LABEL: bswap_v16i16:
375 ; CHECK: ptrue [[PG:p[0-9]+]].h, vl16
376 ; CHECK-NEXT: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
377 ; CHECK-NEXT: revb [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
378 ; CHECK-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
380 %op = load <16 x i16>, <16 x i16>* %a
381 %res = call <16 x i16> @llvm.bswap.v16i16(<16 x i16> %op)
382 store <16 x i16> %res, <16 x i16>* %a
386 define void @bswap_v32i16(<32 x i16>* %a) #0 {
387 ; CHECK-LABEL: bswap_v32i16:
388 ; VBITS_GE_512: ptrue [[PG:p[0-9]+]].h, vl32
389 ; VBITS_GE_512-NEXT: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
390 ; VBITS_GE_512-NEXT: revb [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
391 ; VBITS_GE_512-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
392 ; VBITS_GE_512-NEXT: ret
394 ; Ensure sensible type legalisation.
395 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].h, vl16
396 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #16
397 ; VBITS_EQ_256-DAG: ld1h { [[OP_LO:z[0-9]+]].h }, [[PG]]/z, [x0]
398 ; VBITS_EQ_256-DAG: ld1h { [[OP_HI:z[0-9]+]].h }, [[PG]]/z, [x0, x[[NUMELTS]], lsl #1]
399 ; VBITS_EQ_256-DAG: revb [[RES_LO:z[0-9]+]].h, [[PG]]/m, [[OP_LO]].h
400 ; VBITS_EQ_256-DAG: revb [[RES_HI:z[0-9]+]].h, [[PG]]/m, [[OP_HI]].h
401 ; VBITS_EQ_256-DAG: st1h { [[RES_LO]].h }, [[PG]], [x0]
402 ; VBITS_EQ_256-DAG: st1h { [[RES_HI]].h }, [[PG]], [x0, x[[NUMELTS]], lsl #1]
403 ; VBITS_EQ_256-NEXT: ret
404 %op = load <32 x i16>, <32 x i16>* %a
405 %res = call <32 x i16> @llvm.bswap.v32i16(<32 x i16> %op)
406 store <32 x i16> %res, <32 x i16>* %a
410 define void @bswap_v64i16(<64 x i16>* %a) #0 {
411 ; CHECK-LABEL: bswap_v64i16:
412 ; VBITS_GE_1024: ptrue [[PG:p[0-9]+]].h, vl64
413 ; VBITS_GE_1024-NEXT: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
414 ; VBITS_GE_1024-NEXT: revb [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
415 ; VBITS_GE_1024-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
416 ; VBITS_GE_1024-NEXT: ret
417 %op = load <64 x i16>, <64 x i16>* %a
418 %res = call <64 x i16> @llvm.bswap.v64i16(<64 x i16> %op)
419 store <64 x i16> %res, <64 x i16>* %a
423 define void @bswap_v128i16(<128 x i16>* %a) #0 {
424 ; CHECK-LABEL: bswap_v128i16:
425 ; VBITS_GE_2048: ptrue [[PG:p[0-9]+]].h, vl128
426 ; VBITS_GE_2048-NEXT: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
427 ; VBITS_GE_2048-NEXT: revb [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
428 ; VBITS_GE_2048-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
429 ; VBITS_GE_2048-NEXT: ret
430 %op = load <128 x i16>, <128 x i16>* %a
431 %res = call <128 x i16> @llvm.bswap.v128i16(<128 x i16> %op)
432 store <128 x i16> %res, <128 x i16>* %a
436 ; Don't use SVE for 64-bit vectors.
437 define <2 x i32> @bswap_v2i32(<2 x i32> %op) #0 {
438 ; CHECK-LABEL: bswap_v2i32:
439 ; CHECK: rev32 v0.8b, v0.8b
441 %res = call <2 x i32> @llvm.bswap.v2i32(<2 x i32> %op)
445 ; Don't use SVE for 128-bit vectors.
446 define <4 x i32> @bswap_v4i32(<4 x i32> %op) #0 {
447 ; CHECK-LABEL: bswap_v4i32:
448 ; CHECK: rev32 v0.16b, v0.16b
450 %res = call <4 x i32> @llvm.bswap.v4i32(<4 x i32> %op)
454 define void @bswap_v8i32(<8 x i32>* %a) #0 {
455 ; CHECK-LABEL: bswap_v8i32:
456 ; CHECK: ptrue [[PG:p[0-9]+]].s, vl8
457 ; CHECK-NEXT: ld1w { [[OP:z[0-9]+]].s }, [[PG]]/z, [x0]
458 ; CHECK-NEXT: revb [[RES:z[0-9]+]].s, [[PG]]/m, [[OP]].s
459 ; CHECK-NEXT: st1w { [[RES]].s }, [[PG]], [x0]
461 %op = load <8 x i32>, <8 x i32>* %a
462 %res = call <8 x i32> @llvm.bswap.v8i32(<8 x i32> %op)
463 store <8 x i32> %res, <8 x i32>* %a
467 define void @bswap_v16i32(<16 x i32>* %a) #0 {
468 ; CHECK-LABEL: bswap_v16i32:
469 ; VBITS_GE_512: ptrue [[PG:p[0-9]+]].s, vl16
470 ; VBITS_GE_512-NEXT: ld1w { [[OP:z[0-9]+]].s }, [[PG]]/z, [x0]
471 ; VBITS_GE_512-NEXT: revb [[RES:z[0-9]+]].s, [[PG]]/m, [[OP]].s
472 ; VBITS_GE_512-NEXT: st1w { [[RES]].s }, [[PG]], [x0]
473 ; VBITS_GE_512-NEXT: ret
475 ; Ensure sensible type legalisation.
476 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].s, vl8
477 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #8
478 ; VBITS_EQ_256-DAG: ld1w { [[OP_LO:z[0-9]+]].s }, [[PG]]/z, [x0]
479 ; VBITS_EQ_256-DAG: ld1w { [[OP_HI:z[0-9]+]].s }, [[PG]]/z, [x0, x[[NUMELTS]], lsl #2]
480 ; VBITS_EQ_256-DAG: revb [[RES_LO:z[0-9]+]].s, [[PG]]/m, [[OP_LO]].s
481 ; VBITS_EQ_256-DAG: revb [[RES_HI:z[0-9]+]].s, [[PG]]/m, [[OP_HI]].s
482 ; VBITS_EQ_256-DAG: st1w { [[RES_LO]].s }, [[PG]], [x0]
483 ; VBITS_EQ_256-DAG: st1w { [[RES_HI]].s }, [[PG]], [x0, x[[NUMELTS]], lsl #2]
484 ; VBITS_EQ_256-NEXT: ret
485 %op = load <16 x i32>, <16 x i32>* %a
486 %res = call <16 x i32> @llvm.bswap.v16i32(<16 x i32> %op)
487 store <16 x i32> %res, <16 x i32>* %a
491 define void @bswap_v32i32(<32 x i32>* %a) #0 {
492 ; CHECK-LABEL: bswap_v32i32:
493 ; VBITS_GE_1024: ptrue [[PG:p[0-9]+]].s, vl32
494 ; VBITS_GE_1024-NEXT: ld1w { [[OP:z[0-9]+]].s }, [[PG]]/z, [x0]
495 ; VBITS_GE_1024-NEXT: revb [[RES:z[0-9]+]].s, [[PG]]/m, [[OP]].s
496 ; VBITS_GE_1024-NEXT: st1w { [[RES]].s }, [[PG]], [x0]
497 ; VBITS_GE_1024-NEXT: ret
498 %op = load <32 x i32>, <32 x i32>* %a
499 %res = call <32 x i32> @llvm.bswap.v32i32(<32 x i32> %op)
500 store <32 x i32> %res, <32 x i32>* %a
504 define void @bswap_v64i32(<64 x i32>* %a) #0 {
505 ; CHECK-LABEL: bswap_v64i32:
506 ; VBITS_GE_2048: ptrue [[PG:p[0-9]+]].s, vl64
507 ; VBITS_GE_2048-NEXT: ld1w { [[OP:z[0-9]+]].s }, [[PG]]/z, [x0]
508 ; VBITS_GE_2048-NEXT: revb [[RES:z[0-9]+]].s, [[PG]]/m, [[OP]].s
509 ; VBITS_GE_2048-NEXT: st1w { [[RES]].s }, [[PG]], [x0]
510 ; VBITS_GE_2048-NEXT: ret
511 %op = load <64 x i32>, <64 x i32>* %a
512 %res = call <64 x i32> @llvm.bswap.v64i32(<64 x i32> %op)
513 store <64 x i32> %res, <64 x i32>* %a
517 ; Don't use SVE for 64-bit vectors.
518 define <1 x i64> @bswap_v1i64(<1 x i64> %op) #0 {
519 ; CHECK-LABEL: bswap_v1i64:
520 ; CHECK: rev64 v0.8b, v0.8b
522 %res = call <1 x i64> @llvm.bswap.v1i64(<1 x i64> %op)
526 ; Don't use SVE for 128-bit vectors.
527 define <2 x i64> @bswap_v2i64(<2 x i64> %op) #0 {
528 ; CHECK-LABEL: bswap_v2i64:
529 ; CHECK: rev64 v0.16b, v0.16b
531 %res = call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %op)
535 define void @bswap_v4i64(<4 x i64>* %a) #0 {
536 ; CHECK-LABEL: bswap_v4i64:
537 ; CHECK: ptrue [[PG:p[0-9]+]].d, vl4
538 ; CHECK-NEXT: ld1d { [[OP:z[0-9]+]].d }, [[PG]]/z, [x0]
539 ; CHECK-NEXT: revb [[RES:z[0-9]+]].d, [[PG]]/m, [[OP]].d
540 ; CHECK-NEXT: st1d { [[RES]].d }, [[PG]], [x0]
542 %op = load <4 x i64>, <4 x i64>* %a
543 %res = call <4 x i64> @llvm.bswap.v4i64(<4 x i64> %op)
544 store <4 x i64> %res, <4 x i64>* %a
548 define void @bswap_v8i64(<8 x i64>* %a) #0 {
549 ; CHECK-LABEL: bswap_v8i64:
550 ; VBITS_GE_512: ptrue [[PG:p[0-9]+]].d, vl8
551 ; VBITS_GE_512-NEXT: ld1d { [[OP:z[0-9]+]].d }, [[PG]]/z, [x0]
552 ; VBITS_GE_512-NEXT: revb [[RES:z[0-9]+]].d, [[PG]]/m, [[OP]].d
553 ; VBITS_GE_512-NEXT: st1d { [[RES]].d }, [[PG]], [x0]
554 ; VBITS_GE_512-NEXT: ret
556 ; Ensure sensible type legalisation.
557 ; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].d, vl4
558 ; VBITS_EQ_256-DAG: mov x[[NUMELTS:[0-9]+]], #4
559 ; VBITS_EQ_256-DAG: ld1d { [[OP_LO:z[0-9]+]].d }, [[PG]]/z, [x0]
560 ; VBITS_EQ_256-DAG: ld1d { [[OP_HI:z[0-9]+]].d }, [[PG]]/z, [x0, x[[NUMELTS]], lsl #3]
561 ; VBITS_EQ_256-DAG: revb [[RES_LO:z[0-9]+]].d, [[PG]]/m, [[OP_LO]].d
562 ; VBITS_EQ_256-DAG: revb [[RES_HI:z[0-9]+]].d, [[PG]]/m, [[OP_HI]].d
563 ; VBITS_EQ_256-DAG: st1d { [[RES_LO]].d }, [[PG]], [x0]
564 ; VBITS_EQ_256-DAG: st1d { [[RES_HI]].d }, [[PG]], [x0, x[[NUMELTS]], lsl #3]
565 ; VBITS_EQ_256-NEXT: ret
566 %op = load <8 x i64>, <8 x i64>* %a
567 %res = call <8 x i64> @llvm.bswap.v8i64(<8 x i64> %op)
568 store <8 x i64> %res, <8 x i64>* %a
572 define void @bswap_v16i64(<16 x i64>* %a) #0 {
573 ; CHECK-LABEL: bswap_v16i64:
574 ; VBITS_GE_1024: ptrue [[PG:p[0-9]+]].d, vl16
575 ; VBITS_GE_1024-NEXT: ld1d { [[OP:z[0-9]+]].d }, [[PG]]/z, [x0]
576 ; VBITS_GE_1024-NEXT: revb [[RES:z[0-9]+]].d, [[PG]]/m, [[OP]].d
577 ; VBITS_GE_1024-NEXT: st1d { [[RES]].d }, [[PG]], [x0]
578 ; VBITS_GE_1024-NEXT: ret
579 %op = load <16 x i64>, <16 x i64>* %a
580 %res = call <16 x i64> @llvm.bswap.v16i64(<16 x i64> %op)
581 store <16 x i64> %res, <16 x i64>* %a
585 define void @bswap_v32i64(<32 x i64>* %a) #0 {
586 ; CHECK-LABEL: bswap_v32i64:
587 ; VBITS_GE_2048: ptrue [[PG:p[0-9]+]].d, vl32
588 ; VBITS_GE_2048-NEXT: ld1d { [[OP:z[0-9]+]].d }, [[PG]]/z, [x0]
589 ; VBITS_GE_2048-NEXT: revb [[RES:z[0-9]+]].d, [[PG]]/m, [[OP]].d
590 ; VBITS_GE_2048-NEXT: st1d { [[RES]].d }, [[PG]], [x0]
591 ; VBITS_GE_2048-NEXT: ret
592 %op = load <32 x i64>, <32 x i64>* %a
593 %res = call <32 x i64> @llvm.bswap.v32i64(<32 x i64> %op)
594 store <32 x i64> %res, <32 x i64>* %a
598 attributes #0 = { "target-features"="+sve" }
600 declare <8 x i8> @llvm.bitreverse.v8i8(<8 x i8>)
601 declare <16 x i8> @llvm.bitreverse.v16i8(<16 x i8>)
602 declare <32 x i8> @llvm.bitreverse.v32i8(<32 x i8>)
603 declare <64 x i8> @llvm.bitreverse.v64i8(<64 x i8>)
604 declare <128 x i8> @llvm.bitreverse.v128i8(<128 x i8>)
605 declare <256 x i8> @llvm.bitreverse.v256i8(<256 x i8>)
606 declare <4 x i16> @llvm.bitreverse.v4i16(<4 x i16>)
607 declare <8 x i16> @llvm.bitreverse.v8i16(<8 x i16>)
608 declare <16 x i16> @llvm.bitreverse.v16i16(<16 x i16>)
609 declare <32 x i16> @llvm.bitreverse.v32i16(<32 x i16>)
610 declare <64 x i16> @llvm.bitreverse.v64i16(<64 x i16>)
611 declare <128 x i16> @llvm.bitreverse.v128i16(<128 x i16>)
612 declare <2 x i32> @llvm.bitreverse.v2i32(<2 x i32>)
613 declare <4 x i32> @llvm.bitreverse.v4i32(<4 x i32>)
614 declare <8 x i32> @llvm.bitreverse.v8i32(<8 x i32>)
615 declare <16 x i32> @llvm.bitreverse.v16i32(<16 x i32>)
616 declare <32 x i32> @llvm.bitreverse.v32i32(<32 x i32>)
617 declare <64 x i32> @llvm.bitreverse.v64i32(<64 x i32>)
618 declare <1 x i64> @llvm.bitreverse.v1i64(<1 x i64>)
619 declare <2 x i64> @llvm.bitreverse.v2i64(<2 x i64>)
620 declare <4 x i64> @llvm.bitreverse.v4i64(<4 x i64>)
621 declare <8 x i64> @llvm.bitreverse.v8i64(<8 x i64>)
622 declare <16 x i64> @llvm.bitreverse.v16i64(<16 x i64>)
623 declare <32 x i64> @llvm.bitreverse.v32i64(<32 x i64>)
625 declare <4 x i16> @llvm.bswap.v4i16(<4 x i16>)
626 declare <8 x i16> @llvm.bswap.v8i16(<8 x i16>)
627 declare <16 x i16> @llvm.bswap.v16i16(<16 x i16>)
628 declare <32 x i16> @llvm.bswap.v32i16(<32 x i16>)
629 declare <64 x i16> @llvm.bswap.v64i16(<64 x i16>)
630 declare <128 x i16> @llvm.bswap.v128i16(<128 x i16>)
631 declare <2 x i32> @llvm.bswap.v2i32(<2 x i32>)
632 declare <4 x i32> @llvm.bswap.v4i32(<4 x i32>)
633 declare <8 x i32> @llvm.bswap.v8i32(<8 x i32>)
634 declare <16 x i32> @llvm.bswap.v16i32(<16 x i32>)
635 declare <32 x i32> @llvm.bswap.v32i32(<32 x i32>)
636 declare <64 x i32> @llvm.bswap.v64i32(<64 x i32>)
637 declare <1 x i64> @llvm.bswap.v1i64(<1 x i64>)
638 declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
639 declare <4 x i64> @llvm.bswap.v4i64(<4 x i64>)
640 declare <8 x i64> @llvm.bswap.v8i64(<8 x i64>)
641 declare <16 x i64> @llvm.bswap.v16i64(<16 x i64>)
642 declare <32 x i64> @llvm.bswap.v32i64(<32 x i64>)