1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=GFX11
4 declare i32 @llvm.amdgcn.workitem.id.x()
8 ; GFX11: ; %bb.0: ; %bb
9 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
10 ; GFX11-NEXT: s_mov_b32 s2, s33
11 ; GFX11-NEXT: s_mov_b32 s33, s32
12 ; GFX11-NEXT: s_xor_saveexec_b32 s0, -1
13 ; GFX11-NEXT: scratch_store_b32 off, v4, s33 ; 4-byte Folded Spill
14 ; GFX11-NEXT: s_mov_b32 exec_lo, s0
15 ; GFX11-NEXT: s_add_i32 s32, s32, 16
16 ; GFX11-NEXT: s_getpc_b64 s[0:1]
17 ; GFX11-NEXT: s_add_u32 s0, s0, f1@gotpcrel32@lo+4
18 ; GFX11-NEXT: s_addc_u32 s1, s1, f1@gotpcrel32@hi+12
19 ; GFX11-NEXT: v_writelane_b32 v4, s30, 0
20 ; GFX11-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
21 ; GFX11-NEXT: v_writelane_b32 v4, s31, 1
22 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
23 ; GFX11-NEXT: s_swappc_b64 s[30:31], s[0:1]
24 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
25 ; GFX11-NEXT: v_readlane_b32 s31, v4, 1
26 ; GFX11-NEXT: v_readlane_b32 s30, v4, 0
27 ; GFX11-NEXT: s_xor_saveexec_b32 s0, -1
28 ; GFX11-NEXT: scratch_load_b32 v4, off, s33 ; 4-byte Folded Reload
29 ; GFX11-NEXT: s_mov_b32 exec_lo, s0
30 ; GFX11-NEXT: s_add_i32 s32, s32, -16
31 ; GFX11-NEXT: s_mov_b32 s33, s2
32 ; GFX11-NEXT: s_waitcnt vmcnt(0)
33 ; GFX11-NEXT: s_setpc_b64 s[30:31]
35 %i = call <2 x i64> @f1()
39 define <2 x i64> @f1() #0 {
42 ; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
43 ; GFX11-NEXT: v_mov_b32_e32 v0, 0
44 ; GFX11-NEXT: v_mov_b32_e32 v1, 0
45 ; GFX11-NEXT: v_mov_b32_e32 v2, 0
46 ; GFX11-NEXT: v_mov_b32_e32 v3, 0
47 ; GFX11-NEXT: s_setpc_b64 s[30:31]
48 ret <2 x i64> zeroinitializer
51 ; FIXME: This generates "instid1(/* invalid instid value */)".
52 define amdgpu_kernel void @f2(i32 %arg, i32 %arg1, i32 %arg2, i1 %arg3, i32 %arg4, i1 %arg5, ptr %arg6, i32 %arg7, i32 %arg8, i32 %arg9, i32 %arg10, i1 %arg11) {
54 ; GFX11: ; %bb.0: ; %bb
55 ; GFX11-NEXT: s_mov_b64 s[16:17], s[4:5]
56 ; GFX11-NEXT: v_mov_b32_e32 v31, v0
57 ; GFX11-NEXT: s_load_b32 s24, s[16:17], 0x24
58 ; GFX11-NEXT: s_mov_b32 s12, s13
59 ; GFX11-NEXT: s_mov_b64 s[10:11], s[6:7]
60 ; GFX11-NEXT: s_mov_b64 s[6:7], s[2:3]
61 ; GFX11-NEXT: v_and_b32_e32 v0, 0x3ff, v31
62 ; GFX11-NEXT: s_mov_b64 s[4:5], s[0:1]
63 ; GFX11-NEXT: s_mov_b32 s3, 0
64 ; GFX11-NEXT: s_mov_b32 s0, -1
65 ; GFX11-NEXT: s_mov_b32 s18, exec_lo
66 ; GFX11-NEXT: s_mov_b32 s32, 0
67 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
68 ; GFX11-NEXT: v_mul_lo_u32 v0, s24, v0
69 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
70 ; GFX11-NEXT: v_cmpx_eq_u32_e32 0, v0
71 ; GFX11-NEXT: s_cbranch_execz .LBB2_13
72 ; GFX11-NEXT: ; %bb.1: ; %bb14
73 ; GFX11-NEXT: s_load_b128 s[20:23], s[16:17], 0x2c
74 ; GFX11-NEXT: s_mov_b32 s19, 0
75 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
76 ; GFX11-NEXT: s_bitcmp1_b32 s21, 0
77 ; GFX11-NEXT: s_cselect_b32 s25, -1, 0
78 ; GFX11-NEXT: s_bitcmp0_b32 s21, 0
79 ; GFX11-NEXT: s_cbranch_scc0 .LBB2_3
80 ; GFX11-NEXT: ; %bb.2: ; %bb15
81 ; GFX11-NEXT: s_add_u32 s8, s16, 0x58
82 ; GFX11-NEXT: s_addc_u32 s9, s17, 0
83 ; GFX11-NEXT: s_getpc_b64 s[0:1]
84 ; GFX11-NEXT: s_add_u32 s0, s0, f0@gotpcrel32@lo+4
85 ; GFX11-NEXT: s_addc_u32 s1, s1, f0@gotpcrel32@hi+12
86 ; GFX11-NEXT: s_mov_b32 s13, s14
87 ; GFX11-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
88 ; GFX11-NEXT: s_mov_b32 s3, s14
89 ; GFX11-NEXT: s_mov_b32 s14, s15
90 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
91 ; GFX11-NEXT: s_swappc_b64 s[30:31], s[0:1]
92 ; GFX11-NEXT: s_mov_b32 s14, s3
93 ; GFX11-NEXT: s_mov_b32 s1, -1
94 ; GFX11-NEXT: s_cbranch_execz .LBB2_4
95 ; GFX11-NEXT: s_branch .LBB2_12
96 ; GFX11-NEXT: .LBB2_3:
97 ; GFX11-NEXT: s_mov_b32 s1, 0
98 ; GFX11-NEXT: s_and_not1_b32 vcc_lo, exec_lo, s0
99 ; GFX11-NEXT: s_cbranch_vccnz .LBB2_12
100 ; GFX11-NEXT: .LBB2_4: ; %bb16
101 ; GFX11-NEXT: s_load_b32 s2, s[16:17], 0x54
102 ; GFX11-NEXT: s_bitcmp1_b32 s23, 0
103 ; GFX11-NEXT: s_cselect_b32 s0, -1, 0
104 ; GFX11-NEXT: s_and_b32 s3, s23, 1
105 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
106 ; GFX11-NEXT: s_bitcmp1_b32 s2, 0
107 ; GFX11-NEXT: s_mov_b32 s2, -1
108 ; GFX11-NEXT: s_cselect_b32 s8, -1, 0
109 ; GFX11-NEXT: s_cmp_eq_u32 s3, 0
110 ; GFX11-NEXT: s_cbranch_scc0 .LBB2_8
111 ; GFX11-NEXT: ; %bb.5: ; %bb18.preheader
112 ; GFX11-NEXT: s_load_b128 s[28:31], s[16:17], 0x44
113 ; GFX11-NEXT: v_mov_b32_e32 v2, 0
114 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
115 ; GFX11-NEXT: s_mul_hi_u32 s2, s29, s28
116 ; GFX11-NEXT: s_mul_i32 s3, s29, s28
117 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
118 ; GFX11-NEXT: v_alignbit_b32 v0, s2, s3, 1
119 ; GFX11-NEXT: s_mov_b32 s3, 0
120 ; GFX11-NEXT: v_readfirstlane_b32 s2, v0
121 ; GFX11-NEXT: v_cndmask_b32_e64 v0, 0, 1, s25
122 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
123 ; GFX11-NEXT: s_or_b32 s2, s2, 1
124 ; GFX11-NEXT: s_lshr_b32 s2, s2, s30
125 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
126 ; GFX11-NEXT: s_mul_i32 s2, s2, s22
127 ; GFX11-NEXT: s_mul_i32 s2, s2, s20
128 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
129 ; GFX11-NEXT: s_or_b32 s2, s24, s2
130 ; GFX11-NEXT: s_lshl_b64 s[20:21], s[2:3], 1
131 ; GFX11-NEXT: global_load_u16 v1, v2, s[20:21]
132 ; GFX11-NEXT: s_waitcnt vmcnt(0)
133 ; GFX11-NEXT: v_cmp_eq_u16_e32 vcc_lo, 0, v1
134 ; GFX11-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc_lo
135 ; GFX11-NEXT: .p2align 6
136 ; GFX11-NEXT: .LBB2_6: ; %bb18
137 ; GFX11-NEXT: ; =>This Inner Loop Header: Depth=1
138 ; GFX11-NEXT: v_cmp_ne_u16_e64 s2, s3, 0
139 ; GFX11-NEXT: v_cmp_ne_u16_e32 vcc_lo, 0, v2
140 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_2)
141 ; GFX11-NEXT: v_cndmask_b32_e64 v3, 0, 1, s2
142 ; GFX11-NEXT: v_cndmask_b32_e64 v2, 0, 1, vcc_lo
143 ; GFX11-NEXT: s_and_b32 vcc_lo, s8, vcc_lo
144 ; GFX11-NEXT: v_cndmask_b32_e64 v3, v1, v3, s0
145 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
146 ; GFX11-NEXT: v_cndmask_b32_e32 v2, v0, v2, vcc_lo
147 ; GFX11-NEXT: s_mov_b32 vcc_lo, 0
148 ; GFX11-NEXT: v_readfirstlane_b32 s2, v3
149 ; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
150 ; GFX11-NEXT: v_and_b32_e32 v2, 1, v2
151 ; GFX11-NEXT: s_bitcmp1_b32 s2, 0
152 ; GFX11-NEXT: s_cselect_b32 s2, 0x100, 0
153 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
154 ; GFX11-NEXT: s_or_b32 s3, s2, s3
155 ; GFX11-NEXT: s_cbranch_vccz .LBB2_6
156 ; GFX11-NEXT: ; %bb.7: ; %Flow
157 ; GFX11-NEXT: s_mov_b32 s2, 0
158 ; GFX11-NEXT: .LBB2_8: ; %Flow12
159 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
160 ; GFX11-NEXT: s_and_b32 vcc_lo, exec_lo, s2
161 ; GFX11-NEXT: s_cbranch_vccz .LBB2_12
162 ; GFX11-NEXT: ; %bb.9:
163 ; GFX11-NEXT: s_xor_b32 s0, s8, -1
164 ; GFX11-NEXT: .LBB2_10: ; %bb17
165 ; GFX11-NEXT: ; =>This Inner Loop Header: Depth=1
166 ; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
167 ; GFX11-NEXT: s_and_b32 vcc_lo, exec_lo, s0
168 ; GFX11-NEXT: s_cbranch_vccz .LBB2_10
169 ; GFX11-NEXT: ; %bb.11: ; %Flow6
170 ; GFX11-NEXT: s_mov_b32 s19, -1
171 ; GFX11-NEXT: .LBB2_12: ; %Flow11
172 ; GFX11-NEXT: s_and_b32 s3, s1, exec_lo
173 ; GFX11-NEXT: s_or_not1_b32 s0, s19, exec_lo
174 ; GFX11-NEXT: .LBB2_13: ; %Flow9
175 ; GFX11-NEXT: s_or_b32 exec_lo, exec_lo, s18
176 ; GFX11-NEXT: s_and_saveexec_b32 s18, s0
177 ; GFX11-NEXT: s_cbranch_execz .LBB2_15
178 ; GFX11-NEXT: ; %bb.14: ; %bb43
179 ; GFX11-NEXT: s_add_u32 s8, s16, 0x58
180 ; GFX11-NEXT: s_addc_u32 s9, s17, 0
181 ; GFX11-NEXT: s_getpc_b64 s[0:1]
182 ; GFX11-NEXT: s_add_u32 s0, s0, f0@gotpcrel32@lo+4
183 ; GFX11-NEXT: s_addc_u32 s1, s1, f0@gotpcrel32@hi+12
184 ; GFX11-NEXT: s_mov_b32 s13, s14
185 ; GFX11-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
186 ; GFX11-NEXT: s_mov_b32 s14, s15
187 ; GFX11-NEXT: s_waitcnt lgkmcnt(0)
188 ; GFX11-NEXT: s_swappc_b64 s[30:31], s[0:1]
189 ; GFX11-NEXT: s_or_b32 s3, s3, exec_lo
190 ; GFX11-NEXT: .LBB2_15: ; %Flow14
191 ; GFX11-NEXT: s_or_b32 exec_lo, exec_lo, s18
192 ; GFX11-NEXT: s_and_saveexec_b32 s0, s3
193 ; GFX11-NEXT: ; %bb.16: ; %UnifiedUnreachableBlock
194 ; GFX11-NEXT: ; divergent unreachable
195 ; GFX11-NEXT: ; %bb.17: ; %UnifiedReturnBlock
196 ; GFX11-NEXT: s_endpgm
198 %i = tail call i32 @llvm.amdgcn.workitem.id.x()
199 %i12 = mul i32 %arg, %i
200 %i13 = icmp ult i32 %i12, 1
201 br i1 %i13, label %bb14, label %bb43
204 br i1 %arg3, label %bb16, label %bb15
211 br i1 %arg5, label %bb17, label %bb18
214 br i1 %arg11, label %bb17, label %bb43
217 %i19 = phi i16 [ %i38, %bb18 ], [ 0, %bb16 ]
218 %i20 = phi i16 [ %i42, %bb18 ], [ 0, %bb16 ]
219 %i21 = zext i32 %arg7 to i64
220 %i22 = zext i32 %arg8 to i64
221 %i23 = mul i64 %i22, %i21
222 %i24 = lshr i64 %i23, 1
223 %i25 = trunc i64 %i24 to i32
224 %i26 = or i32 1, %i25
225 %i27 = lshr i32 %i26, %arg9
226 %i28 = mul i32 %i27, %arg4
227 %i29 = mul i32 %i28, %arg2
228 %i30 = or i32 %arg, %i29
229 %i31 = zext i32 %i30 to i64
230 %i32 = getelementptr { [2 x i8] }, ptr addrspace(1) null, i64 %i31
231 %i33 = load i16, ptr addrspace(1) %i32, align 2
232 %i34 = icmp ult i16 %i33, 1
233 %i35 = icmp ne i16 %i19, 0
234 %i36 = select i1 %arg11, i1 %i35, i1 false
235 %i37 = select i1 %i36, i1 %i35, i1 %arg3
236 %i38 = select i1 %i37, i16 1, i16 0
237 %i39 = icmp ne i16 %i20, 0
238 %i40 = select i1 %arg5, i1 %i39, i1 %i34
239 %i41 = select i1 %i40, i16 256, i16 0
240 %i42 = or i16 %i41, %i20
248 attributes #0 = { noinline optnone }