1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 < %s | FileCheck -check-prefix=GFX9 %s
; RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1100 < %s | FileCheck -check-prefix=GFX11 %s
define i16 @v_underflow_compare_fold_i16(i16 %a, i16 %b) #0 {
; GFX9-LABEL: v_underflow_compare_fold_i16:
; GFX9: ; %bb.0:
; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NEXT: v_sub_u16_e32 v1, v0, v1
; GFX9-NEXT: v_min_u16_e32 v0, v1, v0
; GFX9-NEXT: s_setpc_b64 s[30:31]
;
; GFX11-LABEL: v_underflow_compare_fold_i16:
; GFX11: ; %bb.0:
; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX11-NEXT: v_sub_nc_u16 v0.h, v0.l, v1.l
; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
; GFX11-NEXT: v_min_u16 v0.l, v0.h, v0.l
; GFX11-NEXT: s_setpc_b64 s[30:31]
%sub = sub i16 %a, %b
%cond = call i16 @llvm.umin.i16(i16 %sub, i16 %a)
ret i16 %cond
}
define i32 @v_underflow_compare_fold_i32(i32 %a, i32 %b) #0 {
; GFX9-LABEL: v_underflow_compare_fold_i32:
; GFX9: ; %bb.0:
; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NEXT: v_sub_u32_e32 v1, v0, v1
; GFX9-NEXT: v_min_u32_e32 v0, v1, v0
; GFX9-NEXT: s_setpc_b64 s[30:31]
;
; GFX11-LABEL: v_underflow_compare_fold_i32:
; GFX11: ; %bb.0:
; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX11-NEXT: v_sub_nc_u32_e32 v1, v0, v1
; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
; GFX11-NEXT: v_min_u32_e32 v0, v1, v0
; GFX11-NEXT: s_setpc_b64 s[30:31]
%sub = sub i32 %a, %b
%cond = call i32 @llvm.umin.i32(i32 %sub, i32 %a)
ret i32 %cond
}
define i32 @v_underflow_compare_fold_i32_commute(i32 %a, i32 %b) #0 {
; GFX9-LABEL: v_underflow_compare_fold_i32_commute:
; GFX9: ; %bb.0:
; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NEXT: v_sub_u32_e32 v1, v0, v1
; GFX9-NEXT: v_min_u32_e32 v0, v0, v1
; GFX9-NEXT: s_setpc_b64 s[30:31]
;
; GFX11-LABEL: v_underflow_compare_fold_i32_commute:
; GFX11: ; %bb.0:
; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX11-NEXT: v_sub_nc_u32_e32 v1, v0, v1
; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
; GFX11-NEXT: v_min_u32_e32 v0, v0, v1
; GFX11-NEXT: s_setpc_b64 s[30:31]
%sub = sub i32 %a, %b
%cond = call i32 @llvm.umin.i32(i32 %a, i32 %sub)
ret i32 %cond
}
define i32 @v_underflow_compare_fold_i32_multi_use(i32 %a, i32 %b, ptr addrspace(1) %ptr) #0 {
; GFX9-LABEL: v_underflow_compare_fold_i32_multi_use:
; GFX9: ; %bb.0:
; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NEXT: v_sub_u32_e32 v1, v0, v1
; GFX9-NEXT: v_min_u32_e32 v0, v1, v0
; GFX9-NEXT: global_store_dword v[2:3], v1, off
; GFX9-NEXT: s_waitcnt vmcnt(0)
; GFX9-NEXT: s_setpc_b64 s[30:31]
;
; GFX11-LABEL: v_underflow_compare_fold_i32_multi_use:
; GFX11: ; %bb.0:
; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX11-NEXT: v_sub_nc_u32_e32 v1, v0, v1
; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1)
; GFX11-NEXT: v_min_u32_e32 v0, v1, v0
; GFX11-NEXT: global_store_b32 v[2:3], v1, off
; GFX11-NEXT: s_setpc_b64 s[30:31]
%sub = sub i32 %a, %b
store i32 %sub, ptr addrspace(1) %ptr
%cond = call i32 @llvm.umin.i32(i32 %sub, i32 %a)
ret i32 %cond
}
define i64 @v_underflow_compare_fold_i64(i64 %a, i64 %b) #0 {
; GFX9-LABEL: v_underflow_compare_fold_i64:
; GFX9: ; %bb.0:
; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NEXT: v_sub_co_u32_e32 v2, vcc, v0, v2
; GFX9-NEXT: v_subb_co_u32_e32 v3, vcc, v1, v3, vcc
; GFX9-NEXT: v_cmp_lt_u64_e32 vcc, v[2:3], v[0:1]
; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
; GFX9-NEXT: v_cndmask_b32_e32 v1, v1, v3, vcc
; GFX9-NEXT: s_setpc_b64 s[30:31]
;
; GFX11-LABEL: v_underflow_compare_fold_i64:
; GFX11: ; %bb.0:
; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX11-NEXT: v_sub_co_u32 v2, vcc_lo, v0, v2
; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
; GFX11-NEXT: v_sub_co_ci_u32_e64 v3, null, v1, v3, vcc_lo
; GFX11-NEXT: v_cmp_lt_u64_e32 vcc_lo, v[2:3], v[0:1]
; GFX11-NEXT: v_dual_cndmask_b32 v0, v0, v2 :: v_dual_cndmask_b32 v1, v1, v3
; GFX11-NEXT: s_setpc_b64 s[30:31]
%sub = sub i64 %a, %b
%cond = call i64 @llvm.umin.i64(i64 %sub, i64 %a)
ret i64 %cond
}
define i64 @v_underflow_compare_fold_i64_commute(i64 %a, i64 %b) #0 {
; GFX9-LABEL: v_underflow_compare_fold_i64_commute:
; GFX9: ; %bb.0:
; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NEXT: v_sub_co_u32_e32 v2, vcc, v0, v2
; GFX9-NEXT: v_subb_co_u32_e32 v3, vcc, v1, v3, vcc
; GFX9-NEXT: v_cmp_lt_u64_e32 vcc, v[0:1], v[2:3]
; GFX9-NEXT: v_cndmask_b32_e32 v0, v2, v0, vcc
; GFX9-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
; GFX9-NEXT: s_setpc_b64 s[30:31]
;
; GFX11-LABEL: v_underflow_compare_fold_i64_commute:
; GFX11: ; %bb.0:
; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX11-NEXT: v_sub_co_u32 v2, vcc_lo, v0, v2
; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
; GFX11-NEXT: v_sub_co_ci_u32_e64 v3, null, v1, v3, vcc_lo
; GFX11-NEXT: v_cmp_lt_u64_e32 vcc_lo, v[0:1], v[2:3]
; GFX11-NEXT: v_dual_cndmask_b32 v0, v2, v0 :: v_dual_cndmask_b32 v1, v3, v1
; GFX11-NEXT: s_setpc_b64 s[30:31]
%sub = sub i64 %a, %b
%cond = call i64 @llvm.umin.i64(i64 %a, i64 %sub)
ret i64 %cond
}
define i64 @v_underflow_compare_fold_i64_multi_use(i64 %a, i64 %b, ptr addrspace(1) %ptr) #0 {
; GFX9-LABEL: v_underflow_compare_fold_i64_multi_use:
; GFX9: ; %bb.0:
; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX9-NEXT: v_sub_co_u32_e32 v2, vcc, v0, v2
; GFX9-NEXT: v_subb_co_u32_e32 v3, vcc, v1, v3, vcc
; GFX9-NEXT: v_cmp_lt_u64_e32 vcc, v[2:3], v[0:1]
; GFX9-NEXT: global_store_dwordx2 v[4:5], v[2:3], off
; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
; GFX9-NEXT: v_cndmask_b32_e32 v1, v1, v3, vcc
; GFX9-NEXT: s_waitcnt vmcnt(0)
; GFX9-NEXT: s_setpc_b64 s[30:31]
;
; GFX11-LABEL: v_underflow_compare_fold_i64_multi_use:
; GFX11: ; %bb.0:
; GFX11-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GFX11-NEXT: v_sub_co_u32 v2, vcc_lo, v0, v2
; GFX11-NEXT: s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
; GFX11-NEXT: v_sub_co_ci_u32_e64 v3, null, v1, v3, vcc_lo
; GFX11-NEXT: v_cmp_lt_u64_e32 vcc_lo, v[2:3], v[0:1]
; GFX11-NEXT: global_store_b64 v[4:5], v[2:3], off
; GFX11-NEXT: v_dual_cndmask_b32 v0, v0, v2 :: v_dual_cndmask_b32 v1, v1, v3
; GFX11-NEXT: s_setpc_b64 s[30:31]
%sub = sub i64 %a, %b
store i64 %sub, ptr addrspace(1) %ptr
%cond = call i64 @llvm.umin.i64(i64 %sub, i64 %a)
ret i64 %cond
}
define amdgpu_ps i16 @s_underflow_compare_fold_i16(i16 inreg %a, i16 inreg %b) #0 {
; GFX9-LABEL: s_underflow_compare_fold_i16:
; GFX9: ; %bb.0:
; GFX9-NEXT: s_sub_i32 s1, s0, s1
; GFX9-NEXT: s_and_b32 s0, 0xffff, s0
; GFX9-NEXT: s_and_b32 s1, s1, 0xffff
; GFX9-NEXT: s_min_u32 s0, s1, s0
; GFX9-NEXT: ; return to shader part epilog
;
; GFX11-LABEL: s_underflow_compare_fold_i16:
; GFX11: ; %bb.0:
; GFX11-NEXT: s_sub_i32 s1, s0, s1
; GFX11-NEXT: s_and_b32 s0, 0xffff, s0
; GFX11-NEXT: s_and_b32 s1, s1, 0xffff
; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
; GFX11-NEXT: s_min_u32 s0, s1, s0
; GFX11-NEXT: ; return to shader part epilog
%sub = sub i16 %a, %b
%cond = call i16 @llvm.umin.i16(i16 %sub, i16 %a)
ret i16 %cond
}
define amdgpu_ps i32 @s_underflow_compare_fold_i32(i32 inreg %a, i32 inreg %b) #0 {
; GFX9-LABEL: s_underflow_compare_fold_i32:
; GFX9: ; %bb.0:
; GFX9-NEXT: s_sub_i32 s1, s0, s1
; GFX9-NEXT: s_min_u32 s0, s1, s0
; GFX9-NEXT: ; return to shader part epilog
;
; GFX11-LABEL: s_underflow_compare_fold_i32:
; GFX11: ; %bb.0:
; GFX11-NEXT: s_sub_i32 s1, s0, s1
; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
; GFX11-NEXT: s_min_u32 s0, s1, s0
; GFX11-NEXT: ; return to shader part epilog
%sub = sub i32 %a, %b
%cond = call i32 @llvm.umin.i32(i32 %sub, i32 %a)
ret i32 %cond
}
define amdgpu_ps i64 @s_underflow_compare_fold_i64(i64 inreg %a, i64 inreg %b) #0 {
; GFX9-LABEL: s_underflow_compare_fold_i64:
; GFX9: ; %bb.0:
; GFX9-NEXT: s_sub_u32 s2, s0, s2
; GFX9-NEXT: v_mov_b32_e32 v0, s0
; GFX9-NEXT: s_subb_u32 s3, s1, s3
; GFX9-NEXT: v_mov_b32_e32 v1, s1
; GFX9-NEXT: v_cmp_lt_u64_e32 vcc, s[2:3], v[0:1]
; GFX9-NEXT: s_and_b64 s[4:5], vcc, exec
; GFX9-NEXT: s_cselect_b32 s1, s3, s1
; GFX9-NEXT: s_cselect_b32 s0, s2, s0
; GFX9-NEXT: ; return to shader part epilog
;
; GFX11-LABEL: s_underflow_compare_fold_i64:
; GFX11: ; %bb.0:
; GFX11-NEXT: s_sub_u32 s2, s0, s2
; GFX11-NEXT: s_subb_u32 s3, s1, s3
; GFX11-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
; GFX11-NEXT: v_cmp_lt_u64_e64 s4, s[2:3], s[0:1]
; GFX11-NEXT: s_and_b32 s4, s4, exec_lo
; GFX11-NEXT: s_cselect_b32 s0, s2, s0
; GFX11-NEXT: s_cselect_b32 s1, s3, s1
; GFX11-NEXT: ; return to shader part epilog
%sub = sub i64 %a, %b
%cond = call i64 @llvm.umin.i64(i64 %sub, i64 %a)
ret i64 %cond
}
attributes #0 = { nounwind }
|