1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx906 -verify-machineinstrs -run-pass=si-optimize-exec-masking-pre-ra,si-optimize-exec-masking-pre-ra -o - %s | FileCheck %s
4 # FIXME: Second run of the pass is a workaround for a bug in
5 # -run-pass. The verifier doesn't detect broken LiveIntervals, see bug
9 # Cannot fold this without moving the def of %7 after the and.
11 name: no_fold_andn2_select_condition_live_out_phi
12 tracksRegLiveness: true
14 ; CHECK-LABEL: name: no_fold_andn2_select_condition_live_out_phi
16 ; CHECK-NEXT: successors: %bb.2(0x80000000)
18 ; CHECK-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64_xexec = S_MOV_B64 -1
19 ; CHECK-NEXT: undef %1.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
20 ; CHECK-NEXT: S_BRANCH %bb.2
23 ; CHECK-NEXT: S_ENDPGM 0
26 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
28 ; CHECK-NEXT: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, [[S_MOV_B64_]], implicit $exec
29 ; CHECK-NEXT: V_CMP_NE_U32_e32 1, [[V_CNDMASK_B32_e64_]], implicit-def $vcc, implicit $exec
30 ; CHECK-NEXT: %1.sub1:vreg_64 = COPY %1.sub0
31 ; CHECK-NEXT: DS_WRITE_B64_gfx9 undef %3:vgpr_32, %1, 0, 0, implicit $exec :: (store (s64), addrspace 3)
32 ; CHECK-NEXT: ATOMIC_FENCE 4, 2
33 ; CHECK-NEXT: [[S_MOV_B64_1:%[0-9]+]]:sreg_64_xexec = S_MOV_B64 0
34 ; CHECK-NEXT: $vcc = S_AND_B64 $exec, $vcc, implicit-def dead $scc
35 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit $vcc
36 ; CHECK-NEXT: S_BRANCH %bb.2
40 %7:sreg_64_xexec = S_MOV_B64 -1
41 undef %5.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
48 successors: %bb.1, %bb.2
50 %4:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %7, implicit $exec
51 V_CMP_NE_U32_e32 1, %4, implicit-def $vcc, implicit $exec
52 %5.sub1:vreg_64 = COPY %5.sub0
53 DS_WRITE_B64_gfx9 undef %6:vgpr_32, %5, 0, 0, implicit $exec :: (store (s64), addrspace 3)
55 %7:sreg_64_xexec = S_MOV_B64 0
56 $vcc = S_AND_B64 $exec, killed $vcc, implicit-def dead $scc
57 S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc
62 # It's OK to fold this, since the phi def is after the andn2 insert point.
64 name: fold_andn2_select_condition_live_out_phi_reorder
65 tracksRegLiveness: true
67 ; CHECK-LABEL: name: fold_andn2_select_condition_live_out_phi_reorder
69 ; CHECK-NEXT: successors: %bb.2(0x80000000)
71 ; CHECK-NEXT: [[S_MOV_B64_:%[0-9]+]]:sreg_64_xexec = S_MOV_B64 -1
72 ; CHECK-NEXT: undef %1.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
73 ; CHECK-NEXT: S_BRANCH %bb.2
76 ; CHECK-NEXT: S_ENDPGM 0
79 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
81 ; CHECK-NEXT: %1.sub1:vreg_64 = COPY %1.sub0
82 ; CHECK-NEXT: DS_WRITE_B64_gfx9 undef %3:vgpr_32, %1, 0, 0, implicit $exec :: (store (s64), addrspace 3)
83 ; CHECK-NEXT: ATOMIC_FENCE 4, 2
84 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, [[S_MOV_B64_]], implicit-def dead $scc
85 ; CHECK-NEXT: [[S_MOV_B64_1:%[0-9]+]]:sreg_64_xexec = S_MOV_B64 0
86 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit $vcc
87 ; CHECK-NEXT: S_BRANCH %bb.2
91 %7:sreg_64_xexec = S_MOV_B64 -1
92 undef %5.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
99 successors: %bb.1, %bb.2
101 %4:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %7, implicit $exec
102 V_CMP_NE_U32_e32 1, %4, implicit-def $vcc, implicit $exec
103 %5.sub1:vreg_64 = COPY %5.sub0
104 DS_WRITE_B64_gfx9 undef %6:vgpr_32, %5, 0, 0, implicit $exec :: (store (s64), addrspace 3)
106 $vcc = S_AND_B64 $exec, killed $vcc, implicit-def dead $scc
107 %7:sreg_64_xexec = S_MOV_B64 0
108 S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc
114 name: no_fold_andn2_select_condition_live_out_phi_physreg
115 tracksRegLiveness: true
117 ; CHECK-LABEL: name: no_fold_andn2_select_condition_live_out_phi_physreg
119 ; CHECK-NEXT: successors: %bb.2(0x80000000)
121 ; CHECK-NEXT: $sgpr4_sgpr5 = S_MOV_B64 -1
122 ; CHECK-NEXT: undef %0.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
123 ; CHECK-NEXT: S_BRANCH %bb.2
126 ; CHECK-NEXT: S_ENDPGM 0
129 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
130 ; CHECK-NEXT: liveins: $sgpr4_sgpr5
132 ; CHECK-NEXT: [[V_CNDMASK_B32_e64_:%[0-9]+]]:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, $sgpr4_sgpr5, implicit $exec
133 ; CHECK-NEXT: V_CMP_NE_U32_e32 1, [[V_CNDMASK_B32_e64_]], implicit-def $vcc, implicit $exec
134 ; CHECK-NEXT: %0.sub1:vreg_64 = COPY %0.sub0
135 ; CHECK-NEXT: DS_WRITE_B64_gfx9 undef %2:vgpr_32, %0, 0, 0, implicit $exec :: (store (s64), addrspace 3)
136 ; CHECK-NEXT: ATOMIC_FENCE 4, 2
137 ; CHECK-NEXT: $sgpr4_sgpr5 = S_MOV_B64 0
138 ; CHECK-NEXT: $vcc = S_AND_B64 $exec, $vcc, implicit-def dead $scc
139 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit $vcc
140 ; CHECK-NEXT: S_BRANCH %bb.2
144 $sgpr4_sgpr5 = S_MOV_B64 -1
145 undef %5.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
152 successors: %bb.1, %bb.2
153 liveins: $sgpr4_sgpr5
155 %4:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, $sgpr4_sgpr5, implicit $exec
156 V_CMP_NE_U32_e32 1, %4, implicit-def $vcc, implicit $exec
157 %5.sub1:vreg_64 = COPY %5.sub0
158 DS_WRITE_B64_gfx9 undef %6:vgpr_32, %5, 0, 0, implicit $exec :: (store (s64), addrspace 3)
160 $sgpr4_sgpr5 = S_MOV_B64 0
161 $vcc = S_AND_B64 $exec, killed $vcc, implicit-def dead $scc
162 S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc
168 name: fold_andn2_select_condition_live_out_phi_physreg_reorder
169 tracksRegLiveness: true
171 ; CHECK-LABEL: name: fold_andn2_select_condition_live_out_phi_physreg_reorder
173 ; CHECK-NEXT: successors: %bb.2(0x80000000)
175 ; CHECK-NEXT: $sgpr4_sgpr5 = S_MOV_B64 -1
176 ; CHECK-NEXT: undef %0.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
177 ; CHECK-NEXT: S_BRANCH %bb.2
180 ; CHECK-NEXT: S_ENDPGM 0
183 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
184 ; CHECK-NEXT: liveins: $sgpr4_sgpr5
186 ; CHECK-NEXT: %0.sub1:vreg_64 = COPY %0.sub0
187 ; CHECK-NEXT: DS_WRITE_B64_gfx9 undef %2:vgpr_32, %0, 0, 0, implicit $exec :: (store (s64), addrspace 3)
188 ; CHECK-NEXT: ATOMIC_FENCE 4, 2
189 ; CHECK-NEXT: $vcc = S_ANDN2_B64 $exec, $sgpr4_sgpr5, implicit-def dead $scc
190 ; CHECK-NEXT: $sgpr4_sgpr5 = S_MOV_B64 0
191 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.1, implicit $vcc
192 ; CHECK-NEXT: S_BRANCH %bb.2
196 $sgpr4_sgpr5 = S_MOV_B64 -1
197 undef %5.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
204 successors: %bb.1, %bb.2
205 liveins: $sgpr4_sgpr5
207 %4:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, $sgpr4_sgpr5, implicit $exec
208 V_CMP_NE_U32_e32 1, %4, implicit-def $vcc, implicit $exec
209 %5.sub1:vreg_64 = COPY %5.sub0
210 DS_WRITE_B64_gfx9 undef %6:vgpr_32, %5, 0, 0, implicit $exec :: (store (s64), addrspace 3)
212 $vcc = S_AND_B64 $exec, killed $vcc, implicit-def dead $scc
213 $sgpr4_sgpr5 = S_MOV_B64 0
214 S_CBRANCH_VCCNZ %bb.1, implicit killed $vcc