1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1031 -run-pass=machine-sink -o - %s | FileCheck %s
4 # A VGPR loop variable was incorrectly sunk into a flow block, past
5 # the si_end_cf reconvergence point.
8 name: machinesink_loop_vgpr_out_of_divergent_loop
9 tracksRegLiveness: true
11 scratchRSrcReg: '$sgpr0_sgpr1_sgpr2_sgpr3'
12 frameOffsetReg: '$sgpr33'
13 stackPtrOffsetReg: '$sgpr32'
15 ; CHECK-LABEL: name: machinesink_loop_vgpr_out_of_divergent_loop
17 ; CHECK-NEXT: successors: %bb.1(0x80000000)
18 ; CHECK-NEXT: liveins: $vgpr0, $vgpr1, $sgpr8
20 ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr_32 = COPY $vgpr0
21 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr8
22 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr_32 = COPY $vgpr1
25 ; CHECK-NEXT: successors: %bb.6(0x40000000), %bb.2(0x40000000)
27 ; CHECK-NEXT: [[SI_IF:%[0-9]+]]:sreg_32 = SI_IF [[COPY1]], %bb.6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
28 ; CHECK-NEXT: S_BRANCH %bb.2
31 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000)
33 ; CHECK-NEXT: [[SI_IF1:%[0-9]+]]:sreg_32 = SI_IF [[COPY1]], %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
34 ; CHECK-NEXT: S_BRANCH %bb.3
37 ; CHECK-NEXT: successors: %bb.4(0x80000000)
42 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.5(0x40000000)
44 ; CHECK-NEXT: INLINEASM &"", 1 /* sideeffect attdialect */
45 ; CHECK-NEXT: [[SI_IF_BREAK:%[0-9]+]]:sreg_32 = SI_IF_BREAK killed [[SI_IF1]], [[SI_IF]], implicit-def dead $scc
46 ; CHECK-NEXT: SI_LOOP [[SI_IF_BREAK]], %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
47 ; CHECK-NEXT: S_BRANCH %bb.5
50 ; CHECK-NEXT: successors: %bb.2(0x80000000)
52 ; CHECK-NEXT: [[PHI:%[0-9]+]]:vgpr_32 = PHI [[COPY]], %bb.4
53 ; CHECK-NEXT: SI_END_CF [[SI_IF_BREAK]], implicit-def dead $exec, implicit-def dead $scc, implicit $exec
54 ; CHECK-NEXT: [[V_ADD_U32_e64_:%[0-9]+]]:vgpr_32 = V_ADD_U32_e64 [[COPY]], [[COPY1]], 0, implicit $exec
55 ; CHECK-NEXT: INLINEASM &"", 1 /* sideeffect attdialect */, implicit [[V_ADD_U32_e64_]]
56 ; CHECK-NEXT: S_BRANCH %bb.2
59 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.7(0x40000000)
61 ; CHECK-NEXT: SI_LOOP [[SI_IF]], %bb.1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
62 ; CHECK-NEXT: S_BRANCH %bb.7
65 ; CHECK-NEXT: successors: %bb.7(0x40000000), %bb.8(0x40000000)
67 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.7, implicit undef $vcc
68 ; CHECK-NEXT: S_BRANCH %bb.8
71 ; CHECK-NEXT: SI_RETURN
73 liveins: $vgpr0, $vgpr1, $sgpr8
75 %0:vgpr_32 = COPY $vgpr0
76 %1:sreg_32 = COPY $sgpr8
77 %2:vgpr_32 = COPY $vgpr1
80 %3:sreg_32 = SI_IF %1, %bb.6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
84 %4:sreg_32 = SI_IF %1, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
91 INLINEASM &"", 1 /* sideeffect attdialect */
92 %5:vgpr_32 = V_ADD_U32_e64 %0, %1, 0, implicit $exec
93 %6:sreg_32 = SI_IF_BREAK killed %4, %3, implicit-def dead $scc
94 SI_LOOP %6, %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
98 %7:vgpr_32 = PHI %0, %bb.4
99 SI_END_CF %6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
100 INLINEASM &"", 1, implicit %5
104 SI_LOOP %3, %bb.1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
108 S_CBRANCH_VCCNZ %bb.7, implicit undef $vcc
116 # The same testcase, except the relevant instruction is scalar and
117 # could be legally sunk.
119 name: machinesink_loop_sgpr_out_of_divergent_loop
120 tracksRegLiveness: true
122 scratchRSrcReg: '$sgpr0_sgpr1_sgpr2_sgpr3'
123 frameOffsetReg: '$sgpr33'
124 stackPtrOffsetReg: '$sgpr32'
126 ; CHECK-LABEL: name: machinesink_loop_sgpr_out_of_divergent_loop
128 ; CHECK-NEXT: successors: %bb.1(0x80000000)
129 ; CHECK-NEXT: liveins: $sgpr8, $sgpr9, $sgpr10
131 ; CHECK-NEXT: [[COPY:%[0-9]+]]:sreg_32 = COPY $sgpr8
132 ; CHECK-NEXT: [[COPY1:%[0-9]+]]:sreg_32 = COPY $sgpr9
133 ; CHECK-NEXT: [[COPY2:%[0-9]+]]:sreg_32 = COPY $sgpr10
136 ; CHECK-NEXT: successors: %bb.6(0x40000000), %bb.2(0x40000000)
138 ; CHECK-NEXT: [[SI_IF:%[0-9]+]]:sreg_32 = SI_IF [[COPY1]], %bb.6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
139 ; CHECK-NEXT: S_BRANCH %bb.2
142 ; CHECK-NEXT: successors: %bb.4(0x40000000), %bb.3(0x40000000)
144 ; CHECK-NEXT: [[SI_IF1:%[0-9]+]]:sreg_32 = SI_IF [[COPY1]], %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
145 ; CHECK-NEXT: S_BRANCH %bb.3
148 ; CHECK-NEXT: successors: %bb.4(0x80000000)
150 ; CHECK-NEXT: S_NOP 0
153 ; CHECK-NEXT: successors: %bb.2(0x40000000), %bb.5(0x40000000)
155 ; CHECK-NEXT: INLINEASM &"", 1 /* sideeffect attdialect */
156 ; CHECK-NEXT: [[SI_IF_BREAK:%[0-9]+]]:sreg_32 = SI_IF_BREAK killed [[SI_IF1]], [[SI_IF]], implicit-def dead $scc
157 ; CHECK-NEXT: SI_LOOP [[SI_IF_BREAK]], %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
158 ; CHECK-NEXT: S_BRANCH %bb.5
161 ; CHECK-NEXT: successors: %bb.2(0x80000000)
163 ; CHECK-NEXT: [[PHI:%[0-9]+]]:vgpr_32 = PHI [[COPY]], %bb.4
164 ; CHECK-NEXT: SI_END_CF [[SI_IF_BREAK]], implicit-def dead $exec, implicit-def dead $scc, implicit $exec
165 ; CHECK-NEXT: [[S_ADD_I32_:%[0-9]+]]:sreg_32 = S_ADD_I32 [[COPY]], [[COPY1]], implicit-def dead $scc
166 ; CHECK-NEXT: INLINEASM &"", 1 /* sideeffect attdialect */, implicit [[S_ADD_I32_]]
167 ; CHECK-NEXT: S_BRANCH %bb.2
170 ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.7(0x40000000)
172 ; CHECK-NEXT: SI_LOOP [[SI_IF]], %bb.1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
173 ; CHECK-NEXT: S_BRANCH %bb.7
176 ; CHECK-NEXT: successors: %bb.7(0x40000000), %bb.8(0x40000000)
178 ; CHECK-NEXT: S_CBRANCH_VCCNZ %bb.7, implicit undef $vcc
179 ; CHECK-NEXT: S_BRANCH %bb.8
182 ; CHECK-NEXT: SI_RETURN
184 liveins: $sgpr8, $sgpr9, $sgpr10
186 %0:sreg_32 = COPY $sgpr8
187 %1:sreg_32 = COPY $sgpr9
188 %2:sreg_32 = COPY $sgpr10
191 %3:sreg_32 = SI_IF %1, %bb.6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
195 %4:sreg_32 = SI_IF %1, %bb.4, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
202 INLINEASM &"", 1 /* sideeffect attdialect */
203 %5:sreg_32 = S_ADD_I32 %0, %1, implicit-def dead $scc
204 %6:sreg_32 = SI_IF_BREAK killed %4, %3, implicit-def dead $scc
205 SI_LOOP %6, %bb.2, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
209 %7:vgpr_32 = PHI %0, %bb.4
210 SI_END_CF %6, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
211 INLINEASM &"", 1, implicit %5
215 SI_LOOP %3, %bb.1, implicit-def dead $exec, implicit-def dead $scc, implicit $exec
219 S_CBRANCH_VCCNZ %bb.7, implicit undef $vcc