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
3 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -mattr=+use-scalar-inc-vl < %s | FileCheck %s -check-prefix=USE_SCALAR_INC
4 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s -check-prefix=USE_SCALAR_INC
5 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sme < %s | FileCheck %s -check-prefix=USE_SCALAR_INC
14 ; CHECK-NEXT: cntb x0, vl2
17 ; USE_SCALAR_INC-LABEL: cntb:
18 ; USE_SCALAR_INC: // %bb.0:
19 ; USE_SCALAR_INC-NEXT: cntb x0, vl2
20 ; USE_SCALAR_INC-NEXT: ret
21 %out = call i64 @llvm.aarch64.sve.cntb(i32 2)
25 define i64 @cntb_mul3() {
26 ; CHECK-LABEL: cntb_mul3:
28 ; CHECK-NEXT: cntb x0, vl6, mul #3
31 ; USE_SCALAR_INC-LABEL: cntb_mul3:
32 ; USE_SCALAR_INC: // %bb.0:
33 ; USE_SCALAR_INC-NEXT: cntb x0, vl6, mul #3
34 ; USE_SCALAR_INC-NEXT: ret
35 %cnt = call i64 @llvm.aarch64.sve.cntb(i32 6)
36 %out = mul i64 %cnt, 3
40 define i64 @cntb_mul4() {
41 ; CHECK-LABEL: cntb_mul4:
43 ; CHECK-NEXT: cntb x0, vl8, mul #4
46 ; USE_SCALAR_INC-LABEL: cntb_mul4:
47 ; USE_SCALAR_INC: // %bb.0:
48 ; USE_SCALAR_INC-NEXT: cntb x0, vl8, mul #4
49 ; USE_SCALAR_INC-NEXT: ret
50 %cnt = call i64 @llvm.aarch64.sve.cntb(i32 8)
51 %out = mul i64 %cnt, 4
62 ; CHECK-NEXT: cnth x0, vl3
65 ; USE_SCALAR_INC-LABEL: cnth:
66 ; USE_SCALAR_INC: // %bb.0:
67 ; USE_SCALAR_INC-NEXT: cnth x0, vl3
68 ; USE_SCALAR_INC-NEXT: ret
69 %out = call i64 @llvm.aarch64.sve.cnth(i32 3)
73 define i64 @cnth_mul5() {
74 ; CHECK-LABEL: cnth_mul5:
76 ; CHECK-NEXT: cnth x0, vl7, mul #5
79 ; USE_SCALAR_INC-LABEL: cnth_mul5:
80 ; USE_SCALAR_INC: // %bb.0:
81 ; USE_SCALAR_INC-NEXT: cnth x0, vl7, mul #5
82 ; USE_SCALAR_INC-NEXT: ret
83 %cnt = call i64 @llvm.aarch64.sve.cnth(i32 7)
84 %out = mul i64 %cnt, 5
88 define i64 @cnth_mul8() {
89 ; CHECK-LABEL: cnth_mul8:
91 ; CHECK-NEXT: cnth x0, vl5, mul #8
94 ; USE_SCALAR_INC-LABEL: cnth_mul8:
95 ; USE_SCALAR_INC: // %bb.0:
96 ; USE_SCALAR_INC-NEXT: cnth x0, vl5, mul #8
97 ; USE_SCALAR_INC-NEXT: ret
98 %cnt = call i64 @llvm.aarch64.sve.cnth(i32 5)
99 %out = mul i64 %cnt, 8
110 ; CHECK-NEXT: cntw x0, vl4
113 ; USE_SCALAR_INC-LABEL: cntw:
114 ; USE_SCALAR_INC: // %bb.0:
115 ; USE_SCALAR_INC-NEXT: cntw x0, vl4
116 ; USE_SCALAR_INC-NEXT: ret
117 %out = call i64 @llvm.aarch64.sve.cntw(i32 4)
121 define i64 @cntw_mul11() {
122 ; CHECK-LABEL: cntw_mul11:
124 ; CHECK-NEXT: cntw x0, vl8, mul #11
127 ; USE_SCALAR_INC-LABEL: cntw_mul11:
128 ; USE_SCALAR_INC: // %bb.0:
129 ; USE_SCALAR_INC-NEXT: cntw x0, vl8, mul #11
130 ; USE_SCALAR_INC-NEXT: ret
131 %cnt = call i64 @llvm.aarch64.sve.cntw(i32 8)
132 %out = mul i64 %cnt, 11
136 define i64 @cntw_mul2() {
137 ; CHECK-LABEL: cntw_mul2:
139 ; CHECK-NEXT: cntw x0, vl6, mul #2
142 ; USE_SCALAR_INC-LABEL: cntw_mul2:
143 ; USE_SCALAR_INC: // %bb.0:
144 ; USE_SCALAR_INC-NEXT: cntw x0, vl6, mul #2
145 ; USE_SCALAR_INC-NEXT: ret
146 %cnt = call i64 @llvm.aarch64.sve.cntw(i32 6)
147 %out = mul i64 %cnt, 2
158 ; CHECK-NEXT: cntd x0, vl5
161 ; USE_SCALAR_INC-LABEL: cntd:
162 ; USE_SCALAR_INC: // %bb.0:
163 ; USE_SCALAR_INC-NEXT: cntd x0, vl5
164 ; USE_SCALAR_INC-NEXT: ret
165 %out = call i64 @llvm.aarch64.sve.cntd(i32 5)
169 define i64 @cntd_mul15() {
170 ; CHECK-LABEL: cntd_mul15:
172 ; CHECK-NEXT: cntd x0, vl16, mul #15
175 ; USE_SCALAR_INC-LABEL: cntd_mul15:
176 ; USE_SCALAR_INC: // %bb.0:
177 ; USE_SCALAR_INC-NEXT: cntd x0, vl16, mul #15
178 ; USE_SCALAR_INC-NEXT: ret
179 %cnt = call i64 @llvm.aarch64.sve.cntd(i32 9)
180 %out = mul i64 %cnt, 15
184 define i64 @cntd_mul16() {
185 ; CHECK-LABEL: cntd_mul16:
187 ; CHECK-NEXT: cntd x0, vl32, mul #16
190 ; USE_SCALAR_INC-LABEL: cntd_mul16:
191 ; USE_SCALAR_INC: // %bb.0:
192 ; USE_SCALAR_INC-NEXT: cntd x0, vl32, mul #16
193 ; USE_SCALAR_INC-NEXT: ret
194 %cnt = call i64 @llvm.aarch64.sve.cntd(i32 10)
195 %out = mul i64 %cnt, 16
203 define i64 @cntp_b8(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a) {
204 ; CHECK-LABEL: cntp_b8:
206 ; CHECK-NEXT: cntp x0, p0, p1.b
209 ; USE_SCALAR_INC-LABEL: cntp_b8:
210 ; USE_SCALAR_INC: // %bb.0:
211 ; USE_SCALAR_INC-NEXT: cntp x0, p0, p1.b
212 ; USE_SCALAR_INC-NEXT: ret
213 %out = call i64 @llvm.aarch64.sve.cntp.nxv16i1(<vscale x 16 x i1> %pg,
214 <vscale x 16 x i1> %a)
218 define i64 @cntp_b16(<vscale x 8 x i1> %pg, <vscale x 8 x i1> %a) {
219 ; CHECK-LABEL: cntp_b16:
221 ; CHECK-NEXT: cntp x0, p0, p1.h
224 ; USE_SCALAR_INC-LABEL: cntp_b16:
225 ; USE_SCALAR_INC: // %bb.0:
226 ; USE_SCALAR_INC-NEXT: cntp x0, p0, p1.h
227 ; USE_SCALAR_INC-NEXT: ret
228 %out = call i64 @llvm.aarch64.sve.cntp.nxv8i1(<vscale x 8 x i1> %pg,
229 <vscale x 8 x i1> %a)
233 define i64 @cntp_b32(<vscale x 4 x i1> %pg, <vscale x 4 x i1> %a) {
234 ; CHECK-LABEL: cntp_b32:
236 ; CHECK-NEXT: cntp x0, p0, p1.s
239 ; USE_SCALAR_INC-LABEL: cntp_b32:
240 ; USE_SCALAR_INC: // %bb.0:
241 ; USE_SCALAR_INC-NEXT: cntp x0, p0, p1.s
242 ; USE_SCALAR_INC-NEXT: ret
243 %out = call i64 @llvm.aarch64.sve.cntp.nxv4i1(<vscale x 4 x i1> %pg,
244 <vscale x 4 x i1> %a)
248 define i64 @cntp_b64(<vscale x 2 x i1> %pg, <vscale x 2 x i1> %a) {
249 ; CHECK-LABEL: cntp_b64:
251 ; CHECK-NEXT: cntp x0, p0, p1.d
254 ; USE_SCALAR_INC-LABEL: cntp_b64:
255 ; USE_SCALAR_INC: // %bb.0:
256 ; USE_SCALAR_INC-NEXT: cntp x0, p0, p1.d
257 ; USE_SCALAR_INC-NEXT: ret
258 %out = call i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1> %pg,
259 <vscale x 2 x i1> %a)
267 define i64 @incb(i64 %a) {
270 ; CHECK-NEXT: cntb x8, vl5
271 ; CHECK-NEXT: add x0, x8, x0
274 ; USE_SCALAR_INC-LABEL: incb:
275 ; USE_SCALAR_INC: // %bb.0:
276 ; USE_SCALAR_INC-NEXT: incb x0, vl5
277 ; USE_SCALAR_INC-NEXT: ret
278 %cnt = call i64 @llvm.aarch64.sve.cntb(i32 5)
279 %out = add i64 %cnt, %a
283 define i64 @incb_mul(i64 %a) {
284 ; CHECK-LABEL: incb_mul:
286 ; CHECK-NEXT: cntb x8, vl4
287 ; CHECK-NEXT: add x0, x0, x8, lsl #2
290 ; USE_SCALAR_INC-LABEL: incb_mul:
291 ; USE_SCALAR_INC: // %bb.0:
292 ; USE_SCALAR_INC-NEXT: incb x0, vl4, mul #4
293 ; USE_SCALAR_INC-NEXT: ret
294 %cnt = call i64 @llvm.aarch64.sve.cntb(i32 4)
295 %mul = mul i64 %cnt, 4
296 %out = add i64 %mul, %a
304 define i64 @decb(i64 %a) {
307 ; CHECK-NEXT: cntb x8, vl6
308 ; CHECK-NEXT: sub x0, x0, x8
311 ; USE_SCALAR_INC-LABEL: decb:
312 ; USE_SCALAR_INC: // %bb.0:
313 ; USE_SCALAR_INC-NEXT: decb x0, vl6
314 ; USE_SCALAR_INC-NEXT: ret
315 %cnt = call i64 @llvm.aarch64.sve.cntb(i32 6)
316 %out = sub i64 %a, %cnt
320 define i64 @decb_mul(i64 %a) {
321 ; CHECK-LABEL: decb_mul:
323 ; CHECK-NEXT: cntb x8, vl7
324 ; CHECK-NEXT: sub x0, x0, x8, lsl #3
327 ; USE_SCALAR_INC-LABEL: decb_mul:
328 ; USE_SCALAR_INC: // %bb.0:
329 ; USE_SCALAR_INC-NEXT: decb x0, vl7, mul #8
330 ; USE_SCALAR_INC-NEXT: ret
331 %cnt = call i64 @llvm.aarch64.sve.cntb(i32 7)
332 %mul = mul i64 %cnt, 8
333 %out = sub i64 %a, %mul
341 define i64 @inch(i64 %a) {
344 ; CHECK-NEXT: cnth x8, vl4
345 ; CHECK-NEXT: add x0, x8, x0
348 ; USE_SCALAR_INC-LABEL: inch:
349 ; USE_SCALAR_INC: // %bb.0:
350 ; USE_SCALAR_INC-NEXT: inch x0, vl4
351 ; USE_SCALAR_INC-NEXT: ret
352 %cnt = call i64 @llvm.aarch64.sve.cnth(i32 4)
353 %out = add i64 %cnt, %a
357 define i64 @inch_mul(i64 %a) {
358 ; CHECK-LABEL: inch_mul:
360 ; CHECK-NEXT: cnth x8, vl8, mul #5
361 ; CHECK-NEXT: add x0, x8, x0
364 ; USE_SCALAR_INC-LABEL: inch_mul:
365 ; USE_SCALAR_INC: // %bb.0:
366 ; USE_SCALAR_INC-NEXT: inch x0, vl8, mul #5
367 ; USE_SCALAR_INC-NEXT: ret
368 %cnt = call i64 @llvm.aarch64.sve.cnth(i32 8)
369 %mul = mul i64 %cnt, 5
370 %out = add i64 %mul, %a
378 define i64 @dech(i64 %a) {
381 ; CHECK-NEXT: cnth x8, vl1
382 ; CHECK-NEXT: sub x0, x0, x8
385 ; USE_SCALAR_INC-LABEL: dech:
386 ; USE_SCALAR_INC: // %bb.0:
387 ; USE_SCALAR_INC-NEXT: dech x0, vl1
388 ; USE_SCALAR_INC-NEXT: ret
389 %cnt = call i64 @llvm.aarch64.sve.cnth(i32 1)
390 %out = sub i64 %a, %cnt
394 define i64 @dech_mul(i64 %a) {
395 ; CHECK-LABEL: dech_mul:
397 ; CHECK-NEXT: cnth x8, vl16, mul #7
398 ; CHECK-NEXT: sub x0, x0, x8
401 ; USE_SCALAR_INC-LABEL: dech_mul:
402 ; USE_SCALAR_INC: // %bb.0:
403 ; USE_SCALAR_INC-NEXT: dech x0, vl16, mul #7
404 ; USE_SCALAR_INC-NEXT: ret
405 %cnt = call i64 @llvm.aarch64.sve.cnth(i32 9)
406 %mul = mul i64 %cnt, 7
407 %out = sub i64 %a, %mul
415 define i64 @incw(i64 %a) {
418 ; CHECK-NEXT: cntw x8, #16
419 ; CHECK-NEXT: add x0, x8, x0
422 ; USE_SCALAR_INC-LABEL: incw:
423 ; USE_SCALAR_INC: // %bb.0:
424 ; USE_SCALAR_INC-NEXT: incw x0, #16
425 ; USE_SCALAR_INC-NEXT: ret
426 %cnt = call i64 @llvm.aarch64.sve.cntw(i32 16)
427 %out = add i64 %cnt, %a
431 define i64 @incw_mul(i64 %a) {
432 ; CHECK-LABEL: incw_mul:
434 ; CHECK-NEXT: cntw x8, vl32, mul #12
435 ; CHECK-NEXT: add x0, x8, x0
438 ; USE_SCALAR_INC-LABEL: incw_mul:
439 ; USE_SCALAR_INC: // %bb.0:
440 ; USE_SCALAR_INC-NEXT: incw x0, vl32, mul #12
441 ; USE_SCALAR_INC-NEXT: ret
442 %cnt = call i64 @llvm.aarch64.sve.cntw(i32 10)
443 %mul = mul i64 %cnt, 12
444 %out = add i64 %mul, %a
452 define i64 @decw(i64 %a) {
455 ; CHECK-NEXT: cntw x8
456 ; CHECK-NEXT: sub x0, x0, x8
459 ; USE_SCALAR_INC-LABEL: decw:
460 ; USE_SCALAR_INC: // %bb.0:
461 ; USE_SCALAR_INC-NEXT: decw x0
462 ; USE_SCALAR_INC-NEXT: ret
463 %cnt = call i64 @llvm.aarch64.sve.cntw(i32 31)
464 %out = sub i64 %a, %cnt
468 define i64 @decw_mul(i64 %a) {
469 ; CHECK-LABEL: decw_mul:
471 ; CHECK-NEXT: cntw x8, vl128
472 ; CHECK-NEXT: sub x0, x0, x8, lsl #4
475 ; USE_SCALAR_INC-LABEL: decw_mul:
476 ; USE_SCALAR_INC: // %bb.0:
477 ; USE_SCALAR_INC-NEXT: decw x0, vl128, mul #16
478 ; USE_SCALAR_INC-NEXT: ret
479 %cnt = call i64 @llvm.aarch64.sve.cntw(i32 12)
480 %mul = mul i64 %cnt, 16
481 %out = sub i64 %a, %mul
485 define i64 @incd(i64 %a) {
488 ; CHECK-NEXT: cntd x8, vl8
489 ; CHECK-NEXT: add x0, x8, x0
492 ; USE_SCALAR_INC-LABEL: incd:
493 ; USE_SCALAR_INC: // %bb.0:
494 ; USE_SCALAR_INC-NEXT: incd x0, vl8
495 ; USE_SCALAR_INC-NEXT: ret
496 %cnt = call i64 @llvm.aarch64.sve.cntd(i32 8)
497 %out = add i64 %cnt, %a
501 define i64 @incd_mul(i64 %a) {
502 ; CHECK-LABEL: incd_mul:
504 ; CHECK-NEXT: cntd x8, all, mul #15
505 ; CHECK-NEXT: add x0, x8, x0
508 ; USE_SCALAR_INC-LABEL: incd_mul:
509 ; USE_SCALAR_INC: // %bb.0:
510 ; USE_SCALAR_INC-NEXT: incd x0, all, mul #15
511 ; USE_SCALAR_INC-NEXT: ret
512 %cnt = call i64 @llvm.aarch64.sve.cntd(i32 31)
513 %mul = mul i64 %cnt, 15
514 %out = add i64 %mul, %a
522 define i64 @decd(i64 %a) {
525 ; CHECK-NEXT: cntd x8, #16
526 ; CHECK-NEXT: sub x0, x0, x8
529 ; USE_SCALAR_INC-LABEL: decd:
530 ; USE_SCALAR_INC: // %bb.0:
531 ; USE_SCALAR_INC-NEXT: decd x0, #16
532 ; USE_SCALAR_INC-NEXT: ret
533 %cnt = call i64 @llvm.aarch64.sve.cntd(i32 16)
534 %out = sub i64 %a, %cnt
538 define i64 @decd_mul(i64 %a) {
539 ; CHECK-LABEL: decd_mul:
541 ; CHECK-NEXT: cntd x8, vl2, mul #9
542 ; CHECK-NEXT: sub x0, x0, x8
545 ; USE_SCALAR_INC-LABEL: decd_mul:
546 ; USE_SCALAR_INC: // %bb.0:
547 ; USE_SCALAR_INC-NEXT: decd x0, vl2, mul #9
548 ; USE_SCALAR_INC-NEXT: ret
549 %cnt = call i64 @llvm.aarch64.sve.cntd(i32 2)
550 %mul = mul i64 %cnt, 9
551 %out = sub i64 %a, %mul
555 declare i64 @llvm.aarch64.sve.cntb(i32 %pattern)
556 declare i64 @llvm.aarch64.sve.cnth(i32 %pattern)
557 declare i64 @llvm.aarch64.sve.cntw(i32 %pattern)
558 declare i64 @llvm.aarch64.sve.cntd(i32 %pattern)
560 declare i64 @llvm.aarch64.sve.cntp.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>)
561 declare i64 @llvm.aarch64.sve.cntp.nxv8i1(<vscale x 8 x i1>, <vscale x 8 x i1>)
562 declare i64 @llvm.aarch64.sve.cntp.nxv4i1(<vscale x 4 x i1>, <vscale x 4 x i1>)
563 declare i64 @llvm.aarch64.sve.cntp.nxv2i1(<vscale x 2 x i1>, <vscale x 2 x i1>)