1 # RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve -run-pass=peephole-opt -verify-machineinstrs %s -o - | FileCheck %s
2 # Test that RDFFR followed by PTEST is replaced with RDFFRS.
4 # CHECK-LABEL: name:{{\s*}} substitute_rdffr_pp_with_rdffrs_pp
5 name: substitute_rdffr_pp_with_rdffrs_pp
6 tracksRegLiveness: true
14 %1:ppr_3b = RDFFR_PPz %0:ppr_3b, implicit $ffr
15 PTEST_PP killed %0:ppr_3b, killed %1:ppr_3b, implicit-def $nzcv
19 %3:gpr32 = CSINCWr killed %2, $wzr, 0, implicit $nzcv
21 RET_ReallyLR implicit $w0
24 # CHECK-LABEL: name:{{\s*}} fail_to_substitute_rdffr_pp_with_rdffrs_pp_differing_mask
25 name: fail_to_substitute_rdffr_pp_with_rdffrs_pp_differing_mask
26 tracksRegLiveness: true
29 liveins: $ffr, $p0, $p1
35 %2:ppr_3b = RDFFR_PPz %0:ppr_3b, implicit $ffr
36 PTEST_PP killed %1:ppr_3b, killed %2:ppr_3b, implicit-def $nzcv
40 %4:gpr32 = CSINCWr killed %3, $wzr, 0, implicit $nzcv
42 RET_ReallyLR implicit $w0
45 # CHECK-LABEL: name:{{\s*}} fail_to_substitute_rdffr_pp_with_rdffrs_pp_nzcv_clobbered
46 name: fail_to_substitute_rdffr_pp_with_rdffrs_pp_nzcv_clobbered
47 tracksRegLiveness: true
50 liveins: $ffr, $p0, $x0
55 ; CHECK-NEXT: PTEST_PP
56 %1:ppr_3b = RDFFR_PPz %0:ppr_3b, implicit $ffr
58 $x0 = ADDSXrr $x0, $x0, implicit-def $nzcv
59 PTEST_PP killed %0:ppr_3b, killed %1:ppr_3b, implicit-def $nzcv
63 %3:gpr32 = CSINCWr killed %2, $wzr, 0, implicit $nzcv
65 RET_ReallyLR implicit $w0
68 # CHECK-LABEL: name:{{\s*}} fail_to_substitute_rdffr_pp_with_rdffrs_pp_nzcv_flags_used_between
69 name: fail_to_substitute_rdffr_pp_with_rdffrs_pp_nzcv_flags_used_between
70 tracksRegLiveness: true
73 liveins: $ffr, $p0, $x0
76 $wzr = SUBSWri $w0, 0, 0, implicit-def $nzcv
80 ; CHECK-NEXT: PTEST_PP
81 %1:ppr_3b = RDFFR_PPz %0:ppr_3b, implicit $ffr
83 %2:gpr32 = CSINCWr $wzr, $wzr, 0, implicit $nzcv
84 PTEST_PP killed %0:ppr_3b, killed %1:ppr_3b, implicit-def $nzcv
88 %4:gpr32 = CSINCWr killed %3, $wzr, 0, implicit $nzcv
89 $w0 = ORRWrs %4, %2, 1
90 RET_ReallyLR implicit $w0