1 # RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve -run-pass=peephole-opt -verify-machineinstrs %s -o - | FileCheck %s
3 # Test instruction sequences where PTEST is redundant and thus gets removed.
7 tracksRegLiveness: true
9 - { id: 0, class: ppr_3b }
10 - { id: 1, class: zpr }
11 - { id: 2, class: zpr }
12 - { id: 3, class: ppr }
13 - { id: 4, class: gpr32 }
14 - { id: 5, class: gpr32 }
16 - { reg: '$p0', virtual-reg: '%0' }
17 - { reg: '$z0', virtual-reg: '%1' }
18 - { reg: '$z1', virtual-reg: '%2' }
23 liveins: $p0, $z0, $z1
25 ; Here we check the expected sequence with subsequent tests
26 ; just asserting there is no PTEST instruction.
28 ; CHECK-LABEL: name: cmpeq_nxv16i8
29 ; CHECK: %3:ppr = CMPEQ_PPzZZ_B %0, %1, %2, implicit-def $nzcv
30 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
31 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
35 %3:ppr = CMPEQ_PPzZZ_B %0, %1, %2, implicit-def dead $nzcv
36 PTEST_PP %0, killed %3, implicit-def $nzcv
38 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
40 RET_ReallyLR implicit $w0
46 tracksRegLiveness: true
48 - { id: 0, class: ppr_3b }
49 - { id: 1, class: zpr }
50 - { id: 2, class: zpr }
51 - { id: 3, class: ppr_3b }
52 - { id: 4, class: ppr }
53 - { id: 5, class: ppr }
54 - { id: 6, class: gpr32 }
55 - { id: 7, class: gpr32 }
57 - { reg: '$p0', virtual-reg: '%0' }
58 - { reg: '$z0', virtual-reg: '%1' }
59 - { reg: '$z1', virtual-reg: '%2' }
64 liveins: $p0, $z0, $z1
66 ; CHECK-LABEL: name: cmpeq_nxv8i16
71 %4:ppr = CMPEQ_PPzZZ_H %0, %1, %2, implicit-def dead $nzcv
72 PTEST_PP %0, %4, implicit-def $nzcv
74 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
76 RET_ReallyLR implicit $w0
82 tracksRegLiveness: true
84 - { id: 0, class: ppr_3b }
85 - { id: 1, class: zpr }
86 - { id: 2, class: zpr }
87 - { id: 3, class: ppr_3b }
88 - { id: 4, class: ppr }
89 - { id: 5, class: ppr }
90 - { id: 6, class: gpr32 }
91 - { id: 7, class: gpr32 }
93 - { reg: '$p0', virtual-reg: '%0' }
94 - { reg: '$z0', virtual-reg: '%1' }
95 - { reg: '$z1', virtual-reg: '%2' }
100 liveins: $p0, $z0, $z1
102 ; CHECK-LABEL: name: cmpeq_nxv4i32
107 %4:ppr = CMPEQ_PPzZZ_S %0, %1, %2, implicit-def dead $nzcv
108 PTEST_PP %0, %4, implicit-def $nzcv
110 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
112 RET_ReallyLR implicit $w0
118 tracksRegLiveness: true
120 - { id: 0, class: ppr_3b }
121 - { id: 1, class: zpr }
122 - { id: 2, class: zpr }
123 - { id: 3, class: ppr_3b }
124 - { id: 4, class: ppr }
125 - { id: 5, class: ppr }
126 - { id: 6, class: gpr32 }
127 - { id: 7, class: gpr32 }
129 - { reg: '$p0', virtual-reg: '%0' }
130 - { reg: '$z0', virtual-reg: '%1' }
131 - { reg: '$z1', virtual-reg: '%2' }
136 liveins: $p0, $z0, $z1
138 ; CHECK-LABEL: name: cmpeq_nxv2i64
143 %4:ppr = CMPEQ_PPzZZ_D %0, %1, %2, implicit-def dead $nzcv
144 PTEST_PP %0, %4, implicit-def $nzcv
146 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
148 RET_ReallyLR implicit $w0
152 name: cmpeq_imm_nxv16i8
154 tracksRegLiveness: true
156 - { id: 0, class: ppr_3b }
157 - { id: 1, class: zpr }
158 - { id: 2, class: ppr }
159 - { id: 3, class: ppr }
160 - { id: 4, class: gpr32 }
161 - { id: 5, class: gpr32 }
163 - { reg: '$p0', virtual-reg: '%0' }
164 - { reg: '$z0', virtual-reg: '%1' }
171 ; CHECK-LABEL: name: cmpeq_imm_nxv16i8
175 %2:ppr = CMPEQ_PPzZI_B %0, %1, 0, implicit-def dead $nzcv
177 PTEST_PP killed %3, killed %2, implicit-def $nzcv
179 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
181 RET_ReallyLR implicit $w0
185 name: cmpeq_imm_nxv8i16
187 tracksRegLiveness: true
189 - { id: 0, class: ppr_3b }
190 - { id: 1, class: zpr }
191 - { id: 2, class: ppr }
192 - { id: 3, class: ppr }
193 - { id: 4, class: ppr }
194 - { id: 5, class: gpr32 }
195 - { id: 6, class: gpr32 }
197 - { reg: '$p0', virtual-reg: '%0' }
198 - { reg: '$z0', virtual-reg: '%1' }
205 ; CHECK-LABEL: name: cmpeq_imm_nxv8i16
209 %2:ppr = CMPEQ_PPzZI_H %0, %1, 0, implicit-def dead $nzcv
210 PTEST_PP %0, %2, implicit-def $nzcv
212 %6:gpr32 = CSINCWr %5, $wzr, 0, implicit $nzcv
214 RET_ReallyLR implicit $w0
218 name: cmpeq_imm_nxv4i32
220 tracksRegLiveness: true
222 - { id: 0, class: ppr_3b }
223 - { id: 1, class: zpr }
224 - { id: 2, class: ppr }
225 - { id: 3, class: ppr }
226 - { id: 4, class: ppr }
227 - { id: 5, class: gpr32 }
228 - { id: 6, class: gpr32 }
230 - { reg: '$p0', virtual-reg: '%0' }
231 - { reg: '$z0', virtual-reg: '%1' }
238 ; CHECK-LABEL: name: cmpeq_imm_nxv4i32
242 %2:ppr = CMPEQ_PPzZI_S %0, %1, 0, implicit-def dead $nzcv
243 PTEST_PP %0, %2, implicit-def $nzcv
245 %6:gpr32 = CSINCWr %5, $wzr, 0, implicit $nzcv
247 RET_ReallyLR implicit $w0
251 name: cmpeq_imm_nxv2i64
253 tracksRegLiveness: true
255 - { id: 0, class: ppr_3b }
256 - { id: 1, class: zpr }
257 - { id: 2, class: ppr }
258 - { id: 3, class: ppr }
259 - { id: 4, class: ppr }
260 - { id: 5, class: gpr32 }
261 - { id: 6, class: gpr32 }
263 - { reg: '$p0', virtual-reg: '%0' }
264 - { reg: '$z0', virtual-reg: '%1' }
271 ; CHECK-LABEL: name: cmpeq_imm_nxv2i64
275 %2:ppr = CMPEQ_PPzZI_D %0, %1, 0, implicit-def dead $nzcv
276 PTEST_PP %0, %2, implicit-def $nzcv
278 %6:gpr32 = CSINCWr %5, $wzr, 0, implicit $nzcv
280 RET_ReallyLR implicit $w0
284 name: cmpeq_wide_nxv16i8
286 tracksRegLiveness: true
288 - { id: 0, class: ppr_3b }
289 - { id: 1, class: zpr }
290 - { id: 2, class: zpr }
291 - { id: 3, class: ppr }
292 - { id: 4, class: gpr32 }
293 - { id: 5, class: gpr32 }
295 - { reg: '$p0', virtual-reg: '%0' }
296 - { reg: '$z0', virtual-reg: '%1' }
297 - { reg: '$z1', virtual-reg: '%2' }
302 liveins: $p0, $z0, $z1
304 ; CHECK-LABEL: name: cmpeq_wide_nxv16i8
309 %3:ppr = CMPEQ_WIDE_PPzZZ_B %0, %1, %2, implicit-def dead $nzcv
310 PTEST_PP %0, killed %3, implicit-def $nzcv
312 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
314 RET_ReallyLR implicit $w0
318 name: cmpeq_wide_nxv8i16
320 tracksRegLiveness: true
322 - { id: 0, class: ppr_3b }
323 - { id: 1, class: zpr }
324 - { id: 2, class: zpr }
325 - { id: 3, class: ppr_3b }
326 - { id: 4, class: ppr }
327 - { id: 5, class: ppr }
328 - { id: 6, class: gpr32 }
329 - { id: 7, class: gpr32 }
331 - { reg: '$p0', virtual-reg: '%0' }
332 - { reg: '$z0', virtual-reg: '%1' }
333 - { reg: '$z1', virtual-reg: '%2' }
338 liveins: $p0, $z0, $z1
340 ; CHECK-LABEL: name: cmpeq_wide_nxv8i16
345 %4:ppr = CMPEQ_WIDE_PPzZZ_H %0, %1, %2, implicit-def dead $nzcv
346 PTEST_PP %0, %4, implicit-def $nzcv
348 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
350 RET_ReallyLR implicit $w0
354 name: cmpeq_wide_nxv4i32
356 tracksRegLiveness: true
358 - { id: 0, class: ppr_3b }
359 - { id: 1, class: zpr }
360 - { id: 2, class: zpr }
361 - { id: 3, class: ppr_3b }
362 - { id: 4, class: ppr }
363 - { id: 5, class: ppr }
364 - { id: 6, class: gpr32 }
365 - { id: 7, class: gpr32 }
367 - { reg: '$p0', virtual-reg: '%0' }
368 - { reg: '$z0', virtual-reg: '%1' }
369 - { reg: '$z1', virtual-reg: '%2' }
374 liveins: $p0, $z0, $z1
376 ; CHECK-LABEL: name: cmpeq_wide_nxv4i32
381 %4:ppr = CMPEQ_WIDE_PPzZZ_S %0, %1, %2, implicit-def dead $nzcv
382 PTEST_PP %0, %4, implicit-def $nzcv
384 %7:gpr32 = CSINCWr %6, $wzr, 0, implicit $nzcv
386 RET_ReallyLR implicit $w0
390 name: cmpeq_imm_nxv16i8_ptest_not_all_active
392 tracksRegLiveness: true
394 - { id: 0, class: ppr_3b }
395 - { id: 1, class: zpr }
396 - { id: 2, class: ppr }
397 - { id: 3, class: ppr }
398 - { id: 4, class: gpr32 }
399 - { id: 5, class: gpr32 }
401 - { reg: '$p0', virtual-reg: '%0' }
402 - { reg: '$z0', virtual-reg: '%1' }
409 ; CHECK-LABEL: name: cmpeq_imm_nxv16i8_ptest_not_all_active
410 ; CHECK: %2:ppr = CMPEQ_PPzZI_B %0, %1, 0, implicit-def dead $nzcv
411 ; CHECK-NEXT: %3:ppr = PTRUE_B 0
412 ; CHECK-NEXT: PTEST_PP killed %3, killed %2, implicit-def $nzcv
413 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
414 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
417 %2:ppr = CMPEQ_PPzZI_B %0, %1, 0, implicit-def dead $nzcv
419 PTEST_PP killed %3, killed %2, implicit-def $nzcv
421 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
423 RET_ReallyLR implicit $w0
427 name: cmpeq_imm_nxv16i8_ptest_of_halfs
429 tracksRegLiveness: true
431 - { id: 0, class: ppr_3b }
432 - { id: 1, class: zpr }
433 - { id: 2, class: ppr }
434 - { id: 3, class: ppr }
435 - { id: 4, class: gpr32 }
436 - { id: 5, class: gpr32 }
438 - { reg: '$p0', virtual-reg: '%0' }
439 - { reg: '$z0', virtual-reg: '%1' }
446 ; CHECK-LABEL: name: cmpeq_imm_nxv16i8_ptest_of_halfs
447 ; CHECK: %2:ppr = CMPEQ_PPzZI_B %0, %1, 0, implicit-def dead $nzcv
448 ; CHECK-NEXT: %3:ppr = PTRUE_H 31
449 ; CHECK-NEXT: PTEST_PP killed %3, killed %2, implicit-def $nzcv
450 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
451 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
454 %2:ppr = CMPEQ_PPzZI_B %0, %1, 0, implicit-def dead $nzcv
456 PTEST_PP killed %3, killed %2, implicit-def $nzcv
458 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
460 RET_ReallyLR implicit $w0
464 name: cmpeq_imm_nxv16i8_ptest_with_unique_pg
466 tracksRegLiveness: true
468 - { id: 0, class: ppr_3b }
469 - { id: 1, class: zpr }
470 - { id: 2, class: ppr }
471 - { id: 3, class: ppr }
472 - { id: 4, class: gpr32 }
473 - { id: 5, class: gpr32 }
475 - { reg: '$p0', virtual-reg: '%0' }
476 - { reg: '$p1', virtual-reg: '%3' }
477 - { reg: '$z0', virtual-reg: '%1' }
482 liveins: $p0, $p1, $z0
484 ; CHECK-LABEL: name: cmpeq_imm_nxv16i8_ptest_with_unique_pg
485 ; CHECK: %2:ppr = CMPEQ_PPzZI_B %0, %1, 0, implicit-def dead $nzcv
486 ; CHECK-NEXT: %3:ppr = COPY $p1
487 ; CHECK-NEXT: PTEST_PP killed %3, killed %2, implicit-def $nzcv
488 ; CHECK-NEXT: %4:gpr32 = COPY $wzr
489 ; CHECK-NEXT: %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
492 %2:ppr = CMPEQ_PPzZI_B %0, %1, 0, implicit-def dead $nzcv
494 PTEST_PP killed %3, killed %2, implicit-def $nzcv
496 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
498 RET_ReallyLR implicit $w0
502 name: cmpeq_nxv16i8_ptest_with_matching_operands
504 tracksRegLiveness: true
506 - { id: 0, class: ppr_3b }
507 - { id: 1, class: zpr }
508 - { id: 2, class: zpr }
509 - { id: 3, class: ppr }
510 - { id: 4, class: gpr32 }
511 - { id: 5, class: gpr32 }
513 - { reg: '$p0', virtual-reg: '%0' }
514 - { reg: '$z0', virtual-reg: '%1' }
515 - { reg: '$z1', virtual-reg: '%2' }
520 liveins: $p0, $z0, $z1
522 ; CHECK-LABEL: name: cmpeq_nxv16i8_ptest_with_matching_operands
527 %3:ppr = CMPEQ_PPzZZ_B %0, %1, %2, implicit-def dead $nzcv
528 PTEST_PP %3, killed %3, implicit-def $nzcv
530 %5:gpr32 = CSINCWr %4, $wzr, 0, implicit $nzcv
532 RET_ReallyLR implicit $w0