1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdpal -mcpu=tahiti -o - %s | FileCheck -check-prefix=GFX6 %s
3 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdpal -mcpu=fiji -o - %s | FileCheck -check-prefix=GFX8 %s
4 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdpal -mcpu=gfx900 -o - %s | FileCheck -check-prefix=GFX9 %s
5 ; RUN: llc -global-isel -mtriple=amdgcn-amd-amdpal -mcpu=gfx1010 -o - %s | FileCheck -check-prefix=GFX10 %s
7 define i7 @v_saddsat_i7(i7 %lhs, i7 %rhs) {
8 ; GFX6-LABEL: v_saddsat_i7:
10 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
11 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 25, v0
12 ; GFX6-NEXT: v_min_i32_e32 v3, 0, v0
13 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 25, v1
14 ; GFX6-NEXT: v_max_i32_e32 v2, 0, v0
15 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, 0x80000000, v3
16 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, 0x7fffffff, v2
17 ; GFX6-NEXT: v_max_i32_e32 v1, v3, v1
18 ; GFX6-NEXT: v_min_i32_e32 v1, v1, v2
19 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
20 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 25, v0
21 ; GFX6-NEXT: s_setpc_b64 s[30:31]
23 ; GFX8-LABEL: v_saddsat_i7:
25 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
26 ; GFX8-NEXT: v_lshlrev_b16_e32 v0, 9, v0
27 ; GFX8-NEXT: v_min_i16_e32 v3, 0, v0
28 ; GFX8-NEXT: v_lshlrev_b16_e32 v1, 9, v1
29 ; GFX8-NEXT: v_max_i16_e32 v2, 0, v0
30 ; GFX8-NEXT: v_sub_u16_e32 v3, 0x8000, v3
31 ; GFX8-NEXT: v_sub_u16_e32 v2, 0x7fff, v2
32 ; GFX8-NEXT: v_max_i16_e32 v1, v3, v1
33 ; GFX8-NEXT: v_min_i16_e32 v1, v1, v2
34 ; GFX8-NEXT: v_add_u16_e32 v0, v0, v1
35 ; GFX8-NEXT: v_ashrrev_i16_e32 v0, 9, v0
36 ; GFX8-NEXT: s_setpc_b64 s[30:31]
38 ; GFX9-LABEL: v_saddsat_i7:
40 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
41 ; GFX9-NEXT: v_lshlrev_b16_e32 v0, 9, v0
42 ; GFX9-NEXT: v_lshlrev_b16_e32 v1, 9, v1
43 ; GFX9-NEXT: v_add_i16 v0, v0, v1 clamp
44 ; GFX9-NEXT: v_ashrrev_i16_e32 v0, 9, v0
45 ; GFX9-NEXT: s_setpc_b64 s[30:31]
47 ; GFX10-LABEL: v_saddsat_i7:
49 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
50 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
51 ; GFX10-NEXT: v_lshlrev_b16 v0, 9, v0
52 ; GFX10-NEXT: v_lshlrev_b16 v1, 9, v1
53 ; GFX10-NEXT: v_add_nc_i16 v0, v0, v1 clamp
54 ; GFX10-NEXT: v_ashrrev_i16 v0, 9, v0
55 ; GFX10-NEXT: s_setpc_b64 s[30:31]
56 %result = call i7 @llvm.sadd.sat.i7(i7 %lhs, i7 %rhs)
60 define amdgpu_ps i7 @s_saddsat_i7(i7 inreg %lhs, i7 inreg %rhs) {
61 ; GFX6-LABEL: s_saddsat_i7:
63 ; GFX6-NEXT: s_lshl_b32 s0, s0, 25
64 ; GFX6-NEXT: s_min_i32 s3, s0, 0
65 ; GFX6-NEXT: s_lshl_b32 s1, s1, 25
66 ; GFX6-NEXT: s_max_i32 s2, s0, 0
67 ; GFX6-NEXT: s_sub_i32 s3, 0x80000000, s3
68 ; GFX6-NEXT: s_sub_i32 s2, 0x7fffffff, s2
69 ; GFX6-NEXT: s_max_i32 s1, s3, s1
70 ; GFX6-NEXT: s_min_i32 s1, s1, s2
71 ; GFX6-NEXT: s_add_i32 s0, s0, s1
72 ; GFX6-NEXT: s_ashr_i32 s0, s0, 25
73 ; GFX6-NEXT: ; return to shader part epilog
75 ; GFX8-LABEL: s_saddsat_i7:
77 ; GFX8-NEXT: s_bfe_u32 s2, 9, 0x100000
78 ; GFX8-NEXT: s_lshl_b32 s0, s0, s2
79 ; GFX8-NEXT: s_sext_i32_i16 s3, s0
80 ; GFX8-NEXT: s_sext_i32_i16 s4, 0
81 ; GFX8-NEXT: s_max_i32 s5, s3, s4
82 ; GFX8-NEXT: s_min_i32 s3, s3, s4
83 ; GFX8-NEXT: s_lshl_b32 s1, s1, s2
84 ; GFX8-NEXT: s_sub_i32 s3, 0xffff8000, s3
85 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
86 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
87 ; GFX8-NEXT: s_sub_i32 s5, 0x7fff, s5
88 ; GFX8-NEXT: s_max_i32 s1, s3, s1
89 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
90 ; GFX8-NEXT: s_sext_i32_i16 s3, s5
91 ; GFX8-NEXT: s_min_i32 s1, s1, s3
92 ; GFX8-NEXT: s_add_i32 s0, s0, s1
93 ; GFX8-NEXT: s_sext_i32_i16 s0, s0
94 ; GFX8-NEXT: s_ashr_i32 s0, s0, s2
95 ; GFX8-NEXT: ; return to shader part epilog
97 ; GFX9-LABEL: s_saddsat_i7:
99 ; GFX9-NEXT: s_bfe_u32 s2, 9, 0x100000
100 ; GFX9-NEXT: s_lshl_b32 s1, s1, s2
101 ; GFX9-NEXT: s_lshl_b32 s0, s0, s2
102 ; GFX9-NEXT: v_mov_b32_e32 v0, s1
103 ; GFX9-NEXT: v_add_i16 v0, s0, v0 clamp
104 ; GFX9-NEXT: v_ashrrev_i16_e32 v0, 9, v0
105 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
106 ; GFX9-NEXT: ; return to shader part epilog
108 ; GFX10-LABEL: s_saddsat_i7:
110 ; GFX10-NEXT: s_bfe_u32 s2, 9, 0x100000
111 ; GFX10-NEXT: s_lshl_b32 s0, s0, s2
112 ; GFX10-NEXT: s_lshl_b32 s1, s1, s2
113 ; GFX10-NEXT: v_add_nc_i16 v0, s0, s1 clamp
114 ; GFX10-NEXT: v_ashrrev_i16 v0, 9, v0
115 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
116 ; GFX10-NEXT: ; return to shader part epilog
117 %result = call i7 @llvm.sadd.sat.i7(i7 %lhs, i7 %rhs)
121 define i8 @v_saddsat_i8(i8 %lhs, i8 %rhs) {
122 ; GFX6-LABEL: v_saddsat_i8:
124 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
125 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 24, v0
126 ; GFX6-NEXT: v_min_i32_e32 v3, 0, v0
127 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 24, v1
128 ; GFX6-NEXT: v_max_i32_e32 v2, 0, v0
129 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, 0x80000000, v3
130 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, 0x7fffffff, v2
131 ; GFX6-NEXT: v_max_i32_e32 v1, v3, v1
132 ; GFX6-NEXT: v_min_i32_e32 v1, v1, v2
133 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
134 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 24, v0
135 ; GFX6-NEXT: s_setpc_b64 s[30:31]
137 ; GFX8-LABEL: v_saddsat_i8:
139 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
140 ; GFX8-NEXT: v_lshlrev_b16_e32 v0, 8, v0
141 ; GFX8-NEXT: v_min_i16_e32 v3, 0, v0
142 ; GFX8-NEXT: v_lshlrev_b16_e32 v1, 8, v1
143 ; GFX8-NEXT: v_max_i16_e32 v2, 0, v0
144 ; GFX8-NEXT: v_sub_u16_e32 v3, 0x8000, v3
145 ; GFX8-NEXT: v_sub_u16_e32 v2, 0x7fff, v2
146 ; GFX8-NEXT: v_max_i16_e32 v1, v3, v1
147 ; GFX8-NEXT: v_min_i16_e32 v1, v1, v2
148 ; GFX8-NEXT: v_add_u16_e32 v0, v0, v1
149 ; GFX8-NEXT: v_ashrrev_i16_e32 v0, 8, v0
150 ; GFX8-NEXT: s_setpc_b64 s[30:31]
152 ; GFX9-LABEL: v_saddsat_i8:
154 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
155 ; GFX9-NEXT: v_lshlrev_b16_e32 v0, 8, v0
156 ; GFX9-NEXT: v_lshlrev_b16_e32 v1, 8, v1
157 ; GFX9-NEXT: v_add_i16 v0, v0, v1 clamp
158 ; GFX9-NEXT: v_ashrrev_i16_e32 v0, 8, v0
159 ; GFX9-NEXT: s_setpc_b64 s[30:31]
161 ; GFX10-LABEL: v_saddsat_i8:
163 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
164 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
165 ; GFX10-NEXT: v_lshlrev_b16 v0, 8, v0
166 ; GFX10-NEXT: v_lshlrev_b16 v1, 8, v1
167 ; GFX10-NEXT: v_add_nc_i16 v0, v0, v1 clamp
168 ; GFX10-NEXT: v_ashrrev_i16 v0, 8, v0
169 ; GFX10-NEXT: s_setpc_b64 s[30:31]
170 %result = call i8 @llvm.sadd.sat.i8(i8 %lhs, i8 %rhs)
174 define amdgpu_ps i8 @s_saddsat_i8(i8 inreg %lhs, i8 inreg %rhs) {
175 ; GFX6-LABEL: s_saddsat_i8:
177 ; GFX6-NEXT: s_lshl_b32 s0, s0, 24
178 ; GFX6-NEXT: s_min_i32 s3, s0, 0
179 ; GFX6-NEXT: s_lshl_b32 s1, s1, 24
180 ; GFX6-NEXT: s_max_i32 s2, s0, 0
181 ; GFX6-NEXT: s_sub_i32 s3, 0x80000000, s3
182 ; GFX6-NEXT: s_sub_i32 s2, 0x7fffffff, s2
183 ; GFX6-NEXT: s_max_i32 s1, s3, s1
184 ; GFX6-NEXT: s_min_i32 s1, s1, s2
185 ; GFX6-NEXT: s_add_i32 s0, s0, s1
186 ; GFX6-NEXT: s_ashr_i32 s0, s0, 24
187 ; GFX6-NEXT: ; return to shader part epilog
189 ; GFX8-LABEL: s_saddsat_i8:
191 ; GFX8-NEXT: s_bfe_u32 s2, 8, 0x100000
192 ; GFX8-NEXT: s_lshl_b32 s0, s0, s2
193 ; GFX8-NEXT: s_sext_i32_i16 s3, s0
194 ; GFX8-NEXT: s_sext_i32_i16 s4, 0
195 ; GFX8-NEXT: s_max_i32 s5, s3, s4
196 ; GFX8-NEXT: s_min_i32 s3, s3, s4
197 ; GFX8-NEXT: s_lshl_b32 s1, s1, s2
198 ; GFX8-NEXT: s_sub_i32 s3, 0xffff8000, s3
199 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
200 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
201 ; GFX8-NEXT: s_sub_i32 s5, 0x7fff, s5
202 ; GFX8-NEXT: s_max_i32 s1, s3, s1
203 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
204 ; GFX8-NEXT: s_sext_i32_i16 s3, s5
205 ; GFX8-NEXT: s_min_i32 s1, s1, s3
206 ; GFX8-NEXT: s_add_i32 s0, s0, s1
207 ; GFX8-NEXT: s_sext_i32_i16 s0, s0
208 ; GFX8-NEXT: s_ashr_i32 s0, s0, s2
209 ; GFX8-NEXT: ; return to shader part epilog
211 ; GFX9-LABEL: s_saddsat_i8:
213 ; GFX9-NEXT: s_bfe_u32 s2, 8, 0x100000
214 ; GFX9-NEXT: s_lshl_b32 s1, s1, s2
215 ; GFX9-NEXT: s_lshl_b32 s0, s0, s2
216 ; GFX9-NEXT: v_mov_b32_e32 v0, s1
217 ; GFX9-NEXT: v_add_i16 v0, s0, v0 clamp
218 ; GFX9-NEXT: v_ashrrev_i16_e32 v0, 8, v0
219 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
220 ; GFX9-NEXT: ; return to shader part epilog
222 ; GFX10-LABEL: s_saddsat_i8:
224 ; GFX10-NEXT: s_bfe_u32 s2, 8, 0x100000
225 ; GFX10-NEXT: s_lshl_b32 s0, s0, s2
226 ; GFX10-NEXT: s_lshl_b32 s1, s1, s2
227 ; GFX10-NEXT: v_add_nc_i16 v0, s0, s1 clamp
228 ; GFX10-NEXT: v_ashrrev_i16 v0, 8, v0
229 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
230 ; GFX10-NEXT: ; return to shader part epilog
231 %result = call i8 @llvm.sadd.sat.i8(i8 %lhs, i8 %rhs)
235 define i16 @v_saddsat_v2i8(i16 %lhs.arg, i16 %rhs.arg) {
236 ; GFX6-LABEL: v_saddsat_v2i8:
238 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
239 ; GFX6-NEXT: v_lshrrev_b32_e32 v2, 8, v0
240 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 24, v0
241 ; GFX6-NEXT: s_brev_b32 s5, 1
242 ; GFX6-NEXT: v_min_i32_e32 v5, 0, v0
243 ; GFX6-NEXT: v_lshrrev_b32_e32 v3, 8, v1
244 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 24, v1
245 ; GFX6-NEXT: s_brev_b32 s4, -2
246 ; GFX6-NEXT: v_max_i32_e32 v4, 0, v0
247 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, s5, v5
248 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s4, v4
249 ; GFX6-NEXT: v_max_i32_e32 v1, v5, v1
250 ; GFX6-NEXT: v_min_i32_e32 v1, v1, v4
251 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
252 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 24, v2
253 ; GFX6-NEXT: v_min_i32_e32 v4, 0, v1
254 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 24, v3
255 ; GFX6-NEXT: v_max_i32_e32 v3, 0, v1
256 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s5, v4
257 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, s4, v3
258 ; GFX6-NEXT: v_max_i32_e32 v2, v4, v2
259 ; GFX6-NEXT: v_min_i32_e32 v2, v2, v3
260 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v2
261 ; GFX6-NEXT: v_ashrrev_i32_e32 v1, 24, v1
262 ; GFX6-NEXT: v_mov_b32_e32 v2, 0xff
263 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 24, v0
264 ; GFX6-NEXT: v_and_b32_e32 v1, v1, v2
265 ; GFX6-NEXT: v_and_b32_e32 v0, v0, v2
266 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 8, v1
267 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
268 ; GFX6-NEXT: s_setpc_b64 s[30:31]
270 ; GFX8-LABEL: v_saddsat_v2i8:
272 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
273 ; GFX8-NEXT: v_mov_b32_e32 v2, 8
274 ; GFX8-NEXT: v_lshrrev_b32_sdwa v3, v2, v0 dst_sel:BYTE_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
275 ; GFX8-NEXT: v_lshlrev_b16_e32 v0, 8, v0
276 ; GFX8-NEXT: s_movk_i32 s5, 0x8000
277 ; GFX8-NEXT: v_min_i16_e32 v5, 0, v0
278 ; GFX8-NEXT: v_lshrrev_b32_sdwa v2, v2, v1 dst_sel:BYTE_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
279 ; GFX8-NEXT: v_lshlrev_b16_e32 v1, 8, v1
280 ; GFX8-NEXT: s_movk_i32 s4, 0x7fff
281 ; GFX8-NEXT: v_max_i16_e32 v4, 0, v0
282 ; GFX8-NEXT: v_sub_u16_e32 v5, s5, v5
283 ; GFX8-NEXT: v_sub_u16_e32 v4, s4, v4
284 ; GFX8-NEXT: v_max_i16_e32 v1, v5, v1
285 ; GFX8-NEXT: v_min_i16_e32 v1, v1, v4
286 ; GFX8-NEXT: v_min_i16_e32 v4, 0, v3
287 ; GFX8-NEXT: v_add_u16_e32 v0, v0, v1
288 ; GFX8-NEXT: v_max_i16_e32 v1, 0, v3
289 ; GFX8-NEXT: v_sub_u16_e32 v4, s5, v4
290 ; GFX8-NEXT: v_sub_u16_e32 v1, s4, v1
291 ; GFX8-NEXT: v_max_i16_e32 v2, v4, v2
292 ; GFX8-NEXT: v_min_i16_e32 v1, v2, v1
293 ; GFX8-NEXT: v_add_u16_e32 v1, v3, v1
294 ; GFX8-NEXT: v_mov_b32_e32 v2, 0xff
295 ; GFX8-NEXT: v_and_b32_sdwa v0, sext(v0), v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_1 src1_sel:DWORD
296 ; GFX8-NEXT: v_and_b32_sdwa v1, sext(v1), v2 dst_sel:BYTE_1 dst_unused:UNUSED_PAD src0_sel:BYTE_1 src1_sel:DWORD
297 ; GFX8-NEXT: v_or_b32_e32 v0, v0, v1
298 ; GFX8-NEXT: s_setpc_b64 s[30:31]
300 ; GFX9-LABEL: v_saddsat_v2i8:
302 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
303 ; GFX9-NEXT: s_mov_b32 s4, 8
304 ; GFX9-NEXT: v_lshrrev_b32_sdwa v2, s4, v0 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
305 ; GFX9-NEXT: v_lshrrev_b32_sdwa v3, s4, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
306 ; GFX9-NEXT: v_mov_b32_e32 v4, 0xffff
307 ; GFX9-NEXT: v_and_or_b32 v0, v0, v4, v2
308 ; GFX9-NEXT: v_and_or_b32 v1, v1, v4, v3
309 ; GFX9-NEXT: v_pk_lshlrev_b16 v0, 8, v0 op_sel_hi:[0,1]
310 ; GFX9-NEXT: v_pk_lshlrev_b16 v1, 8, v1 op_sel_hi:[0,1]
311 ; GFX9-NEXT: v_pk_add_i16 v0, v0, v1 clamp
312 ; GFX9-NEXT: v_pk_ashrrev_i16 v0, 8, v0 op_sel_hi:[0,1]
313 ; GFX9-NEXT: s_movk_i32 s4, 0xff
314 ; GFX9-NEXT: v_and_b32_sdwa v1, v0, s4 dst_sel:BYTE_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD
315 ; GFX9-NEXT: v_or_b32_sdwa v0, v0, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_0 src1_sel:DWORD
316 ; GFX9-NEXT: s_setpc_b64 s[30:31]
318 ; GFX10-LABEL: v_saddsat_v2i8:
320 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
321 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
322 ; GFX10-NEXT: s_mov_b32 s4, 8
323 ; GFX10-NEXT: v_mov_b32_e32 v2, 0xffff
324 ; GFX10-NEXT: v_lshrrev_b32_sdwa v3, s4, v0 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
325 ; GFX10-NEXT: v_lshrrev_b32_sdwa v4, s4, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
326 ; GFX10-NEXT: s_movk_i32 s4, 0xff
327 ; GFX10-NEXT: v_and_or_b32 v0, v0, v2, v3
328 ; GFX10-NEXT: v_and_or_b32 v1, v1, v2, v4
329 ; GFX10-NEXT: v_pk_lshlrev_b16 v0, 8, v0 op_sel_hi:[0,1]
330 ; GFX10-NEXT: v_pk_lshlrev_b16 v1, 8, v1 op_sel_hi:[0,1]
331 ; GFX10-NEXT: v_pk_add_i16 v0, v0, v1 clamp
332 ; GFX10-NEXT: v_pk_ashrrev_i16 v0, 8, v0 op_sel_hi:[0,1]
333 ; GFX10-NEXT: v_and_b32_sdwa v1, v0, s4 dst_sel:BYTE_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD
334 ; GFX10-NEXT: v_or_b32_sdwa v0, v0, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_0 src1_sel:DWORD
335 ; GFX10-NEXT: s_setpc_b64 s[30:31]
336 %lhs = bitcast i16 %lhs.arg to <2 x i8>
337 %rhs = bitcast i16 %rhs.arg to <2 x i8>
338 %result = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %lhs, <2 x i8> %rhs)
339 %cast.result = bitcast <2 x i8> %result to i16
343 define amdgpu_ps i16 @s_saddsat_v2i8(i16 inreg %lhs.arg, i16 inreg %rhs.arg) {
344 ; GFX6-LABEL: s_saddsat_v2i8:
346 ; GFX6-NEXT: s_lshr_b32 s2, s0, 8
347 ; GFX6-NEXT: s_lshl_b32 s0, s0, 24
348 ; GFX6-NEXT: s_brev_b32 s5, 1
349 ; GFX6-NEXT: s_min_i32 s7, s0, 0
350 ; GFX6-NEXT: s_lshr_b32 s3, s1, 8
351 ; GFX6-NEXT: s_lshl_b32 s1, s1, 24
352 ; GFX6-NEXT: s_brev_b32 s4, -2
353 ; GFX6-NEXT: s_max_i32 s6, s0, 0
354 ; GFX6-NEXT: s_sub_i32 s7, s5, s7
355 ; GFX6-NEXT: s_sub_i32 s6, s4, s6
356 ; GFX6-NEXT: s_max_i32 s1, s7, s1
357 ; GFX6-NEXT: s_min_i32 s1, s1, s6
358 ; GFX6-NEXT: s_add_i32 s0, s0, s1
359 ; GFX6-NEXT: s_lshl_b32 s1, s2, 24
360 ; GFX6-NEXT: s_lshl_b32 s2, s3, 24
361 ; GFX6-NEXT: s_max_i32 s3, s1, 0
362 ; GFX6-NEXT: s_sub_i32 s3, s4, s3
363 ; GFX6-NEXT: s_min_i32 s4, s1, 0
364 ; GFX6-NEXT: s_sub_i32 s4, s5, s4
365 ; GFX6-NEXT: s_max_i32 s2, s4, s2
366 ; GFX6-NEXT: s_min_i32 s2, s2, s3
367 ; GFX6-NEXT: s_add_i32 s1, s1, s2
368 ; GFX6-NEXT: s_ashr_i32 s1, s1, 24
369 ; GFX6-NEXT: s_movk_i32 s2, 0xff
370 ; GFX6-NEXT: s_ashr_i32 s0, s0, 24
371 ; GFX6-NEXT: s_and_b32 s1, s1, s2
372 ; GFX6-NEXT: s_and_b32 s0, s0, s2
373 ; GFX6-NEXT: s_lshl_b32 s1, s1, 8
374 ; GFX6-NEXT: s_or_b32 s0, s0, s1
375 ; GFX6-NEXT: ; return to shader part epilog
377 ; GFX8-LABEL: s_saddsat_v2i8:
379 ; GFX8-NEXT: s_bfe_u32 s4, 8, 0x100000
380 ; GFX8-NEXT: s_lshr_b32 s2, s0, 8
381 ; GFX8-NEXT: s_lshl_b32 s0, s0, s4
382 ; GFX8-NEXT: s_sext_i32_i16 s7, s0
383 ; GFX8-NEXT: s_sext_i32_i16 s8, 0
384 ; GFX8-NEXT: s_movk_i32 s6, 0x8000
385 ; GFX8-NEXT: s_max_i32 s9, s7, s8
386 ; GFX8-NEXT: s_min_i32 s7, s7, s8
387 ; GFX8-NEXT: s_lshr_b32 s3, s1, 8
388 ; GFX8-NEXT: s_lshl_b32 s1, s1, s4
389 ; GFX8-NEXT: s_sub_i32 s7, s6, s7
390 ; GFX8-NEXT: s_movk_i32 s5, 0x7fff
391 ; GFX8-NEXT: s_sext_i32_i16 s7, s7
392 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
393 ; GFX8-NEXT: s_sub_i32 s9, s5, s9
394 ; GFX8-NEXT: s_max_i32 s1, s7, s1
395 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
396 ; GFX8-NEXT: s_sext_i32_i16 s7, s9
397 ; GFX8-NEXT: s_min_i32 s1, s1, s7
398 ; GFX8-NEXT: s_add_i32 s0, s0, s1
399 ; GFX8-NEXT: s_lshl_b32 s1, s2, s4
400 ; GFX8-NEXT: s_lshl_b32 s2, s3, s4
401 ; GFX8-NEXT: s_sext_i32_i16 s3, s1
402 ; GFX8-NEXT: s_max_i32 s7, s3, s8
403 ; GFX8-NEXT: s_min_i32 s3, s3, s8
404 ; GFX8-NEXT: s_sub_i32 s3, s6, s3
405 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
406 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
407 ; GFX8-NEXT: s_sub_i32 s5, s5, s7
408 ; GFX8-NEXT: s_max_i32 s2, s3, s2
409 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
410 ; GFX8-NEXT: s_sext_i32_i16 s3, s5
411 ; GFX8-NEXT: s_min_i32 s2, s2, s3
412 ; GFX8-NEXT: s_add_i32 s1, s1, s2
413 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
414 ; GFX8-NEXT: s_sext_i32_i16 s0, s0
415 ; GFX8-NEXT: s_ashr_i32 s1, s1, s4
416 ; GFX8-NEXT: s_movk_i32 s2, 0xff
417 ; GFX8-NEXT: s_ashr_i32 s0, s0, s4
418 ; GFX8-NEXT: s_and_b32 s1, s1, s2
419 ; GFX8-NEXT: s_and_b32 s0, s0, s2
420 ; GFX8-NEXT: s_lshl_b32 s1, s1, s4
421 ; GFX8-NEXT: s_or_b32 s0, s0, s1
422 ; GFX8-NEXT: ; return to shader part epilog
424 ; GFX9-LABEL: s_saddsat_v2i8:
426 ; GFX9-NEXT: s_lshr_b32 s2, s0, 8
427 ; GFX9-NEXT: s_lshr_b32 s3, s1, 8
428 ; GFX9-NEXT: s_pack_ll_b32_b16 s0, s0, s2
429 ; GFX9-NEXT: s_pack_ll_b32_b16 s1, s1, s3
430 ; GFX9-NEXT: s_mov_b32 s2, 0x80008
431 ; GFX9-NEXT: s_lshr_b32 s3, s0, 16
432 ; GFX9-NEXT: s_lshl_b32 s0, s0, s2
433 ; GFX9-NEXT: s_lshl_b32 s3, s3, 8
434 ; GFX9-NEXT: s_pack_ll_b32_b16 s0, s0, s3
435 ; GFX9-NEXT: s_lshr_b32 s3, s1, 16
436 ; GFX9-NEXT: s_lshl_b32 s1, s1, s2
437 ; GFX9-NEXT: s_lshl_b32 s2, s3, 8
438 ; GFX9-NEXT: s_pack_ll_b32_b16 s1, s1, s2
439 ; GFX9-NEXT: v_mov_b32_e32 v0, s1
440 ; GFX9-NEXT: v_pk_add_i16 v0, s0, v0 clamp
441 ; GFX9-NEXT: v_pk_ashrrev_i16 v0, 8, v0 op_sel_hi:[0,1]
442 ; GFX9-NEXT: s_movk_i32 s0, 0xff
443 ; GFX9-NEXT: v_and_b32_sdwa v1, v0, s0 dst_sel:BYTE_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD
444 ; GFX9-NEXT: v_or_b32_sdwa v0, v0, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_0 src1_sel:DWORD
445 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
446 ; GFX9-NEXT: ; return to shader part epilog
448 ; GFX10-LABEL: s_saddsat_v2i8:
450 ; GFX10-NEXT: s_lshr_b32 s2, s0, 8
451 ; GFX10-NEXT: s_lshr_b32 s3, s1, 8
452 ; GFX10-NEXT: s_pack_ll_b32_b16 s0, s0, s2
453 ; GFX10-NEXT: s_pack_ll_b32_b16 s1, s1, s3
454 ; GFX10-NEXT: s_mov_b32 s2, 0x80008
455 ; GFX10-NEXT: s_lshr_b32 s3, s0, 16
456 ; GFX10-NEXT: s_lshr_b32 s4, s1, 16
457 ; GFX10-NEXT: s_lshl_b32 s0, s0, s2
458 ; GFX10-NEXT: s_lshl_b32 s3, s3, 8
459 ; GFX10-NEXT: s_lshl_b32 s1, s1, s2
460 ; GFX10-NEXT: s_lshl_b32 s2, s4, 8
461 ; GFX10-NEXT: s_pack_ll_b32_b16 s0, s0, s3
462 ; GFX10-NEXT: s_pack_ll_b32_b16 s1, s1, s2
463 ; GFX10-NEXT: v_pk_add_i16 v0, s0, s1 clamp
464 ; GFX10-NEXT: s_movk_i32 s0, 0xff
465 ; GFX10-NEXT: v_pk_ashrrev_i16 v0, 8, v0 op_sel_hi:[0,1]
466 ; GFX10-NEXT: v_and_b32_sdwa v1, v0, s0 dst_sel:BYTE_1 dst_unused:UNUSED_PAD src0_sel:WORD_1 src1_sel:DWORD
467 ; GFX10-NEXT: v_or_b32_sdwa v0, v0, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_0 src1_sel:DWORD
468 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
469 ; GFX10-NEXT: ; return to shader part epilog
470 %lhs = bitcast i16 %lhs.arg to <2 x i8>
471 %rhs = bitcast i16 %rhs.arg to <2 x i8>
472 %result = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %lhs, <2 x i8> %rhs)
473 %cast.result = bitcast <2 x i8> %result to i16
477 define i32 @v_saddsat_v4i8(i32 %lhs.arg, i32 %rhs.arg) {
478 ; GFX6-LABEL: v_saddsat_v4i8:
480 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
481 ; GFX6-NEXT: v_lshrrev_b32_e32 v2, 8, v0
482 ; GFX6-NEXT: v_lshrrev_b32_e32 v3, 16, v0
483 ; GFX6-NEXT: v_lshrrev_b32_e32 v4, 24, v0
484 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 24, v0
485 ; GFX6-NEXT: s_brev_b32 s5, 1
486 ; GFX6-NEXT: v_min_i32_e32 v10, 0, v0
487 ; GFX6-NEXT: v_lshrrev_b32_e32 v5, 8, v1
488 ; GFX6-NEXT: v_lshrrev_b32_e32 v6, 16, v1
489 ; GFX6-NEXT: v_lshrrev_b32_e32 v7, 24, v1
490 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 24, v1
491 ; GFX6-NEXT: s_brev_b32 s4, -2
492 ; GFX6-NEXT: v_max_i32_e32 v8, 0, v0
493 ; GFX6-NEXT: v_sub_i32_e32 v10, vcc, s5, v10
494 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, s4, v8
495 ; GFX6-NEXT: v_max_i32_e32 v1, v10, v1
496 ; GFX6-NEXT: v_min_i32_e32 v1, v1, v8
497 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
498 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 24, v2
499 ; GFX6-NEXT: v_min_i32_e32 v8, 0, v1
500 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 24, v5
501 ; GFX6-NEXT: v_max_i32_e32 v5, 0, v1
502 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, s5, v8
503 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, s4, v5
504 ; GFX6-NEXT: v_max_i32_e32 v2, v8, v2
505 ; GFX6-NEXT: v_min_i32_e32 v2, v2, v5
506 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v2
507 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 24, v3
508 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 24, v6
509 ; GFX6-NEXT: v_min_i32_e32 v6, 0, v2
510 ; GFX6-NEXT: v_bfrev_b32_e32 v9, -2
511 ; GFX6-NEXT: v_max_i32_e32 v5, 0, v2
512 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, s5, v6
513 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, v9, v5
514 ; GFX6-NEXT: v_max_i32_e32 v3, v6, v3
515 ; GFX6-NEXT: v_min_i32_e32 v3, v3, v5
516 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
517 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 24, v4
518 ; GFX6-NEXT: v_bfrev_b32_e32 v11, 1
519 ; GFX6-NEXT: v_min_i32_e32 v6, 0, v3
520 ; GFX6-NEXT: v_ashrrev_i32_e32 v1, 24, v1
521 ; GFX6-NEXT: v_lshlrev_b32_e32 v4, 24, v7
522 ; GFX6-NEXT: v_max_i32_e32 v5, 0, v3
523 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, v11, v6
524 ; GFX6-NEXT: s_movk_i32 s4, 0xff
525 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 24, v0
526 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, v9, v5
527 ; GFX6-NEXT: v_max_i32_e32 v4, v6, v4
528 ; GFX6-NEXT: v_and_b32_e32 v1, s4, v1
529 ; GFX6-NEXT: v_ashrrev_i32_e32 v2, 24, v2
530 ; GFX6-NEXT: v_min_i32_e32 v4, v4, v5
531 ; GFX6-NEXT: v_and_b32_e32 v0, s4, v0
532 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 8, v1
533 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v4
534 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
535 ; GFX6-NEXT: v_and_b32_e32 v1, s4, v2
536 ; GFX6-NEXT: v_ashrrev_i32_e32 v3, 24, v3
537 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
538 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
539 ; GFX6-NEXT: v_and_b32_e32 v1, s4, v3
540 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 24, v1
541 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
542 ; GFX6-NEXT: s_setpc_b64 s[30:31]
544 ; GFX8-LABEL: v_saddsat_v4i8:
546 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
547 ; GFX8-NEXT: v_mov_b32_e32 v2, 8
548 ; GFX8-NEXT: v_lshrrev_b32_sdwa v3, v2, v0 dst_sel:BYTE_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
549 ; GFX8-NEXT: v_lshrrev_b32_e32 v4, 16, v0
550 ; GFX8-NEXT: v_lshrrev_b32_e32 v5, 24, v0
551 ; GFX8-NEXT: v_lshlrev_b16_e32 v0, 8, v0
552 ; GFX8-NEXT: s_movk_i32 s5, 0x8000
553 ; GFX8-NEXT: v_min_i16_e32 v10, 0, v0
554 ; GFX8-NEXT: v_lshrrev_b32_sdwa v2, v2, v1 dst_sel:BYTE_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
555 ; GFX8-NEXT: v_lshrrev_b32_e32 v6, 16, v1
556 ; GFX8-NEXT: v_lshrrev_b32_e32 v7, 24, v1
557 ; GFX8-NEXT: v_lshlrev_b16_e32 v1, 8, v1
558 ; GFX8-NEXT: s_movk_i32 s4, 0x7fff
559 ; GFX8-NEXT: v_max_i16_e32 v8, 0, v0
560 ; GFX8-NEXT: v_sub_u16_e32 v10, s5, v10
561 ; GFX8-NEXT: v_sub_u16_e32 v8, s4, v8
562 ; GFX8-NEXT: v_max_i16_e32 v1, v10, v1
563 ; GFX8-NEXT: v_min_i16_e32 v1, v1, v8
564 ; GFX8-NEXT: v_min_i16_e32 v8, 0, v3
565 ; GFX8-NEXT: v_add_u16_e32 v0, v0, v1
566 ; GFX8-NEXT: v_max_i16_e32 v1, 0, v3
567 ; GFX8-NEXT: v_sub_u16_e32 v8, s5, v8
568 ; GFX8-NEXT: v_sub_u16_e32 v1, s4, v1
569 ; GFX8-NEXT: v_max_i16_e32 v2, v8, v2
570 ; GFX8-NEXT: v_min_i16_e32 v1, v2, v1
571 ; GFX8-NEXT: v_lshlrev_b16_e32 v2, 8, v4
572 ; GFX8-NEXT: v_add_u16_e32 v1, v3, v1
573 ; GFX8-NEXT: v_lshlrev_b16_e32 v3, 8, v6
574 ; GFX8-NEXT: v_min_i16_e32 v6, 0, v2
575 ; GFX8-NEXT: v_mov_b32_e32 v9, 0x7fff
576 ; GFX8-NEXT: v_max_i16_e32 v4, 0, v2
577 ; GFX8-NEXT: v_sub_u16_e32 v6, s5, v6
578 ; GFX8-NEXT: v_sub_u16_e32 v4, v9, v4
579 ; GFX8-NEXT: v_max_i16_e32 v3, v6, v3
580 ; GFX8-NEXT: v_min_i16_e32 v3, v3, v4
581 ; GFX8-NEXT: v_add_u16_e32 v2, v2, v3
582 ; GFX8-NEXT: v_lshlrev_b16_e32 v3, 8, v5
583 ; GFX8-NEXT: v_min_i16_e32 v6, 0, v3
584 ; GFX8-NEXT: v_lshlrev_b16_e32 v4, 8, v7
585 ; GFX8-NEXT: v_max_i16_e32 v5, 0, v3
586 ; GFX8-NEXT: v_sub_u16_e32 v6, 0x8000, v6
587 ; GFX8-NEXT: v_sub_u16_e32 v5, v9, v5
588 ; GFX8-NEXT: v_max_i16_e32 v4, v6, v4
589 ; GFX8-NEXT: v_min_i16_e32 v4, v4, v5
590 ; GFX8-NEXT: v_add_u16_e32 v3, v3, v4
591 ; GFX8-NEXT: v_mov_b32_e32 v4, 0xff
592 ; GFX8-NEXT: v_and_b32_sdwa v1, sext(v1), v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_1 src1_sel:DWORD
593 ; GFX8-NEXT: v_and_b32_sdwa v0, sext(v0), v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:BYTE_1 src1_sel:DWORD
594 ; GFX8-NEXT: v_lshlrev_b32_e32 v1, 8, v1
595 ; GFX8-NEXT: v_or_b32_e32 v0, v0, v1
596 ; GFX8-NEXT: v_and_b32_sdwa v1, sext(v2), v4 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:BYTE_1 src1_sel:DWORD
597 ; GFX8-NEXT: v_or_b32_e32 v0, v0, v1
598 ; GFX8-NEXT: v_and_b32_sdwa v1, sext(v3), v4 dst_sel:BYTE_3 dst_unused:UNUSED_PAD src0_sel:BYTE_1 src1_sel:DWORD
599 ; GFX8-NEXT: v_or_b32_e32 v0, v0, v1
600 ; GFX8-NEXT: s_setpc_b64 s[30:31]
602 ; GFX9-LABEL: v_saddsat_v4i8:
604 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
605 ; GFX9-NEXT: s_mov_b32 s4, 8
606 ; GFX9-NEXT: v_lshrrev_b32_sdwa v2, s4, v0 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
607 ; GFX9-NEXT: v_lshrrev_b32_e32 v4, 24, v0
608 ; GFX9-NEXT: v_mov_b32_e32 v8, 0xffff
609 ; GFX9-NEXT: v_lshrrev_b32_e32 v3, 16, v0
610 ; GFX9-NEXT: v_lshrrev_b32_sdwa v5, s4, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
611 ; GFX9-NEXT: v_lshrrev_b32_e32 v7, 24, v1
612 ; GFX9-NEXT: v_and_or_b32 v0, v0, v8, v2
613 ; GFX9-NEXT: v_lshlrev_b32_e32 v2, 16, v4
614 ; GFX9-NEXT: v_lshrrev_b32_e32 v6, 16, v1
615 ; GFX9-NEXT: v_and_or_b32 v2, v3, v8, v2
616 ; GFX9-NEXT: v_and_or_b32 v1, v1, v8, v5
617 ; GFX9-NEXT: v_lshlrev_b32_e32 v3, 16, v7
618 ; GFX9-NEXT: v_pk_lshlrev_b16 v0, 8, v0 op_sel_hi:[0,1]
619 ; GFX9-NEXT: v_and_or_b32 v3, v6, v8, v3
620 ; GFX9-NEXT: v_pk_lshlrev_b16 v1, 8, v1 op_sel_hi:[0,1]
621 ; GFX9-NEXT: v_pk_lshlrev_b16 v2, 8, v2 op_sel_hi:[0,1]
622 ; GFX9-NEXT: v_pk_lshlrev_b16 v3, 8, v3 op_sel_hi:[0,1]
623 ; GFX9-NEXT: v_pk_add_i16 v0, v0, v1 clamp
624 ; GFX9-NEXT: v_pk_add_i16 v1, v2, v3 clamp
625 ; GFX9-NEXT: v_pk_ashrrev_i16 v0, 8, v0 op_sel_hi:[0,1]
626 ; GFX9-NEXT: v_mov_b32_e32 v2, 8
627 ; GFX9-NEXT: v_pk_ashrrev_i16 v1, 8, v1 op_sel_hi:[0,1]
628 ; GFX9-NEXT: s_movk_i32 s4, 0xff
629 ; GFX9-NEXT: v_lshlrev_b32_sdwa v2, v2, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:BYTE_2
630 ; GFX9-NEXT: v_and_or_b32 v0, v0, s4, v2
631 ; GFX9-NEXT: v_and_b32_e32 v2, s4, v1
632 ; GFX9-NEXT: v_mov_b32_e32 v3, 24
633 ; GFX9-NEXT: v_lshlrev_b32_e32 v2, 16, v2
634 ; GFX9-NEXT: v_lshlrev_b32_sdwa v1, v3, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:BYTE_2
635 ; GFX9-NEXT: v_or3_b32 v0, v0, v2, v1
636 ; GFX9-NEXT: s_setpc_b64 s[30:31]
638 ; GFX10-LABEL: v_saddsat_v4i8:
640 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
641 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
642 ; GFX10-NEXT: v_lshrrev_b32_e32 v4, 24, v0
643 ; GFX10-NEXT: v_lshrrev_b32_e32 v5, 24, v1
644 ; GFX10-NEXT: s_mov_b32 s4, 8
645 ; GFX10-NEXT: v_lshrrev_b32_e32 v3, 16, v0
646 ; GFX10-NEXT: v_lshrrev_b32_sdwa v2, s4, v0 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
647 ; GFX10-NEXT: v_lshrrev_b32_sdwa v6, s4, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
648 ; GFX10-NEXT: v_mov_b32_e32 v7, 0xffff
649 ; GFX10-NEXT: v_lshrrev_b32_e32 v8, 16, v1
650 ; GFX10-NEXT: v_lshlrev_b32_e32 v4, 16, v4
651 ; GFX10-NEXT: v_lshlrev_b32_e32 v5, 16, v5
652 ; GFX10-NEXT: s_movk_i32 s4, 0xff
653 ; GFX10-NEXT: v_and_or_b32 v0, v0, v7, v2
654 ; GFX10-NEXT: v_and_or_b32 v1, v1, v7, v6
655 ; GFX10-NEXT: v_and_or_b32 v2, v3, v7, v4
656 ; GFX10-NEXT: v_and_or_b32 v3, v8, v7, v5
657 ; GFX10-NEXT: v_mov_b32_e32 v4, 24
658 ; GFX10-NEXT: v_pk_lshlrev_b16 v0, 8, v0 op_sel_hi:[0,1]
659 ; GFX10-NEXT: v_pk_lshlrev_b16 v1, 8, v1 op_sel_hi:[0,1]
660 ; GFX10-NEXT: v_pk_lshlrev_b16 v2, 8, v2 op_sel_hi:[0,1]
661 ; GFX10-NEXT: v_pk_lshlrev_b16 v3, 8, v3 op_sel_hi:[0,1]
662 ; GFX10-NEXT: v_pk_add_i16 v0, v0, v1 clamp
663 ; GFX10-NEXT: v_pk_add_i16 v1, v2, v3 clamp
664 ; GFX10-NEXT: v_mov_b32_e32 v2, 8
665 ; GFX10-NEXT: v_pk_ashrrev_i16 v0, 8, v0 op_sel_hi:[0,1]
666 ; GFX10-NEXT: v_pk_ashrrev_i16 v1, 8, v1 op_sel_hi:[0,1]
667 ; GFX10-NEXT: v_lshlrev_b32_sdwa v2, v2, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:BYTE_2
668 ; GFX10-NEXT: v_and_b32_e32 v3, s4, v1
669 ; GFX10-NEXT: v_lshlrev_b32_sdwa v1, v4, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:BYTE_2
670 ; GFX10-NEXT: v_and_or_b32 v0, v0, s4, v2
671 ; GFX10-NEXT: v_lshlrev_b32_e32 v2, 16, v3
672 ; GFX10-NEXT: v_or3_b32 v0, v0, v2, v1
673 ; GFX10-NEXT: s_setpc_b64 s[30:31]
674 %lhs = bitcast i32 %lhs.arg to <4 x i8>
675 %rhs = bitcast i32 %rhs.arg to <4 x i8>
676 %result = call <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8> %lhs, <4 x i8> %rhs)
677 %cast.result = bitcast <4 x i8> %result to i32
681 define amdgpu_ps i32 @s_saddsat_v4i8(i32 inreg %lhs.arg, i32 inreg %rhs.arg) {
682 ; GFX6-LABEL: s_saddsat_v4i8:
684 ; GFX6-NEXT: s_lshr_b32 s2, s0, 8
685 ; GFX6-NEXT: s_lshr_b32 s3, s0, 16
686 ; GFX6-NEXT: s_lshr_b32 s4, s0, 24
687 ; GFX6-NEXT: s_lshl_b32 s0, s0, 24
688 ; GFX6-NEXT: s_brev_b32 s9, 1
689 ; GFX6-NEXT: s_min_i32 s11, s0, 0
690 ; GFX6-NEXT: s_lshr_b32 s5, s1, 8
691 ; GFX6-NEXT: s_lshr_b32 s6, s1, 16
692 ; GFX6-NEXT: s_lshr_b32 s7, s1, 24
693 ; GFX6-NEXT: s_lshl_b32 s1, s1, 24
694 ; GFX6-NEXT: s_brev_b32 s8, -2
695 ; GFX6-NEXT: s_max_i32 s10, s0, 0
696 ; GFX6-NEXT: s_sub_i32 s11, s9, s11
697 ; GFX6-NEXT: s_sub_i32 s10, s8, s10
698 ; GFX6-NEXT: s_max_i32 s1, s11, s1
699 ; GFX6-NEXT: s_min_i32 s1, s1, s10
700 ; GFX6-NEXT: s_add_i32 s0, s0, s1
701 ; GFX6-NEXT: s_lshl_b32 s1, s2, 24
702 ; GFX6-NEXT: s_min_i32 s10, s1, 0
703 ; GFX6-NEXT: s_lshl_b32 s2, s5, 24
704 ; GFX6-NEXT: s_max_i32 s5, s1, 0
705 ; GFX6-NEXT: s_sub_i32 s10, s9, s10
706 ; GFX6-NEXT: s_sub_i32 s5, s8, s5
707 ; GFX6-NEXT: s_max_i32 s2, s10, s2
708 ; GFX6-NEXT: s_min_i32 s2, s2, s5
709 ; GFX6-NEXT: s_add_i32 s1, s1, s2
710 ; GFX6-NEXT: s_lshl_b32 s2, s3, 24
711 ; GFX6-NEXT: s_lshl_b32 s3, s6, 24
712 ; GFX6-NEXT: s_min_i32 s6, s2, 0
713 ; GFX6-NEXT: s_max_i32 s5, s2, 0
714 ; GFX6-NEXT: s_sub_i32 s6, s9, s6
715 ; GFX6-NEXT: s_sub_i32 s5, s8, s5
716 ; GFX6-NEXT: s_max_i32 s3, s6, s3
717 ; GFX6-NEXT: s_min_i32 s3, s3, s5
718 ; GFX6-NEXT: s_add_i32 s2, s2, s3
719 ; GFX6-NEXT: s_lshl_b32 s3, s4, 24
720 ; GFX6-NEXT: s_min_i32 s6, s3, 0
721 ; GFX6-NEXT: s_lshl_b32 s4, s7, 24
722 ; GFX6-NEXT: s_max_i32 s5, s3, 0
723 ; GFX6-NEXT: s_sub_i32 s6, s9, s6
724 ; GFX6-NEXT: s_sub_i32 s5, s8, s5
725 ; GFX6-NEXT: s_max_i32 s4, s6, s4
726 ; GFX6-NEXT: s_min_i32 s4, s4, s5
727 ; GFX6-NEXT: s_ashr_i32 s1, s1, 24
728 ; GFX6-NEXT: s_add_i32 s3, s3, s4
729 ; GFX6-NEXT: s_movk_i32 s4, 0xff
730 ; GFX6-NEXT: s_ashr_i32 s0, s0, 24
731 ; GFX6-NEXT: s_and_b32 s1, s1, s4
732 ; GFX6-NEXT: s_ashr_i32 s2, s2, 24
733 ; GFX6-NEXT: s_and_b32 s0, s0, s4
734 ; GFX6-NEXT: s_lshl_b32 s1, s1, 8
735 ; GFX6-NEXT: s_or_b32 s0, s0, s1
736 ; GFX6-NEXT: s_and_b32 s1, s2, s4
737 ; GFX6-NEXT: s_ashr_i32 s3, s3, 24
738 ; GFX6-NEXT: s_lshl_b32 s1, s1, 16
739 ; GFX6-NEXT: s_or_b32 s0, s0, s1
740 ; GFX6-NEXT: s_and_b32 s1, s3, s4
741 ; GFX6-NEXT: s_lshl_b32 s1, s1, 24
742 ; GFX6-NEXT: s_or_b32 s0, s0, s1
743 ; GFX6-NEXT: ; return to shader part epilog
745 ; GFX8-LABEL: s_saddsat_v4i8:
747 ; GFX8-NEXT: s_bfe_u32 s8, 8, 0x100000
748 ; GFX8-NEXT: s_lshr_b32 s2, s0, 8
749 ; GFX8-NEXT: s_lshr_b32 s3, s0, 16
750 ; GFX8-NEXT: s_lshr_b32 s4, s0, 24
751 ; GFX8-NEXT: s_lshl_b32 s0, s0, s8
752 ; GFX8-NEXT: s_sext_i32_i16 s11, s0
753 ; GFX8-NEXT: s_sext_i32_i16 s12, 0
754 ; GFX8-NEXT: s_movk_i32 s10, 0x8000
755 ; GFX8-NEXT: s_max_i32 s13, s11, s12
756 ; GFX8-NEXT: s_min_i32 s11, s11, s12
757 ; GFX8-NEXT: s_lshr_b32 s5, s1, 8
758 ; GFX8-NEXT: s_lshr_b32 s6, s1, 16
759 ; GFX8-NEXT: s_lshr_b32 s7, s1, 24
760 ; GFX8-NEXT: s_lshl_b32 s1, s1, s8
761 ; GFX8-NEXT: s_sub_i32 s11, s10, s11
762 ; GFX8-NEXT: s_movk_i32 s9, 0x7fff
763 ; GFX8-NEXT: s_sext_i32_i16 s11, s11
764 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
765 ; GFX8-NEXT: s_sub_i32 s13, s9, s13
766 ; GFX8-NEXT: s_max_i32 s1, s11, s1
767 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
768 ; GFX8-NEXT: s_sext_i32_i16 s11, s13
769 ; GFX8-NEXT: s_min_i32 s1, s1, s11
770 ; GFX8-NEXT: s_add_i32 s0, s0, s1
771 ; GFX8-NEXT: s_lshl_b32 s1, s2, s8
772 ; GFX8-NEXT: s_lshl_b32 s2, s5, s8
773 ; GFX8-NEXT: s_sext_i32_i16 s5, s1
774 ; GFX8-NEXT: s_max_i32 s11, s5, s12
775 ; GFX8-NEXT: s_min_i32 s5, s5, s12
776 ; GFX8-NEXT: s_sub_i32 s5, s10, s5
777 ; GFX8-NEXT: s_sext_i32_i16 s5, s5
778 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
779 ; GFX8-NEXT: s_sub_i32 s11, s9, s11
780 ; GFX8-NEXT: s_max_i32 s2, s5, s2
781 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
782 ; GFX8-NEXT: s_sext_i32_i16 s5, s11
783 ; GFX8-NEXT: s_min_i32 s2, s2, s5
784 ; GFX8-NEXT: s_add_i32 s1, s1, s2
785 ; GFX8-NEXT: s_lshl_b32 s2, s3, s8
786 ; GFX8-NEXT: s_sext_i32_i16 s5, s2
787 ; GFX8-NEXT: s_lshl_b32 s3, s6, s8
788 ; GFX8-NEXT: s_max_i32 s6, s5, s12
789 ; GFX8-NEXT: s_min_i32 s5, s5, s12
790 ; GFX8-NEXT: s_sub_i32 s5, s10, s5
791 ; GFX8-NEXT: s_sext_i32_i16 s5, s5
792 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
793 ; GFX8-NEXT: s_sub_i32 s6, s9, s6
794 ; GFX8-NEXT: s_max_i32 s3, s5, s3
795 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
796 ; GFX8-NEXT: s_sext_i32_i16 s5, s6
797 ; GFX8-NEXT: s_min_i32 s3, s3, s5
798 ; GFX8-NEXT: s_add_i32 s2, s2, s3
799 ; GFX8-NEXT: s_lshl_b32 s3, s4, s8
800 ; GFX8-NEXT: s_sext_i32_i16 s5, s3
801 ; GFX8-NEXT: s_max_i32 s6, s5, s12
802 ; GFX8-NEXT: s_min_i32 s5, s5, s12
803 ; GFX8-NEXT: s_lshl_b32 s4, s7, s8
804 ; GFX8-NEXT: s_sub_i32 s5, s10, s5
805 ; GFX8-NEXT: s_sext_i32_i16 s5, s5
806 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
807 ; GFX8-NEXT: s_sub_i32 s6, s9, s6
808 ; GFX8-NEXT: s_max_i32 s4, s5, s4
809 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
810 ; GFX8-NEXT: s_sext_i32_i16 s5, s6
811 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
812 ; GFX8-NEXT: s_min_i32 s4, s4, s5
813 ; GFX8-NEXT: s_sext_i32_i16 s0, s0
814 ; GFX8-NEXT: s_ashr_i32 s1, s1, s8
815 ; GFX8-NEXT: s_add_i32 s3, s3, s4
816 ; GFX8-NEXT: s_movk_i32 s4, 0xff
817 ; GFX8-NEXT: s_ashr_i32 s0, s0, s8
818 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
819 ; GFX8-NEXT: s_and_b32 s1, s1, s4
820 ; GFX8-NEXT: s_ashr_i32 s2, s2, s8
821 ; GFX8-NEXT: s_and_b32 s0, s0, s4
822 ; GFX8-NEXT: s_lshl_b32 s1, s1, 8
823 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
824 ; GFX8-NEXT: s_or_b32 s0, s0, s1
825 ; GFX8-NEXT: s_and_b32 s1, s2, s4
826 ; GFX8-NEXT: s_ashr_i32 s3, s3, s8
827 ; GFX8-NEXT: s_lshl_b32 s1, s1, 16
828 ; GFX8-NEXT: s_or_b32 s0, s0, s1
829 ; GFX8-NEXT: s_and_b32 s1, s3, s4
830 ; GFX8-NEXT: s_lshl_b32 s1, s1, 24
831 ; GFX8-NEXT: s_or_b32 s0, s0, s1
832 ; GFX8-NEXT: ; return to shader part epilog
834 ; GFX9-LABEL: s_saddsat_v4i8:
836 ; GFX9-NEXT: s_lshr_b32 s3, s0, 8
837 ; GFX9-NEXT: s_lshr_b32 s4, s0, 16
838 ; GFX9-NEXT: s_lshr_b32 s6, s0, 24
839 ; GFX9-NEXT: s_pack_ll_b32_b16 s0, s0, s3
840 ; GFX9-NEXT: s_pack_ll_b32_b16 s3, s4, s6
841 ; GFX9-NEXT: s_mov_b32 s4, 0x80008
842 ; GFX9-NEXT: s_lshr_b32 s6, s0, 16
843 ; GFX9-NEXT: s_lshr_b32 s7, s1, 8
844 ; GFX9-NEXT: s_lshl_b32 s0, s0, s4
845 ; GFX9-NEXT: s_lshl_b32 s6, s6, 8
846 ; GFX9-NEXT: s_lshr_b32 s8, s1, 16
847 ; GFX9-NEXT: s_lshr_b32 s9, s1, 24
848 ; GFX9-NEXT: s_pack_ll_b32_b16 s0, s0, s6
849 ; GFX9-NEXT: s_lshr_b32 s6, s3, 16
850 ; GFX9-NEXT: s_pack_ll_b32_b16 s1, s1, s7
851 ; GFX9-NEXT: s_lshl_b32 s3, s3, s4
852 ; GFX9-NEXT: s_lshl_b32 s6, s6, 8
853 ; GFX9-NEXT: s_lshr_b32 s7, s1, 16
854 ; GFX9-NEXT: s_pack_ll_b32_b16 s3, s3, s6
855 ; GFX9-NEXT: s_pack_ll_b32_b16 s6, s8, s9
856 ; GFX9-NEXT: s_lshl_b32 s1, s1, s4
857 ; GFX9-NEXT: s_lshl_b32 s7, s7, 8
858 ; GFX9-NEXT: s_pack_ll_b32_b16 s1, s1, s7
859 ; GFX9-NEXT: s_lshr_b32 s7, s6, 16
860 ; GFX9-NEXT: s_lshl_b32 s4, s6, s4
861 ; GFX9-NEXT: s_lshl_b32 s6, s7, 8
862 ; GFX9-NEXT: s_pack_ll_b32_b16 s4, s4, s6
863 ; GFX9-NEXT: v_mov_b32_e32 v0, s1
864 ; GFX9-NEXT: v_pk_add_i16 v0, s0, v0 clamp
865 ; GFX9-NEXT: v_mov_b32_e32 v1, s4
866 ; GFX9-NEXT: s_mov_b32 s2, 8
867 ; GFX9-NEXT: v_pk_add_i16 v1, s3, v1 clamp
868 ; GFX9-NEXT: v_pk_ashrrev_i16 v0, 8, v0 op_sel_hi:[0,1]
869 ; GFX9-NEXT: v_pk_ashrrev_i16 v1, 8, v1 op_sel_hi:[0,1]
870 ; GFX9-NEXT: s_movk_i32 s0, 0xff
871 ; GFX9-NEXT: v_lshlrev_b32_sdwa v2, s2, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:BYTE_2
872 ; GFX9-NEXT: s_mov_b32 s5, 24
873 ; GFX9-NEXT: v_and_or_b32 v0, v0, s0, v2
874 ; GFX9-NEXT: v_and_b32_e32 v2, s0, v1
875 ; GFX9-NEXT: v_lshlrev_b32_e32 v2, 16, v2
876 ; GFX9-NEXT: v_lshlrev_b32_sdwa v1, s5, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:BYTE_2
877 ; GFX9-NEXT: v_or3_b32 v0, v0, v2, v1
878 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
879 ; GFX9-NEXT: ; return to shader part epilog
881 ; GFX10-LABEL: s_saddsat_v4i8:
883 ; GFX10-NEXT: s_lshr_b32 s2, s0, 8
884 ; GFX10-NEXT: s_lshr_b32 s3, s0, 16
885 ; GFX10-NEXT: s_lshr_b32 s4, s0, 24
886 ; GFX10-NEXT: s_pack_ll_b32_b16 s0, s0, s2
887 ; GFX10-NEXT: s_pack_ll_b32_b16 s2, s3, s4
888 ; GFX10-NEXT: s_mov_b32 s3, 0x80008
889 ; GFX10-NEXT: s_lshr_b32 s4, s0, 16
890 ; GFX10-NEXT: s_lshr_b32 s5, s1, 8
891 ; GFX10-NEXT: s_lshr_b32 s6, s1, 16
892 ; GFX10-NEXT: s_lshr_b32 s7, s1, 24
893 ; GFX10-NEXT: s_lshl_b32 s0, s0, s3
894 ; GFX10-NEXT: s_lshl_b32 s4, s4, 8
895 ; GFX10-NEXT: s_pack_ll_b32_b16 s1, s1, s5
896 ; GFX10-NEXT: s_pack_ll_b32_b16 s0, s0, s4
897 ; GFX10-NEXT: s_pack_ll_b32_b16 s4, s6, s7
898 ; GFX10-NEXT: s_lshr_b32 s8, s2, 16
899 ; GFX10-NEXT: s_lshr_b32 s5, s1, 16
900 ; GFX10-NEXT: s_lshr_b32 s6, s4, 16
901 ; GFX10-NEXT: s_lshl_b32 s2, s2, s3
902 ; GFX10-NEXT: s_lshl_b32 s8, s8, 8
903 ; GFX10-NEXT: s_lshl_b32 s1, s1, s3
904 ; GFX10-NEXT: s_lshl_b32 s5, s5, 8
905 ; GFX10-NEXT: s_lshl_b32 s3, s4, s3
906 ; GFX10-NEXT: s_lshl_b32 s4, s6, 8
907 ; GFX10-NEXT: s_pack_ll_b32_b16 s2, s2, s8
908 ; GFX10-NEXT: s_pack_ll_b32_b16 s1, s1, s5
909 ; GFX10-NEXT: s_pack_ll_b32_b16 s3, s3, s4
910 ; GFX10-NEXT: v_pk_add_i16 v0, s0, s1 clamp
911 ; GFX10-NEXT: v_pk_add_i16 v1, s2, s3 clamp
912 ; GFX10-NEXT: s_mov_b32 s0, 8
913 ; GFX10-NEXT: s_movk_i32 s1, 0xff
914 ; GFX10-NEXT: v_pk_ashrrev_i16 v0, 8, v0 op_sel_hi:[0,1]
915 ; GFX10-NEXT: v_pk_ashrrev_i16 v1, 8, v1 op_sel_hi:[0,1]
916 ; GFX10-NEXT: v_lshlrev_b32_sdwa v2, s0, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:BYTE_2
917 ; GFX10-NEXT: v_and_b32_e32 v3, s1, v1
918 ; GFX10-NEXT: s_mov_b32 s0, 24
919 ; GFX10-NEXT: v_lshlrev_b32_sdwa v1, s0, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:BYTE_2
920 ; GFX10-NEXT: v_and_or_b32 v0, v0, s1, v2
921 ; GFX10-NEXT: v_lshlrev_b32_e32 v2, 16, v3
922 ; GFX10-NEXT: v_or3_b32 v0, v0, v2, v1
923 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
924 ; GFX10-NEXT: ; return to shader part epilog
925 %lhs = bitcast i32 %lhs.arg to <4 x i8>
926 %rhs = bitcast i32 %rhs.arg to <4 x i8>
927 %result = call <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8> %lhs, <4 x i8> %rhs)
928 %cast.result = bitcast <4 x i8> %result to i32
932 define i24 @v_saddsat_i24(i24 %lhs, i24 %rhs) {
933 ; GFX6-LABEL: v_saddsat_i24:
935 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
936 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 8, v0
937 ; GFX6-NEXT: v_min_i32_e32 v3, 0, v0
938 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 8, v1
939 ; GFX6-NEXT: v_max_i32_e32 v2, 0, v0
940 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, 0x80000000, v3
941 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, 0x7fffffff, v2
942 ; GFX6-NEXT: v_max_i32_e32 v1, v3, v1
943 ; GFX6-NEXT: v_min_i32_e32 v1, v1, v2
944 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
945 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 8, v0
946 ; GFX6-NEXT: s_setpc_b64 s[30:31]
948 ; GFX8-LABEL: v_saddsat_i24:
950 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
951 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, v0, v1
952 ; GFX8-NEXT: v_bfe_i32 v3, v2, 0, 24
953 ; GFX8-NEXT: v_bfe_i32 v0, v0, 0, 24
954 ; GFX8-NEXT: v_cmp_lt_i32_e64 s[4:5], v3, v0
955 ; GFX8-NEXT: v_bfe_i32 v0, v1, 0, 24
956 ; GFX8-NEXT: v_cmp_gt_i32_e64 s[6:7], 0, v0
957 ; GFX8-NEXT: v_ashrrev_i32_e32 v0, 23, v3
958 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, 0xff800000, v0
959 ; GFX8-NEXT: s_xor_b64 vcc, s[6:7], s[4:5]
960 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v2, v0, vcc
961 ; GFX8-NEXT: s_setpc_b64 s[30:31]
963 ; GFX9-LABEL: v_saddsat_i24:
965 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
966 ; GFX9-NEXT: v_lshlrev_b32_e32 v0, 8, v0
967 ; GFX9-NEXT: v_lshlrev_b32_e32 v1, 8, v1
968 ; GFX9-NEXT: v_add_i32 v0, v0, v1 clamp
969 ; GFX9-NEXT: v_ashrrev_i32_e32 v0, 8, v0
970 ; GFX9-NEXT: s_setpc_b64 s[30:31]
972 ; GFX10-LABEL: v_saddsat_i24:
974 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
975 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
976 ; GFX10-NEXT: v_lshlrev_b32_e32 v0, 8, v0
977 ; GFX10-NEXT: v_lshlrev_b32_e32 v1, 8, v1
978 ; GFX10-NEXT: v_add_nc_i32 v0, v0, v1 clamp
979 ; GFX10-NEXT: v_ashrrev_i32_e32 v0, 8, v0
980 ; GFX10-NEXT: s_setpc_b64 s[30:31]
981 %result = call i24 @llvm.sadd.sat.i24(i24 %lhs, i24 %rhs)
985 define amdgpu_ps i24 @s_saddsat_i24(i24 inreg %lhs, i24 inreg %rhs) {
986 ; GFX6-LABEL: s_saddsat_i24:
988 ; GFX6-NEXT: s_lshl_b32 s0, s0, 8
989 ; GFX6-NEXT: s_min_i32 s3, s0, 0
990 ; GFX6-NEXT: s_lshl_b32 s1, s1, 8
991 ; GFX6-NEXT: s_max_i32 s2, s0, 0
992 ; GFX6-NEXT: s_sub_i32 s3, 0x80000000, s3
993 ; GFX6-NEXT: s_sub_i32 s2, 0x7fffffff, s2
994 ; GFX6-NEXT: s_max_i32 s1, s3, s1
995 ; GFX6-NEXT: s_min_i32 s1, s1, s2
996 ; GFX6-NEXT: s_add_i32 s0, s0, s1
997 ; GFX6-NEXT: s_ashr_i32 s0, s0, 8
998 ; GFX6-NEXT: ; return to shader part epilog
1000 ; GFX8-LABEL: s_saddsat_i24:
1002 ; GFX8-NEXT: s_add_i32 s2, s0, s1
1003 ; GFX8-NEXT: s_bfe_i32 s3, s2, 0x180000
1004 ; GFX8-NEXT: s_bfe_i32 s0, s0, 0x180000
1005 ; GFX8-NEXT: s_cmp_lt_i32 s3, s0
1006 ; GFX8-NEXT: s_cselect_b32 s0, 1, 0
1007 ; GFX8-NEXT: s_bfe_i32 s1, s1, 0x180000
1008 ; GFX8-NEXT: s_cmp_lt_i32 s1, 0
1009 ; GFX8-NEXT: s_cselect_b32 s1, 1, 0
1010 ; GFX8-NEXT: s_xor_b32 s0, s1, s0
1011 ; GFX8-NEXT: s_ashr_i32 s1, s3, 23
1012 ; GFX8-NEXT: s_add_i32 s1, s1, 0xff800000
1013 ; GFX8-NEXT: s_and_b32 s0, s0, 1
1014 ; GFX8-NEXT: s_cmp_lg_u32 s0, 0
1015 ; GFX8-NEXT: s_cselect_b32 s0, s1, s2
1016 ; GFX8-NEXT: ; return to shader part epilog
1018 ; GFX9-LABEL: s_saddsat_i24:
1020 ; GFX9-NEXT: s_lshl_b32 s1, s1, 8
1021 ; GFX9-NEXT: s_lshl_b32 s0, s0, 8
1022 ; GFX9-NEXT: v_mov_b32_e32 v0, s1
1023 ; GFX9-NEXT: v_add_i32 v0, s0, v0 clamp
1024 ; GFX9-NEXT: v_ashrrev_i32_e32 v0, 8, v0
1025 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
1026 ; GFX9-NEXT: ; return to shader part epilog
1028 ; GFX10-LABEL: s_saddsat_i24:
1030 ; GFX10-NEXT: s_lshl_b32 s0, s0, 8
1031 ; GFX10-NEXT: s_lshl_b32 s1, s1, 8
1032 ; GFX10-NEXT: v_add_nc_i32 v0, s0, s1 clamp
1033 ; GFX10-NEXT: v_ashrrev_i32_e32 v0, 8, v0
1034 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
1035 ; GFX10-NEXT: ; return to shader part epilog
1036 %result = call i24 @llvm.sadd.sat.i24(i24 %lhs, i24 %rhs)
1040 define i32 @v_saddsat_i32(i32 %lhs, i32 %rhs) {
1041 ; GFX6-LABEL: v_saddsat_i32:
1043 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1044 ; GFX6-NEXT: v_min_i32_e32 v3, 0, v0
1045 ; GFX6-NEXT: v_max_i32_e32 v2, 0, v0
1046 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, 0x80000000, v3
1047 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, 0x7fffffff, v2
1048 ; GFX6-NEXT: v_max_i32_e32 v1, v3, v1
1049 ; GFX6-NEXT: v_min_i32_e32 v1, v1, v2
1050 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
1051 ; GFX6-NEXT: s_setpc_b64 s[30:31]
1053 ; GFX8-LABEL: v_saddsat_i32:
1055 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1056 ; GFX8-NEXT: v_min_i32_e32 v3, 0, v0
1057 ; GFX8-NEXT: v_max_i32_e32 v2, 0, v0
1058 ; GFX8-NEXT: v_sub_u32_e32 v3, vcc, 0x80000000, v3
1059 ; GFX8-NEXT: v_sub_u32_e32 v2, vcc, 0x7fffffff, v2
1060 ; GFX8-NEXT: v_max_i32_e32 v1, v3, v1
1061 ; GFX8-NEXT: v_min_i32_e32 v1, v1, v2
1062 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, v0, v1
1063 ; GFX8-NEXT: s_setpc_b64 s[30:31]
1065 ; GFX9-LABEL: v_saddsat_i32:
1067 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1068 ; GFX9-NEXT: v_add_i32 v0, v0, v1 clamp
1069 ; GFX9-NEXT: s_setpc_b64 s[30:31]
1071 ; GFX10-LABEL: v_saddsat_i32:
1073 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1074 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
1075 ; GFX10-NEXT: v_add_nc_i32 v0, v0, v1 clamp
1076 ; GFX10-NEXT: s_setpc_b64 s[30:31]
1077 %result = call i32 @llvm.sadd.sat.i32(i32 %lhs, i32 %rhs)
1081 define amdgpu_ps i32 @s_saddsat_i32(i32 inreg %lhs, i32 inreg %rhs) {
1082 ; GCN-LABEL: s_saddsat_i32:
1084 ; GCN-NEXT: s_cmp_gt_i32 s0, 0
1085 ; GCN-NEXT: s_cselect_b32 s2, s0, 0
1086 ; GCN-NEXT: s_sub_i32 s2, 0x7fffffff, s2
1087 ; GCN-NEXT: s_cmp_lt_i32 s0, 0
1088 ; GCN-NEXT: s_cselect_b32 s3, s0, 0
1089 ; GCN-NEXT: s_sub_i32 s3, 0x80000000, s3
1090 ; GCN-NEXT: s_cmp_gt_i32 s3, s1
1091 ; GCN-NEXT: s_cselect_b32 s1, s3, s1
1092 ; GCN-NEXT: s_cmp_lt_i32 s1, s2
1093 ; GCN-NEXT: s_cselect_b32 s1, s1, s2
1094 ; GCN-NEXT: s_add_i32 s0, s0, s1
1095 ; GCN-NEXT: ; return to shader part epilog
1096 ; GFX6-LABEL: s_saddsat_i32:
1098 ; GFX6-NEXT: s_min_i32 s3, s0, 0
1099 ; GFX6-NEXT: s_max_i32 s2, s0, 0
1100 ; GFX6-NEXT: s_sub_i32 s3, 0x80000000, s3
1101 ; GFX6-NEXT: s_sub_i32 s2, 0x7fffffff, s2
1102 ; GFX6-NEXT: s_max_i32 s1, s3, s1
1103 ; GFX6-NEXT: s_min_i32 s1, s1, s2
1104 ; GFX6-NEXT: s_add_i32 s0, s0, s1
1105 ; GFX6-NEXT: ; return to shader part epilog
1107 ; GFX8-LABEL: s_saddsat_i32:
1109 ; GFX8-NEXT: s_min_i32 s3, s0, 0
1110 ; GFX8-NEXT: s_max_i32 s2, s0, 0
1111 ; GFX8-NEXT: s_sub_i32 s3, 0x80000000, s3
1112 ; GFX8-NEXT: s_sub_i32 s2, 0x7fffffff, s2
1113 ; GFX8-NEXT: s_max_i32 s1, s3, s1
1114 ; GFX8-NEXT: s_min_i32 s1, s1, s2
1115 ; GFX8-NEXT: s_add_i32 s0, s0, s1
1116 ; GFX8-NEXT: ; return to shader part epilog
1118 ; GFX9-LABEL: s_saddsat_i32:
1120 ; GFX9-NEXT: v_mov_b32_e32 v0, s1
1121 ; GFX9-NEXT: v_add_i32 v0, s0, v0 clamp
1122 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
1123 ; GFX9-NEXT: ; return to shader part epilog
1125 ; GFX10-LABEL: s_saddsat_i32:
1127 ; GFX10-NEXT: v_add_nc_i32 v0, s0, s1 clamp
1128 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
1129 ; GFX10-NEXT: ; return to shader part epilog
1130 %result = call i32 @llvm.sadd.sat.i32(i32 %lhs, i32 %rhs)
1134 define amdgpu_ps float @saddsat_i32_sv(i32 inreg %lhs, i32 %rhs) {
1135 ; GFX6-LABEL: saddsat_i32_sv:
1137 ; GFX6-NEXT: s_min_i32 s2, s0, 0
1138 ; GFX6-NEXT: s_max_i32 s1, s0, 0
1139 ; GFX6-NEXT: s_sub_i32 s2, 0x80000000, s2
1140 ; GFX6-NEXT: s_sub_i32 s1, 0x7fffffff, s1
1141 ; GFX6-NEXT: v_max_i32_e32 v0, s2, v0
1142 ; GFX6-NEXT: v_min_i32_e32 v0, s1, v0
1143 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s0, v0
1144 ; GFX6-NEXT: ; return to shader part epilog
1146 ; GFX8-LABEL: saddsat_i32_sv:
1148 ; GFX8-NEXT: s_min_i32 s2, s0, 0
1149 ; GFX8-NEXT: s_max_i32 s1, s0, 0
1150 ; GFX8-NEXT: s_sub_i32 s2, 0x80000000, s2
1151 ; GFX8-NEXT: s_sub_i32 s1, 0x7fffffff, s1
1152 ; GFX8-NEXT: v_max_i32_e32 v0, s2, v0
1153 ; GFX8-NEXT: v_min_i32_e32 v0, s1, v0
1154 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s0, v0
1155 ; GFX8-NEXT: ; return to shader part epilog
1157 ; GFX9-LABEL: saddsat_i32_sv:
1159 ; GFX9-NEXT: v_add_i32 v0, s0, v0 clamp
1160 ; GFX9-NEXT: ; return to shader part epilog
1162 ; GFX10-LABEL: saddsat_i32_sv:
1164 ; GFX10-NEXT: v_add_nc_i32 v0, s0, v0 clamp
1165 ; GFX10-NEXT: ; return to shader part epilog
1166 %result = call i32 @llvm.sadd.sat.i32(i32 %lhs, i32 %rhs)
1167 %cast = bitcast i32 %result to float
1171 define amdgpu_ps float @saddsat_i32_vs(i32 %lhs, i32 inreg %rhs) {
1172 ; GFX6-LABEL: saddsat_i32_vs:
1174 ; GFX6-NEXT: v_min_i32_e32 v2, 0, v0
1175 ; GFX6-NEXT: v_max_i32_e32 v1, 0, v0
1176 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, 0x80000000, v2
1177 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, 0x7fffffff, v1
1178 ; GFX6-NEXT: v_max_i32_e32 v2, s0, v2
1179 ; GFX6-NEXT: v_min_i32_e32 v1, v2, v1
1180 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
1181 ; GFX6-NEXT: ; return to shader part epilog
1183 ; GFX8-LABEL: saddsat_i32_vs:
1185 ; GFX8-NEXT: v_min_i32_e32 v2, 0, v0
1186 ; GFX8-NEXT: v_max_i32_e32 v1, 0, v0
1187 ; GFX8-NEXT: v_sub_u32_e32 v2, vcc, 0x80000000, v2
1188 ; GFX8-NEXT: v_sub_u32_e32 v1, vcc, 0x7fffffff, v1
1189 ; GFX8-NEXT: v_max_i32_e32 v2, s0, v2
1190 ; GFX8-NEXT: v_min_i32_e32 v1, v2, v1
1191 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, v0, v1
1192 ; GFX8-NEXT: ; return to shader part epilog
1194 ; GFX9-LABEL: saddsat_i32_vs:
1196 ; GFX9-NEXT: v_add_i32 v0, v0, s0 clamp
1197 ; GFX9-NEXT: ; return to shader part epilog
1199 ; GFX10-LABEL: saddsat_i32_vs:
1201 ; GFX10-NEXT: v_add_nc_i32 v0, v0, s0 clamp
1202 ; GFX10-NEXT: ; return to shader part epilog
1203 %result = call i32 @llvm.sadd.sat.i32(i32 %lhs, i32 %rhs)
1204 %cast = bitcast i32 %result to float
1208 define <2 x i32> @v_saddsat_v2i32(<2 x i32> %lhs, <2 x i32> %rhs) {
1209 ; GFX6-LABEL: v_saddsat_v2i32:
1211 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1212 ; GFX6-NEXT: s_brev_b32 s5, 1
1213 ; GFX6-NEXT: v_min_i32_e32 v5, 0, v0
1214 ; GFX6-NEXT: s_brev_b32 s4, -2
1215 ; GFX6-NEXT: v_max_i32_e32 v4, 0, v0
1216 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, s5, v5
1217 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s4, v4
1218 ; GFX6-NEXT: v_max_i32_e32 v2, v5, v2
1219 ; GFX6-NEXT: v_min_i32_e32 v2, v2, v4
1220 ; GFX6-NEXT: v_min_i32_e32 v4, 0, v1
1221 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
1222 ; GFX6-NEXT: v_max_i32_e32 v2, 0, v1
1223 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s5, v4
1224 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s4, v2
1225 ; GFX6-NEXT: v_max_i32_e32 v3, v4, v3
1226 ; GFX6-NEXT: v_min_i32_e32 v2, v3, v2
1227 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v2
1228 ; GFX6-NEXT: s_setpc_b64 s[30:31]
1230 ; GFX8-LABEL: v_saddsat_v2i32:
1232 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1233 ; GFX8-NEXT: s_brev_b32 s5, 1
1234 ; GFX8-NEXT: v_min_i32_e32 v5, 0, v0
1235 ; GFX8-NEXT: s_brev_b32 s4, -2
1236 ; GFX8-NEXT: v_max_i32_e32 v4, 0, v0
1237 ; GFX8-NEXT: v_sub_u32_e32 v5, vcc, s5, v5
1238 ; GFX8-NEXT: v_sub_u32_e32 v4, vcc, s4, v4
1239 ; GFX8-NEXT: v_max_i32_e32 v2, v5, v2
1240 ; GFX8-NEXT: v_min_i32_e32 v2, v2, v4
1241 ; GFX8-NEXT: v_min_i32_e32 v4, 0, v1
1242 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, v0, v2
1243 ; GFX8-NEXT: v_max_i32_e32 v2, 0, v1
1244 ; GFX8-NEXT: v_sub_u32_e32 v4, vcc, s5, v4
1245 ; GFX8-NEXT: v_sub_u32_e32 v2, vcc, s4, v2
1246 ; GFX8-NEXT: v_max_i32_e32 v3, v4, v3
1247 ; GFX8-NEXT: v_min_i32_e32 v2, v3, v2
1248 ; GFX8-NEXT: v_add_u32_e32 v1, vcc, v1, v2
1249 ; GFX8-NEXT: s_setpc_b64 s[30:31]
1251 ; GFX9-LABEL: v_saddsat_v2i32:
1253 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1254 ; GFX9-NEXT: v_add_i32 v0, v0, v2 clamp
1255 ; GFX9-NEXT: v_add_i32 v1, v1, v3 clamp
1256 ; GFX9-NEXT: s_setpc_b64 s[30:31]
1258 ; GFX10-LABEL: v_saddsat_v2i32:
1260 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1261 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
1262 ; GFX10-NEXT: v_add_nc_i32 v0, v0, v2 clamp
1263 ; GFX10-NEXT: v_add_nc_i32 v1, v1, v3 clamp
1264 ; GFX10-NEXT: s_setpc_b64 s[30:31]
1265 %result = call <2 x i32> @llvm.sadd.sat.v2i32(<2 x i32> %lhs, <2 x i32> %rhs)
1266 ret <2 x i32> %result
1269 define amdgpu_ps <2 x i32> @s_saddsat_v2i32(<2 x i32> inreg %lhs, <2 x i32> inreg %rhs) {
1270 ; GFX6-LABEL: s_saddsat_v2i32:
1272 ; GFX6-NEXT: s_brev_b32 s5, 1
1273 ; GFX6-NEXT: s_min_i32 s7, s0, 0
1274 ; GFX6-NEXT: s_brev_b32 s4, -2
1275 ; GFX6-NEXT: s_max_i32 s6, s0, 0
1276 ; GFX6-NEXT: s_sub_i32 s7, s5, s7
1277 ; GFX6-NEXT: s_sub_i32 s6, s4, s6
1278 ; GFX6-NEXT: s_max_i32 s2, s7, s2
1279 ; GFX6-NEXT: s_min_i32 s2, s2, s6
1280 ; GFX6-NEXT: s_add_i32 s0, s0, s2
1281 ; GFX6-NEXT: s_max_i32 s2, s1, 0
1282 ; GFX6-NEXT: s_sub_i32 s2, s4, s2
1283 ; GFX6-NEXT: s_min_i32 s4, s1, 0
1284 ; GFX6-NEXT: s_sub_i32 s4, s5, s4
1285 ; GFX6-NEXT: s_max_i32 s3, s4, s3
1286 ; GFX6-NEXT: s_min_i32 s2, s3, s2
1287 ; GFX6-NEXT: s_add_i32 s1, s1, s2
1288 ; GFX6-NEXT: ; return to shader part epilog
1290 ; GFX8-LABEL: s_saddsat_v2i32:
1292 ; GFX8-NEXT: s_brev_b32 s5, 1
1293 ; GFX8-NEXT: s_min_i32 s7, s0, 0
1294 ; GFX8-NEXT: s_brev_b32 s4, -2
1295 ; GFX8-NEXT: s_max_i32 s6, s0, 0
1296 ; GFX8-NEXT: s_sub_i32 s7, s5, s7
1297 ; GFX8-NEXT: s_sub_i32 s6, s4, s6
1298 ; GFX8-NEXT: s_max_i32 s2, s7, s2
1299 ; GFX8-NEXT: s_min_i32 s2, s2, s6
1300 ; GFX8-NEXT: s_add_i32 s0, s0, s2
1301 ; GFX8-NEXT: s_max_i32 s2, s1, 0
1302 ; GFX8-NEXT: s_sub_i32 s2, s4, s2
1303 ; GFX8-NEXT: s_min_i32 s4, s1, 0
1304 ; GFX8-NEXT: s_sub_i32 s4, s5, s4
1305 ; GFX8-NEXT: s_max_i32 s3, s4, s3
1306 ; GFX8-NEXT: s_min_i32 s2, s3, s2
1307 ; GFX8-NEXT: s_add_i32 s1, s1, s2
1308 ; GFX8-NEXT: ; return to shader part epilog
1310 ; GFX9-LABEL: s_saddsat_v2i32:
1312 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
1313 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
1314 ; GFX9-NEXT: v_add_i32 v0, s0, v0 clamp
1315 ; GFX9-NEXT: v_add_i32 v1, s1, v1 clamp
1316 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
1317 ; GFX9-NEXT: v_readfirstlane_b32 s1, v1
1318 ; GFX9-NEXT: ; return to shader part epilog
1320 ; GFX10-LABEL: s_saddsat_v2i32:
1322 ; GFX10-NEXT: v_add_nc_i32 v0, s0, s2 clamp
1323 ; GFX10-NEXT: v_add_nc_i32 v1, s1, s3 clamp
1324 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
1325 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
1326 ; GFX10-NEXT: ; return to shader part epilog
1327 %result = call <2 x i32> @llvm.sadd.sat.v2i32(<2 x i32> %lhs, <2 x i32> %rhs)
1328 ret <2 x i32> %result
1331 define <3 x i32> @v_saddsat_v3i32(<3 x i32> %lhs, <3 x i32> %rhs) {
1332 ; GFX6-LABEL: v_saddsat_v3i32:
1334 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1335 ; GFX6-NEXT: s_brev_b32 s5, 1
1336 ; GFX6-NEXT: v_min_i32_e32 v7, 0, v0
1337 ; GFX6-NEXT: s_brev_b32 s4, -2
1338 ; GFX6-NEXT: v_max_i32_e32 v6, 0, v0
1339 ; GFX6-NEXT: v_sub_i32_e32 v7, vcc, s5, v7
1340 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, s4, v6
1341 ; GFX6-NEXT: v_max_i32_e32 v3, v7, v3
1342 ; GFX6-NEXT: v_min_i32_e32 v3, v3, v6
1343 ; GFX6-NEXT: v_min_i32_e32 v6, 0, v1
1344 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v3
1345 ; GFX6-NEXT: v_max_i32_e32 v3, 0, v1
1346 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, s5, v6
1347 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, s4, v3
1348 ; GFX6-NEXT: v_max_i32_e32 v4, v6, v4
1349 ; GFX6-NEXT: v_min_i32_e32 v3, v4, v3
1350 ; GFX6-NEXT: v_min_i32_e32 v4, 0, v2
1351 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v3
1352 ; GFX6-NEXT: v_max_i32_e32 v3, 0, v2
1353 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s5, v4
1354 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, s4, v3
1355 ; GFX6-NEXT: v_max_i32_e32 v4, v4, v5
1356 ; GFX6-NEXT: v_min_i32_e32 v3, v4, v3
1357 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v3
1358 ; GFX6-NEXT: s_setpc_b64 s[30:31]
1360 ; GFX8-LABEL: v_saddsat_v3i32:
1362 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1363 ; GFX8-NEXT: s_brev_b32 s5, 1
1364 ; GFX8-NEXT: v_min_i32_e32 v7, 0, v0
1365 ; GFX8-NEXT: s_brev_b32 s4, -2
1366 ; GFX8-NEXT: v_max_i32_e32 v6, 0, v0
1367 ; GFX8-NEXT: v_sub_u32_e32 v7, vcc, s5, v7
1368 ; GFX8-NEXT: v_sub_u32_e32 v6, vcc, s4, v6
1369 ; GFX8-NEXT: v_max_i32_e32 v3, v7, v3
1370 ; GFX8-NEXT: v_min_i32_e32 v3, v3, v6
1371 ; GFX8-NEXT: v_min_i32_e32 v6, 0, v1
1372 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, v0, v3
1373 ; GFX8-NEXT: v_max_i32_e32 v3, 0, v1
1374 ; GFX8-NEXT: v_sub_u32_e32 v6, vcc, s5, v6
1375 ; GFX8-NEXT: v_sub_u32_e32 v3, vcc, s4, v3
1376 ; GFX8-NEXT: v_max_i32_e32 v4, v6, v4
1377 ; GFX8-NEXT: v_min_i32_e32 v3, v4, v3
1378 ; GFX8-NEXT: v_min_i32_e32 v4, 0, v2
1379 ; GFX8-NEXT: v_add_u32_e32 v1, vcc, v1, v3
1380 ; GFX8-NEXT: v_max_i32_e32 v3, 0, v2
1381 ; GFX8-NEXT: v_sub_u32_e32 v4, vcc, s5, v4
1382 ; GFX8-NEXT: v_sub_u32_e32 v3, vcc, s4, v3
1383 ; GFX8-NEXT: v_max_i32_e32 v4, v4, v5
1384 ; GFX8-NEXT: v_min_i32_e32 v3, v4, v3
1385 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, v2, v3
1386 ; GFX8-NEXT: s_setpc_b64 s[30:31]
1388 ; GFX9-LABEL: v_saddsat_v3i32:
1390 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1391 ; GFX9-NEXT: v_add_i32 v0, v0, v3 clamp
1392 ; GFX9-NEXT: v_add_i32 v1, v1, v4 clamp
1393 ; GFX9-NEXT: v_add_i32 v2, v2, v5 clamp
1394 ; GFX9-NEXT: s_setpc_b64 s[30:31]
1396 ; GFX10-LABEL: v_saddsat_v3i32:
1398 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1399 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
1400 ; GFX10-NEXT: v_add_nc_i32 v0, v0, v3 clamp
1401 ; GFX10-NEXT: v_add_nc_i32 v1, v1, v4 clamp
1402 ; GFX10-NEXT: v_add_nc_i32 v2, v2, v5 clamp
1403 ; GFX10-NEXT: s_setpc_b64 s[30:31]
1404 %result = call <3 x i32> @llvm.sadd.sat.v3i32(<3 x i32> %lhs, <3 x i32> %rhs)
1405 ret <3 x i32> %result
1408 define amdgpu_ps <3 x i32> @s_saddsat_v3i32(<3 x i32> inreg %lhs, <3 x i32> inreg %rhs) {
1409 ; GFX6-LABEL: s_saddsat_v3i32:
1411 ; GFX6-NEXT: s_brev_b32 s7, 1
1412 ; GFX6-NEXT: s_min_i32 s9, s0, 0
1413 ; GFX6-NEXT: s_brev_b32 s6, -2
1414 ; GFX6-NEXT: s_max_i32 s8, s0, 0
1415 ; GFX6-NEXT: s_sub_i32 s9, s7, s9
1416 ; GFX6-NEXT: s_sub_i32 s8, s6, s8
1417 ; GFX6-NEXT: s_max_i32 s3, s9, s3
1418 ; GFX6-NEXT: s_min_i32 s3, s3, s8
1419 ; GFX6-NEXT: s_min_i32 s8, s1, 0
1420 ; GFX6-NEXT: s_add_i32 s0, s0, s3
1421 ; GFX6-NEXT: s_max_i32 s3, s1, 0
1422 ; GFX6-NEXT: s_sub_i32 s8, s7, s8
1423 ; GFX6-NEXT: s_sub_i32 s3, s6, s3
1424 ; GFX6-NEXT: s_max_i32 s4, s8, s4
1425 ; GFX6-NEXT: s_min_i32 s3, s4, s3
1426 ; GFX6-NEXT: s_min_i32 s4, s2, 0
1427 ; GFX6-NEXT: s_add_i32 s1, s1, s3
1428 ; GFX6-NEXT: s_max_i32 s3, s2, 0
1429 ; GFX6-NEXT: s_sub_i32 s4, s7, s4
1430 ; GFX6-NEXT: s_sub_i32 s3, s6, s3
1431 ; GFX6-NEXT: s_max_i32 s4, s4, s5
1432 ; GFX6-NEXT: s_min_i32 s3, s4, s3
1433 ; GFX6-NEXT: s_add_i32 s2, s2, s3
1434 ; GFX6-NEXT: ; return to shader part epilog
1436 ; GFX8-LABEL: s_saddsat_v3i32:
1438 ; GFX8-NEXT: s_brev_b32 s7, 1
1439 ; GFX8-NEXT: s_min_i32 s9, s0, 0
1440 ; GFX8-NEXT: s_brev_b32 s6, -2
1441 ; GFX8-NEXT: s_max_i32 s8, s0, 0
1442 ; GFX8-NEXT: s_sub_i32 s9, s7, s9
1443 ; GFX8-NEXT: s_sub_i32 s8, s6, s8
1444 ; GFX8-NEXT: s_max_i32 s3, s9, s3
1445 ; GFX8-NEXT: s_min_i32 s3, s3, s8
1446 ; GFX8-NEXT: s_min_i32 s8, s1, 0
1447 ; GFX8-NEXT: s_add_i32 s0, s0, s3
1448 ; GFX8-NEXT: s_max_i32 s3, s1, 0
1449 ; GFX8-NEXT: s_sub_i32 s8, s7, s8
1450 ; GFX8-NEXT: s_sub_i32 s3, s6, s3
1451 ; GFX8-NEXT: s_max_i32 s4, s8, s4
1452 ; GFX8-NEXT: s_min_i32 s3, s4, s3
1453 ; GFX8-NEXT: s_min_i32 s4, s2, 0
1454 ; GFX8-NEXT: s_add_i32 s1, s1, s3
1455 ; GFX8-NEXT: s_max_i32 s3, s2, 0
1456 ; GFX8-NEXT: s_sub_i32 s4, s7, s4
1457 ; GFX8-NEXT: s_sub_i32 s3, s6, s3
1458 ; GFX8-NEXT: s_max_i32 s4, s4, s5
1459 ; GFX8-NEXT: s_min_i32 s3, s4, s3
1460 ; GFX8-NEXT: s_add_i32 s2, s2, s3
1461 ; GFX8-NEXT: ; return to shader part epilog
1463 ; GFX9-LABEL: s_saddsat_v3i32:
1465 ; GFX9-NEXT: v_mov_b32_e32 v0, s3
1466 ; GFX9-NEXT: v_mov_b32_e32 v1, s4
1467 ; GFX9-NEXT: v_mov_b32_e32 v2, s5
1468 ; GFX9-NEXT: v_add_i32 v0, s0, v0 clamp
1469 ; GFX9-NEXT: v_add_i32 v1, s1, v1 clamp
1470 ; GFX9-NEXT: v_add_i32 v2, s2, v2 clamp
1471 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
1472 ; GFX9-NEXT: v_readfirstlane_b32 s1, v1
1473 ; GFX9-NEXT: v_readfirstlane_b32 s2, v2
1474 ; GFX9-NEXT: ; return to shader part epilog
1476 ; GFX10-LABEL: s_saddsat_v3i32:
1478 ; GFX10-NEXT: v_add_nc_i32 v0, s0, s3 clamp
1479 ; GFX10-NEXT: v_add_nc_i32 v1, s1, s4 clamp
1480 ; GFX10-NEXT: v_add_nc_i32 v2, s2, s5 clamp
1481 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
1482 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
1483 ; GFX10-NEXT: v_readfirstlane_b32 s2, v2
1484 ; GFX10-NEXT: ; return to shader part epilog
1485 %result = call <3 x i32> @llvm.sadd.sat.v3i32(<3 x i32> %lhs, <3 x i32> %rhs)
1486 ret <3 x i32> %result
1489 define <4 x i32> @v_saddsat_v4i32(<4 x i32> %lhs, <4 x i32> %rhs) {
1490 ; GFX6-LABEL: v_saddsat_v4i32:
1492 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1493 ; GFX6-NEXT: s_brev_b32 s5, 1
1494 ; GFX6-NEXT: v_min_i32_e32 v9, 0, v0
1495 ; GFX6-NEXT: s_brev_b32 s4, -2
1496 ; GFX6-NEXT: v_max_i32_e32 v8, 0, v0
1497 ; GFX6-NEXT: v_sub_i32_e32 v9, vcc, s5, v9
1498 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, s4, v8
1499 ; GFX6-NEXT: v_max_i32_e32 v4, v9, v4
1500 ; GFX6-NEXT: v_min_i32_e32 v4, v4, v8
1501 ; GFX6-NEXT: v_min_i32_e32 v8, 0, v1
1502 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v4
1503 ; GFX6-NEXT: v_max_i32_e32 v4, 0, v1
1504 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, s5, v8
1505 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s4, v4
1506 ; GFX6-NEXT: v_max_i32_e32 v5, v8, v5
1507 ; GFX6-NEXT: v_min_i32_e32 v4, v5, v4
1508 ; GFX6-NEXT: v_min_i32_e32 v5, 0, v2
1509 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v4
1510 ; GFX6-NEXT: v_max_i32_e32 v4, 0, v2
1511 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, s5, v5
1512 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s4, v4
1513 ; GFX6-NEXT: v_max_i32_e32 v5, v5, v6
1514 ; GFX6-NEXT: v_min_i32_e32 v4, v5, v4
1515 ; GFX6-NEXT: v_min_i32_e32 v5, 0, v3
1516 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
1517 ; GFX6-NEXT: v_max_i32_e32 v4, 0, v3
1518 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, 0x80000000, v5
1519 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, 0x7fffffff, v4
1520 ; GFX6-NEXT: v_max_i32_e32 v5, v5, v7
1521 ; GFX6-NEXT: v_min_i32_e32 v4, v5, v4
1522 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v4
1523 ; GFX6-NEXT: s_setpc_b64 s[30:31]
1525 ; GFX8-LABEL: v_saddsat_v4i32:
1527 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1528 ; GFX8-NEXT: s_brev_b32 s5, 1
1529 ; GFX8-NEXT: v_min_i32_e32 v9, 0, v0
1530 ; GFX8-NEXT: s_brev_b32 s4, -2
1531 ; GFX8-NEXT: v_max_i32_e32 v8, 0, v0
1532 ; GFX8-NEXT: v_sub_u32_e32 v9, vcc, s5, v9
1533 ; GFX8-NEXT: v_sub_u32_e32 v8, vcc, s4, v8
1534 ; GFX8-NEXT: v_max_i32_e32 v4, v9, v4
1535 ; GFX8-NEXT: v_min_i32_e32 v4, v4, v8
1536 ; GFX8-NEXT: v_min_i32_e32 v8, 0, v1
1537 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, v0, v4
1538 ; GFX8-NEXT: v_max_i32_e32 v4, 0, v1
1539 ; GFX8-NEXT: v_sub_u32_e32 v8, vcc, s5, v8
1540 ; GFX8-NEXT: v_sub_u32_e32 v4, vcc, s4, v4
1541 ; GFX8-NEXT: v_max_i32_e32 v5, v8, v5
1542 ; GFX8-NEXT: v_min_i32_e32 v4, v5, v4
1543 ; GFX8-NEXT: v_min_i32_e32 v5, 0, v2
1544 ; GFX8-NEXT: v_add_u32_e32 v1, vcc, v1, v4
1545 ; GFX8-NEXT: v_max_i32_e32 v4, 0, v2
1546 ; GFX8-NEXT: v_sub_u32_e32 v5, vcc, s5, v5
1547 ; GFX8-NEXT: v_sub_u32_e32 v4, vcc, s4, v4
1548 ; GFX8-NEXT: v_max_i32_e32 v5, v5, v6
1549 ; GFX8-NEXT: v_min_i32_e32 v4, v5, v4
1550 ; GFX8-NEXT: v_min_i32_e32 v5, 0, v3
1551 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, v2, v4
1552 ; GFX8-NEXT: v_max_i32_e32 v4, 0, v3
1553 ; GFX8-NEXT: v_sub_u32_e32 v5, vcc, 0x80000000, v5
1554 ; GFX8-NEXT: v_sub_u32_e32 v4, vcc, 0x7fffffff, v4
1555 ; GFX8-NEXT: v_max_i32_e32 v5, v5, v7
1556 ; GFX8-NEXT: v_min_i32_e32 v4, v5, v4
1557 ; GFX8-NEXT: v_add_u32_e32 v3, vcc, v3, v4
1558 ; GFX8-NEXT: s_setpc_b64 s[30:31]
1560 ; GFX9-LABEL: v_saddsat_v4i32:
1562 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1563 ; GFX9-NEXT: v_add_i32 v0, v0, v4 clamp
1564 ; GFX9-NEXT: v_add_i32 v1, v1, v5 clamp
1565 ; GFX9-NEXT: v_add_i32 v2, v2, v6 clamp
1566 ; GFX9-NEXT: v_add_i32 v3, v3, v7 clamp
1567 ; GFX9-NEXT: s_setpc_b64 s[30:31]
1569 ; GFX10-LABEL: v_saddsat_v4i32:
1571 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1572 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
1573 ; GFX10-NEXT: v_add_nc_i32 v0, v0, v4 clamp
1574 ; GFX10-NEXT: v_add_nc_i32 v1, v1, v5 clamp
1575 ; GFX10-NEXT: v_add_nc_i32 v2, v2, v6 clamp
1576 ; GFX10-NEXT: v_add_nc_i32 v3, v3, v7 clamp
1577 ; GFX10-NEXT: s_setpc_b64 s[30:31]
1578 %result = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %lhs, <4 x i32> %rhs)
1579 ret <4 x i32> %result
1582 define amdgpu_ps <4 x i32> @s_saddsat_v4i32(<4 x i32> inreg %lhs, <4 x i32> inreg %rhs) {
1583 ; GFX6-LABEL: s_saddsat_v4i32:
1585 ; GFX6-NEXT: s_brev_b32 s9, 1
1586 ; GFX6-NEXT: s_min_i32 s11, s0, 0
1587 ; GFX6-NEXT: s_brev_b32 s8, -2
1588 ; GFX6-NEXT: s_max_i32 s10, s0, 0
1589 ; GFX6-NEXT: s_sub_i32 s11, s9, s11
1590 ; GFX6-NEXT: s_sub_i32 s10, s8, s10
1591 ; GFX6-NEXT: s_max_i32 s4, s11, s4
1592 ; GFX6-NEXT: s_min_i32 s4, s4, s10
1593 ; GFX6-NEXT: s_min_i32 s10, s1, 0
1594 ; GFX6-NEXT: s_add_i32 s0, s0, s4
1595 ; GFX6-NEXT: s_max_i32 s4, s1, 0
1596 ; GFX6-NEXT: s_sub_i32 s10, s9, s10
1597 ; GFX6-NEXT: s_sub_i32 s4, s8, s4
1598 ; GFX6-NEXT: s_max_i32 s5, s10, s5
1599 ; GFX6-NEXT: s_min_i32 s4, s5, s4
1600 ; GFX6-NEXT: s_min_i32 s5, s2, 0
1601 ; GFX6-NEXT: s_add_i32 s1, s1, s4
1602 ; GFX6-NEXT: s_max_i32 s4, s2, 0
1603 ; GFX6-NEXT: s_sub_i32 s5, s9, s5
1604 ; GFX6-NEXT: s_sub_i32 s4, s8, s4
1605 ; GFX6-NEXT: s_max_i32 s5, s5, s6
1606 ; GFX6-NEXT: s_min_i32 s4, s5, s4
1607 ; GFX6-NEXT: s_min_i32 s5, s3, 0
1608 ; GFX6-NEXT: s_add_i32 s2, s2, s4
1609 ; GFX6-NEXT: s_max_i32 s4, s3, 0
1610 ; GFX6-NEXT: s_sub_i32 s5, s9, s5
1611 ; GFX6-NEXT: s_sub_i32 s4, s8, s4
1612 ; GFX6-NEXT: s_max_i32 s5, s5, s7
1613 ; GFX6-NEXT: s_min_i32 s4, s5, s4
1614 ; GFX6-NEXT: s_add_i32 s3, s3, s4
1615 ; GFX6-NEXT: ; return to shader part epilog
1617 ; GFX8-LABEL: s_saddsat_v4i32:
1619 ; GFX8-NEXT: s_brev_b32 s9, 1
1620 ; GFX8-NEXT: s_min_i32 s11, s0, 0
1621 ; GFX8-NEXT: s_brev_b32 s8, -2
1622 ; GFX8-NEXT: s_max_i32 s10, s0, 0
1623 ; GFX8-NEXT: s_sub_i32 s11, s9, s11
1624 ; GFX8-NEXT: s_sub_i32 s10, s8, s10
1625 ; GFX8-NEXT: s_max_i32 s4, s11, s4
1626 ; GFX8-NEXT: s_min_i32 s4, s4, s10
1627 ; GFX8-NEXT: s_min_i32 s10, s1, 0
1628 ; GFX8-NEXT: s_add_i32 s0, s0, s4
1629 ; GFX8-NEXT: s_max_i32 s4, s1, 0
1630 ; GFX8-NEXT: s_sub_i32 s10, s9, s10
1631 ; GFX8-NEXT: s_sub_i32 s4, s8, s4
1632 ; GFX8-NEXT: s_max_i32 s5, s10, s5
1633 ; GFX8-NEXT: s_min_i32 s4, s5, s4
1634 ; GFX8-NEXT: s_min_i32 s5, s2, 0
1635 ; GFX8-NEXT: s_add_i32 s1, s1, s4
1636 ; GFX8-NEXT: s_max_i32 s4, s2, 0
1637 ; GFX8-NEXT: s_sub_i32 s5, s9, s5
1638 ; GFX8-NEXT: s_sub_i32 s4, s8, s4
1639 ; GFX8-NEXT: s_max_i32 s5, s5, s6
1640 ; GFX8-NEXT: s_min_i32 s4, s5, s4
1641 ; GFX8-NEXT: s_min_i32 s5, s3, 0
1642 ; GFX8-NEXT: s_add_i32 s2, s2, s4
1643 ; GFX8-NEXT: s_max_i32 s4, s3, 0
1644 ; GFX8-NEXT: s_sub_i32 s5, s9, s5
1645 ; GFX8-NEXT: s_sub_i32 s4, s8, s4
1646 ; GFX8-NEXT: s_max_i32 s5, s5, s7
1647 ; GFX8-NEXT: s_min_i32 s4, s5, s4
1648 ; GFX8-NEXT: s_add_i32 s3, s3, s4
1649 ; GFX8-NEXT: ; return to shader part epilog
1651 ; GFX9-LABEL: s_saddsat_v4i32:
1653 ; GFX9-NEXT: v_mov_b32_e32 v0, s4
1654 ; GFX9-NEXT: v_mov_b32_e32 v1, s5
1655 ; GFX9-NEXT: v_mov_b32_e32 v2, s6
1656 ; GFX9-NEXT: v_mov_b32_e32 v3, s7
1657 ; GFX9-NEXT: v_add_i32 v0, s0, v0 clamp
1658 ; GFX9-NEXT: v_add_i32 v1, s1, v1 clamp
1659 ; GFX9-NEXT: v_add_i32 v2, s2, v2 clamp
1660 ; GFX9-NEXT: v_add_i32 v3, s3, v3 clamp
1661 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
1662 ; GFX9-NEXT: v_readfirstlane_b32 s1, v1
1663 ; GFX9-NEXT: v_readfirstlane_b32 s2, v2
1664 ; GFX9-NEXT: v_readfirstlane_b32 s3, v3
1665 ; GFX9-NEXT: ; return to shader part epilog
1667 ; GFX10-LABEL: s_saddsat_v4i32:
1669 ; GFX10-NEXT: v_add_nc_i32 v0, s0, s4 clamp
1670 ; GFX10-NEXT: v_add_nc_i32 v1, s1, s5 clamp
1671 ; GFX10-NEXT: v_add_nc_i32 v2, s2, s6 clamp
1672 ; GFX10-NEXT: v_add_nc_i32 v3, s3, s7 clamp
1673 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
1674 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
1675 ; GFX10-NEXT: v_readfirstlane_b32 s2, v2
1676 ; GFX10-NEXT: v_readfirstlane_b32 s3, v3
1677 ; GFX10-NEXT: ; return to shader part epilog
1678 %result = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %lhs, <4 x i32> %rhs)
1679 ret <4 x i32> %result
1682 define <5 x i32> @v_saddsat_v5i32(<5 x i32> %lhs, <5 x i32> %rhs) {
1683 ; GFX6-LABEL: v_saddsat_v5i32:
1685 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1686 ; GFX6-NEXT: s_brev_b32 s5, 1
1687 ; GFX6-NEXT: v_min_i32_e32 v12, 0, v0
1688 ; GFX6-NEXT: s_brev_b32 s4, -2
1689 ; GFX6-NEXT: v_max_i32_e32 v10, 0, v0
1690 ; GFX6-NEXT: v_sub_i32_e32 v12, vcc, s5, v12
1691 ; GFX6-NEXT: v_sub_i32_e32 v10, vcc, s4, v10
1692 ; GFX6-NEXT: v_max_i32_e32 v5, v12, v5
1693 ; GFX6-NEXT: v_min_i32_e32 v5, v5, v10
1694 ; GFX6-NEXT: v_min_i32_e32 v10, 0, v1
1695 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v5
1696 ; GFX6-NEXT: v_max_i32_e32 v5, 0, v1
1697 ; GFX6-NEXT: v_sub_i32_e32 v10, vcc, s5, v10
1698 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, s4, v5
1699 ; GFX6-NEXT: v_max_i32_e32 v6, v10, v6
1700 ; GFX6-NEXT: v_min_i32_e32 v5, v6, v5
1701 ; GFX6-NEXT: v_min_i32_e32 v6, 0, v2
1702 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v5
1703 ; GFX6-NEXT: v_max_i32_e32 v5, 0, v2
1704 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, s5, v6
1705 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, s4, v5
1706 ; GFX6-NEXT: v_max_i32_e32 v6, v6, v7
1707 ; GFX6-NEXT: v_bfrev_b32_e32 v13, 1
1708 ; GFX6-NEXT: v_min_i32_e32 v5, v6, v5
1709 ; GFX6-NEXT: v_min_i32_e32 v6, 0, v3
1710 ; GFX6-NEXT: v_bfrev_b32_e32 v11, -2
1711 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v5
1712 ; GFX6-NEXT: v_max_i32_e32 v5, 0, v3
1713 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, v13, v6
1714 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, v11, v5
1715 ; GFX6-NEXT: v_max_i32_e32 v6, v6, v8
1716 ; GFX6-NEXT: v_min_i32_e32 v5, v6, v5
1717 ; GFX6-NEXT: v_min_i32_e32 v6, 0, v4
1718 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v5
1719 ; GFX6-NEXT: v_max_i32_e32 v5, 0, v4
1720 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, v13, v6
1721 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, v11, v5
1722 ; GFX6-NEXT: v_max_i32_e32 v6, v6, v9
1723 ; GFX6-NEXT: v_min_i32_e32 v5, v6, v5
1724 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v5
1725 ; GFX6-NEXT: s_setpc_b64 s[30:31]
1727 ; GFX8-LABEL: v_saddsat_v5i32:
1729 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1730 ; GFX8-NEXT: s_brev_b32 s5, 1
1731 ; GFX8-NEXT: v_min_i32_e32 v12, 0, v0
1732 ; GFX8-NEXT: s_brev_b32 s4, -2
1733 ; GFX8-NEXT: v_max_i32_e32 v10, 0, v0
1734 ; GFX8-NEXT: v_sub_u32_e32 v12, vcc, s5, v12
1735 ; GFX8-NEXT: v_sub_u32_e32 v10, vcc, s4, v10
1736 ; GFX8-NEXT: v_max_i32_e32 v5, v12, v5
1737 ; GFX8-NEXT: v_min_i32_e32 v5, v5, v10
1738 ; GFX8-NEXT: v_min_i32_e32 v10, 0, v1
1739 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, v0, v5
1740 ; GFX8-NEXT: v_max_i32_e32 v5, 0, v1
1741 ; GFX8-NEXT: v_sub_u32_e32 v10, vcc, s5, v10
1742 ; GFX8-NEXT: v_sub_u32_e32 v5, vcc, s4, v5
1743 ; GFX8-NEXT: v_max_i32_e32 v6, v10, v6
1744 ; GFX8-NEXT: v_min_i32_e32 v5, v6, v5
1745 ; GFX8-NEXT: v_min_i32_e32 v6, 0, v2
1746 ; GFX8-NEXT: v_add_u32_e32 v1, vcc, v1, v5
1747 ; GFX8-NEXT: v_max_i32_e32 v5, 0, v2
1748 ; GFX8-NEXT: v_sub_u32_e32 v6, vcc, s5, v6
1749 ; GFX8-NEXT: v_sub_u32_e32 v5, vcc, s4, v5
1750 ; GFX8-NEXT: v_max_i32_e32 v6, v6, v7
1751 ; GFX8-NEXT: v_bfrev_b32_e32 v13, 1
1752 ; GFX8-NEXT: v_min_i32_e32 v5, v6, v5
1753 ; GFX8-NEXT: v_min_i32_e32 v6, 0, v3
1754 ; GFX8-NEXT: v_bfrev_b32_e32 v11, -2
1755 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, v2, v5
1756 ; GFX8-NEXT: v_max_i32_e32 v5, 0, v3
1757 ; GFX8-NEXT: v_sub_u32_e32 v6, vcc, v13, v6
1758 ; GFX8-NEXT: v_sub_u32_e32 v5, vcc, v11, v5
1759 ; GFX8-NEXT: v_max_i32_e32 v6, v6, v8
1760 ; GFX8-NEXT: v_min_i32_e32 v5, v6, v5
1761 ; GFX8-NEXT: v_min_i32_e32 v6, 0, v4
1762 ; GFX8-NEXT: v_add_u32_e32 v3, vcc, v3, v5
1763 ; GFX8-NEXT: v_max_i32_e32 v5, 0, v4
1764 ; GFX8-NEXT: v_sub_u32_e32 v6, vcc, v13, v6
1765 ; GFX8-NEXT: v_sub_u32_e32 v5, vcc, v11, v5
1766 ; GFX8-NEXT: v_max_i32_e32 v6, v6, v9
1767 ; GFX8-NEXT: v_min_i32_e32 v5, v6, v5
1768 ; GFX8-NEXT: v_add_u32_e32 v4, vcc, v4, v5
1769 ; GFX8-NEXT: s_setpc_b64 s[30:31]
1771 ; GFX9-LABEL: v_saddsat_v5i32:
1773 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1774 ; GFX9-NEXT: v_add_i32 v0, v0, v5 clamp
1775 ; GFX9-NEXT: v_add_i32 v1, v1, v6 clamp
1776 ; GFX9-NEXT: v_add_i32 v2, v2, v7 clamp
1777 ; GFX9-NEXT: v_add_i32 v3, v3, v8 clamp
1778 ; GFX9-NEXT: v_add_i32 v4, v4, v9 clamp
1779 ; GFX9-NEXT: s_setpc_b64 s[30:31]
1781 ; GFX10-LABEL: v_saddsat_v5i32:
1783 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1784 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
1785 ; GFX10-NEXT: v_add_nc_i32 v0, v0, v5 clamp
1786 ; GFX10-NEXT: v_add_nc_i32 v1, v1, v6 clamp
1787 ; GFX10-NEXT: v_add_nc_i32 v2, v2, v7 clamp
1788 ; GFX10-NEXT: v_add_nc_i32 v3, v3, v8 clamp
1789 ; GFX10-NEXT: v_add_nc_i32 v4, v4, v9 clamp
1790 ; GFX10-NEXT: s_setpc_b64 s[30:31]
1791 %result = call <5 x i32> @llvm.sadd.sat.v5i32(<5 x i32> %lhs, <5 x i32> %rhs)
1792 ret <5 x i32> %result
1795 define amdgpu_ps <5 x i32> @s_saddsat_v5i32(<5 x i32> inreg %lhs, <5 x i32> inreg %rhs) {
1796 ; GFX6-LABEL: s_saddsat_v5i32:
1798 ; GFX6-NEXT: s_brev_b32 s11, 1
1799 ; GFX6-NEXT: s_min_i32 s13, s0, 0
1800 ; GFX6-NEXT: s_brev_b32 s10, -2
1801 ; GFX6-NEXT: s_max_i32 s12, s0, 0
1802 ; GFX6-NEXT: s_sub_i32 s13, s11, s13
1803 ; GFX6-NEXT: s_sub_i32 s12, s10, s12
1804 ; GFX6-NEXT: s_max_i32 s5, s13, s5
1805 ; GFX6-NEXT: s_min_i32 s5, s5, s12
1806 ; GFX6-NEXT: s_min_i32 s12, s1, 0
1807 ; GFX6-NEXT: s_add_i32 s0, s0, s5
1808 ; GFX6-NEXT: s_max_i32 s5, s1, 0
1809 ; GFX6-NEXT: s_sub_i32 s12, s11, s12
1810 ; GFX6-NEXT: s_sub_i32 s5, s10, s5
1811 ; GFX6-NEXT: s_max_i32 s6, s12, s6
1812 ; GFX6-NEXT: s_min_i32 s5, s6, s5
1813 ; GFX6-NEXT: s_min_i32 s6, s2, 0
1814 ; GFX6-NEXT: s_add_i32 s1, s1, s5
1815 ; GFX6-NEXT: s_max_i32 s5, s2, 0
1816 ; GFX6-NEXT: s_sub_i32 s6, s11, s6
1817 ; GFX6-NEXT: s_sub_i32 s5, s10, s5
1818 ; GFX6-NEXT: s_max_i32 s6, s6, s7
1819 ; GFX6-NEXT: s_min_i32 s5, s6, s5
1820 ; GFX6-NEXT: s_min_i32 s6, s3, 0
1821 ; GFX6-NEXT: s_add_i32 s2, s2, s5
1822 ; GFX6-NEXT: s_max_i32 s5, s3, 0
1823 ; GFX6-NEXT: s_sub_i32 s6, s11, s6
1824 ; GFX6-NEXT: s_sub_i32 s5, s10, s5
1825 ; GFX6-NEXT: s_max_i32 s6, s6, s8
1826 ; GFX6-NEXT: s_min_i32 s5, s6, s5
1827 ; GFX6-NEXT: s_min_i32 s6, s4, 0
1828 ; GFX6-NEXT: s_add_i32 s3, s3, s5
1829 ; GFX6-NEXT: s_max_i32 s5, s4, 0
1830 ; GFX6-NEXT: s_sub_i32 s6, s11, s6
1831 ; GFX6-NEXT: s_sub_i32 s5, s10, s5
1832 ; GFX6-NEXT: s_max_i32 s6, s6, s9
1833 ; GFX6-NEXT: s_min_i32 s5, s6, s5
1834 ; GFX6-NEXT: s_add_i32 s4, s4, s5
1835 ; GFX6-NEXT: ; return to shader part epilog
1837 ; GFX8-LABEL: s_saddsat_v5i32:
1839 ; GFX8-NEXT: s_brev_b32 s11, 1
1840 ; GFX8-NEXT: s_min_i32 s13, s0, 0
1841 ; GFX8-NEXT: s_brev_b32 s10, -2
1842 ; GFX8-NEXT: s_max_i32 s12, s0, 0
1843 ; GFX8-NEXT: s_sub_i32 s13, s11, s13
1844 ; GFX8-NEXT: s_sub_i32 s12, s10, s12
1845 ; GFX8-NEXT: s_max_i32 s5, s13, s5
1846 ; GFX8-NEXT: s_min_i32 s5, s5, s12
1847 ; GFX8-NEXT: s_min_i32 s12, s1, 0
1848 ; GFX8-NEXT: s_add_i32 s0, s0, s5
1849 ; GFX8-NEXT: s_max_i32 s5, s1, 0
1850 ; GFX8-NEXT: s_sub_i32 s12, s11, s12
1851 ; GFX8-NEXT: s_sub_i32 s5, s10, s5
1852 ; GFX8-NEXT: s_max_i32 s6, s12, s6
1853 ; GFX8-NEXT: s_min_i32 s5, s6, s5
1854 ; GFX8-NEXT: s_min_i32 s6, s2, 0
1855 ; GFX8-NEXT: s_add_i32 s1, s1, s5
1856 ; GFX8-NEXT: s_max_i32 s5, s2, 0
1857 ; GFX8-NEXT: s_sub_i32 s6, s11, s6
1858 ; GFX8-NEXT: s_sub_i32 s5, s10, s5
1859 ; GFX8-NEXT: s_max_i32 s6, s6, s7
1860 ; GFX8-NEXT: s_min_i32 s5, s6, s5
1861 ; GFX8-NEXT: s_min_i32 s6, s3, 0
1862 ; GFX8-NEXT: s_add_i32 s2, s2, s5
1863 ; GFX8-NEXT: s_max_i32 s5, s3, 0
1864 ; GFX8-NEXT: s_sub_i32 s6, s11, s6
1865 ; GFX8-NEXT: s_sub_i32 s5, s10, s5
1866 ; GFX8-NEXT: s_max_i32 s6, s6, s8
1867 ; GFX8-NEXT: s_min_i32 s5, s6, s5
1868 ; GFX8-NEXT: s_min_i32 s6, s4, 0
1869 ; GFX8-NEXT: s_add_i32 s3, s3, s5
1870 ; GFX8-NEXT: s_max_i32 s5, s4, 0
1871 ; GFX8-NEXT: s_sub_i32 s6, s11, s6
1872 ; GFX8-NEXT: s_sub_i32 s5, s10, s5
1873 ; GFX8-NEXT: s_max_i32 s6, s6, s9
1874 ; GFX8-NEXT: s_min_i32 s5, s6, s5
1875 ; GFX8-NEXT: s_add_i32 s4, s4, s5
1876 ; GFX8-NEXT: ; return to shader part epilog
1878 ; GFX9-LABEL: s_saddsat_v5i32:
1880 ; GFX9-NEXT: v_mov_b32_e32 v0, s5
1881 ; GFX9-NEXT: v_mov_b32_e32 v1, s6
1882 ; GFX9-NEXT: v_mov_b32_e32 v2, s7
1883 ; GFX9-NEXT: v_mov_b32_e32 v3, s8
1884 ; GFX9-NEXT: v_mov_b32_e32 v4, s9
1885 ; GFX9-NEXT: v_add_i32 v0, s0, v0 clamp
1886 ; GFX9-NEXT: v_add_i32 v1, s1, v1 clamp
1887 ; GFX9-NEXT: v_add_i32 v2, s2, v2 clamp
1888 ; GFX9-NEXT: v_add_i32 v3, s3, v3 clamp
1889 ; GFX9-NEXT: v_add_i32 v4, s4, v4 clamp
1890 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
1891 ; GFX9-NEXT: v_readfirstlane_b32 s1, v1
1892 ; GFX9-NEXT: v_readfirstlane_b32 s2, v2
1893 ; GFX9-NEXT: v_readfirstlane_b32 s3, v3
1894 ; GFX9-NEXT: v_readfirstlane_b32 s4, v4
1895 ; GFX9-NEXT: ; return to shader part epilog
1897 ; GFX10-LABEL: s_saddsat_v5i32:
1899 ; GFX10-NEXT: v_add_nc_i32 v0, s0, s5 clamp
1900 ; GFX10-NEXT: v_add_nc_i32 v1, s1, s6 clamp
1901 ; GFX10-NEXT: v_add_nc_i32 v2, s2, s7 clamp
1902 ; GFX10-NEXT: v_add_nc_i32 v3, s3, s8 clamp
1903 ; GFX10-NEXT: v_add_nc_i32 v4, s4, s9 clamp
1904 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
1905 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
1906 ; GFX10-NEXT: v_readfirstlane_b32 s2, v2
1907 ; GFX10-NEXT: v_readfirstlane_b32 s3, v3
1908 ; GFX10-NEXT: v_readfirstlane_b32 s4, v4
1909 ; GFX10-NEXT: ; return to shader part epilog
1910 %result = call <5 x i32> @llvm.sadd.sat.v5i32(<5 x i32> %lhs, <5 x i32> %rhs)
1911 ret <5 x i32> %result
1914 define <16 x i32> @v_saddsat_v16i32(<16 x i32> %lhs, <16 x i32> %rhs) {
1915 ; GFX6-LABEL: v_saddsat_v16i32:
1917 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
1918 ; GFX6-NEXT: s_brev_b32 s4, 1
1919 ; GFX6-NEXT: v_min_i32_e32 v31, 0, v0
1920 ; GFX6-NEXT: v_sub_i32_e32 v31, vcc, s4, v31
1921 ; GFX6-NEXT: v_max_i32_e32 v16, v31, v16
1922 ; GFX6-NEXT: s_brev_b32 s5, -2
1923 ; GFX6-NEXT: v_max_i32_e32 v31, 0, v0
1924 ; GFX6-NEXT: v_sub_i32_e32 v31, vcc, s5, v31
1925 ; GFX6-NEXT: v_min_i32_e32 v16, v16, v31
1926 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v16
1927 ; GFX6-NEXT: v_min_i32_e32 v16, 0, v1
1928 ; GFX6-NEXT: v_sub_i32_e32 v16, vcc, s4, v16
1929 ; GFX6-NEXT: v_max_i32_e32 v16, v16, v17
1930 ; GFX6-NEXT: v_max_i32_e32 v17, 0, v1
1931 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, s5, v17
1932 ; GFX6-NEXT: v_min_i32_e32 v16, v16, v17
1933 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v16
1934 ; GFX6-NEXT: v_min_i32_e32 v16, 0, v2
1935 ; GFX6-NEXT: v_sub_i32_e32 v16, vcc, s4, v16
1936 ; GFX6-NEXT: v_max_i32_e32 v17, 0, v2
1937 ; GFX6-NEXT: v_max_i32_e32 v16, v16, v18
1938 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, s5, v17
1939 ; GFX6-NEXT: v_min_i32_e32 v16, v16, v17
1940 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v16
1941 ; GFX6-NEXT: v_bfrev_b32_e32 v16, 1
1942 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v3
1943 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
1944 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v19
1945 ; GFX6-NEXT: v_bfrev_b32_e32 v18, -2
1946 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v3
1947 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
1948 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
1949 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v17
1950 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v4
1951 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
1952 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v20
1953 ; GFX6-NEXT: buffer_load_dword v20, off, s[0:3], s32
1954 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v4
1955 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
1956 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
1957 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v17
1958 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v5
1959 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
1960 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v5
1961 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v21
1962 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
1963 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
1964 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, v5, v17
1965 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v6
1966 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
1967 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v6
1968 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v22
1969 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
1970 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
1971 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, v6, v17
1972 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v7
1973 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
1974 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v7
1975 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v23
1976 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
1977 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
1978 ; GFX6-NEXT: v_add_i32_e32 v7, vcc, v7, v17
1979 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v8
1980 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
1981 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v8
1982 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v24
1983 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
1984 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
1985 ; GFX6-NEXT: v_add_i32_e32 v8, vcc, v8, v17
1986 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v9
1987 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
1988 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v9
1989 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v25
1990 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
1991 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
1992 ; GFX6-NEXT: v_add_i32_e32 v9, vcc, v9, v17
1993 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v10
1994 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
1995 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v10
1996 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v26
1997 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
1998 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
1999 ; GFX6-NEXT: v_add_i32_e32 v10, vcc, v10, v17
2000 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v11
2001 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
2002 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v11
2003 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v27
2004 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
2005 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
2006 ; GFX6-NEXT: v_add_i32_e32 v11, vcc, v11, v17
2007 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v12
2008 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
2009 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v12
2010 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v28
2011 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
2012 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
2013 ; GFX6-NEXT: v_add_i32_e32 v12, vcc, v12, v17
2014 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v13
2015 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
2016 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v13
2017 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v29
2018 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
2019 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
2020 ; GFX6-NEXT: v_add_i32_e32 v13, vcc, v13, v17
2021 ; GFX6-NEXT: v_min_i32_e32 v17, 0, v14
2022 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v16, v17
2023 ; GFX6-NEXT: v_max_i32_e32 v19, 0, v14
2024 ; GFX6-NEXT: v_max_i32_e32 v17, v17, v30
2025 ; GFX6-NEXT: v_sub_i32_e32 v19, vcc, v18, v19
2026 ; GFX6-NEXT: v_min_i32_e32 v17, v17, v19
2027 ; GFX6-NEXT: v_add_i32_e32 v14, vcc, v14, v17
2028 ; GFX6-NEXT: v_max_i32_e32 v17, 0, v15
2029 ; GFX6-NEXT: v_sub_i32_e32 v17, vcc, v18, v17
2030 ; GFX6-NEXT: v_min_i32_e32 v18, 0, v15
2031 ; GFX6-NEXT: v_sub_i32_e32 v16, vcc, v16, v18
2032 ; GFX6-NEXT: s_waitcnt vmcnt(0)
2033 ; GFX6-NEXT: v_max_i32_e32 v16, v16, v20
2034 ; GFX6-NEXT: v_min_i32_e32 v16, v16, v17
2035 ; GFX6-NEXT: v_add_i32_e32 v15, vcc, v15, v16
2036 ; GFX6-NEXT: s_setpc_b64 s[30:31]
2038 ; GFX8-LABEL: v_saddsat_v16i32:
2040 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
2041 ; GFX8-NEXT: s_brev_b32 s4, 1
2042 ; GFX8-NEXT: v_min_i32_e32 v31, 0, v0
2043 ; GFX8-NEXT: v_sub_u32_e32 v31, vcc, s4, v31
2044 ; GFX8-NEXT: v_max_i32_e32 v16, v31, v16
2045 ; GFX8-NEXT: s_brev_b32 s5, -2
2046 ; GFX8-NEXT: v_max_i32_e32 v31, 0, v0
2047 ; GFX8-NEXT: v_sub_u32_e32 v31, vcc, s5, v31
2048 ; GFX8-NEXT: v_min_i32_e32 v16, v16, v31
2049 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, v0, v16
2050 ; GFX8-NEXT: v_min_i32_e32 v16, 0, v1
2051 ; GFX8-NEXT: v_sub_u32_e32 v16, vcc, s4, v16
2052 ; GFX8-NEXT: v_max_i32_e32 v16, v16, v17
2053 ; GFX8-NEXT: v_max_i32_e32 v17, 0, v1
2054 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, s5, v17
2055 ; GFX8-NEXT: v_min_i32_e32 v16, v16, v17
2056 ; GFX8-NEXT: v_add_u32_e32 v1, vcc, v1, v16
2057 ; GFX8-NEXT: v_min_i32_e32 v16, 0, v2
2058 ; GFX8-NEXT: v_sub_u32_e32 v16, vcc, s4, v16
2059 ; GFX8-NEXT: v_max_i32_e32 v17, 0, v2
2060 ; GFX8-NEXT: v_max_i32_e32 v16, v16, v18
2061 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, s5, v17
2062 ; GFX8-NEXT: v_min_i32_e32 v16, v16, v17
2063 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, v2, v16
2064 ; GFX8-NEXT: v_bfrev_b32_e32 v16, 1
2065 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v3
2066 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2067 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v19
2068 ; GFX8-NEXT: v_bfrev_b32_e32 v18, -2
2069 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v3
2070 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2071 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2072 ; GFX8-NEXT: v_add_u32_e32 v3, vcc, v3, v17
2073 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v4
2074 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2075 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v20
2076 ; GFX8-NEXT: buffer_load_dword v20, off, s[0:3], s32
2077 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v4
2078 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2079 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2080 ; GFX8-NEXT: v_add_u32_e32 v4, vcc, v4, v17
2081 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v5
2082 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2083 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v5
2084 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v21
2085 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2086 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2087 ; GFX8-NEXT: v_add_u32_e32 v5, vcc, v5, v17
2088 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v6
2089 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2090 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v6
2091 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v22
2092 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2093 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2094 ; GFX8-NEXT: v_add_u32_e32 v6, vcc, v6, v17
2095 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v7
2096 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2097 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v7
2098 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v23
2099 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2100 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2101 ; GFX8-NEXT: v_add_u32_e32 v7, vcc, v7, v17
2102 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v8
2103 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2104 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v8
2105 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v24
2106 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2107 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2108 ; GFX8-NEXT: v_add_u32_e32 v8, vcc, v8, v17
2109 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v9
2110 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2111 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v9
2112 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v25
2113 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2114 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2115 ; GFX8-NEXT: v_add_u32_e32 v9, vcc, v9, v17
2116 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v10
2117 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2118 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v10
2119 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v26
2120 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2121 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2122 ; GFX8-NEXT: v_add_u32_e32 v10, vcc, v10, v17
2123 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v11
2124 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2125 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v11
2126 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v27
2127 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2128 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2129 ; GFX8-NEXT: v_add_u32_e32 v11, vcc, v11, v17
2130 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v12
2131 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2132 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v12
2133 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v28
2134 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2135 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2136 ; GFX8-NEXT: v_add_u32_e32 v12, vcc, v12, v17
2137 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v13
2138 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2139 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v13
2140 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v29
2141 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2142 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2143 ; GFX8-NEXT: v_add_u32_e32 v13, vcc, v13, v17
2144 ; GFX8-NEXT: v_min_i32_e32 v17, 0, v14
2145 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v16, v17
2146 ; GFX8-NEXT: v_max_i32_e32 v19, 0, v14
2147 ; GFX8-NEXT: v_max_i32_e32 v17, v17, v30
2148 ; GFX8-NEXT: v_sub_u32_e32 v19, vcc, v18, v19
2149 ; GFX8-NEXT: v_min_i32_e32 v17, v17, v19
2150 ; GFX8-NEXT: v_add_u32_e32 v14, vcc, v14, v17
2151 ; GFX8-NEXT: v_max_i32_e32 v17, 0, v15
2152 ; GFX8-NEXT: v_sub_u32_e32 v17, vcc, v18, v17
2153 ; GFX8-NEXT: v_min_i32_e32 v18, 0, v15
2154 ; GFX8-NEXT: v_sub_u32_e32 v16, vcc, v16, v18
2155 ; GFX8-NEXT: s_waitcnt vmcnt(0)
2156 ; GFX8-NEXT: v_max_i32_e32 v16, v16, v20
2157 ; GFX8-NEXT: v_min_i32_e32 v16, v16, v17
2158 ; GFX8-NEXT: v_add_u32_e32 v15, vcc, v15, v16
2159 ; GFX8-NEXT: s_setpc_b64 s[30:31]
2161 ; GFX9-LABEL: v_saddsat_v16i32:
2163 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
2164 ; GFX9-NEXT: v_add_i32 v0, v0, v16 clamp
2165 ; GFX9-NEXT: buffer_load_dword v16, off, s[0:3], s32
2166 ; GFX9-NEXT: v_add_i32 v1, v1, v17 clamp
2167 ; GFX9-NEXT: v_add_i32 v2, v2, v18 clamp
2168 ; GFX9-NEXT: v_add_i32 v3, v3, v19 clamp
2169 ; GFX9-NEXT: v_add_i32 v4, v4, v20 clamp
2170 ; GFX9-NEXT: v_add_i32 v5, v5, v21 clamp
2171 ; GFX9-NEXT: v_add_i32 v6, v6, v22 clamp
2172 ; GFX9-NEXT: v_add_i32 v7, v7, v23 clamp
2173 ; GFX9-NEXT: v_add_i32 v8, v8, v24 clamp
2174 ; GFX9-NEXT: v_add_i32 v9, v9, v25 clamp
2175 ; GFX9-NEXT: v_add_i32 v10, v10, v26 clamp
2176 ; GFX9-NEXT: v_add_i32 v11, v11, v27 clamp
2177 ; GFX9-NEXT: v_add_i32 v12, v12, v28 clamp
2178 ; GFX9-NEXT: v_add_i32 v13, v13, v29 clamp
2179 ; GFX9-NEXT: v_add_i32 v14, v14, v30 clamp
2180 ; GFX9-NEXT: s_waitcnt vmcnt(0)
2181 ; GFX9-NEXT: v_add_i32 v15, v15, v16 clamp
2182 ; GFX9-NEXT: s_setpc_b64 s[30:31]
2184 ; GFX10-LABEL: v_saddsat_v16i32:
2186 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
2187 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
2188 ; GFX10-NEXT: buffer_load_dword v31, off, s[0:3], s32
2189 ; GFX10-NEXT: v_add_nc_i32 v0, v0, v16 clamp
2190 ; GFX10-NEXT: v_add_nc_i32 v1, v1, v17 clamp
2191 ; GFX10-NEXT: v_add_nc_i32 v2, v2, v18 clamp
2192 ; GFX10-NEXT: v_add_nc_i32 v3, v3, v19 clamp
2193 ; GFX10-NEXT: v_add_nc_i32 v4, v4, v20 clamp
2194 ; GFX10-NEXT: v_add_nc_i32 v5, v5, v21 clamp
2195 ; GFX10-NEXT: v_add_nc_i32 v6, v6, v22 clamp
2196 ; GFX10-NEXT: v_add_nc_i32 v7, v7, v23 clamp
2197 ; GFX10-NEXT: v_add_nc_i32 v8, v8, v24 clamp
2198 ; GFX10-NEXT: v_add_nc_i32 v9, v9, v25 clamp
2199 ; GFX10-NEXT: v_add_nc_i32 v10, v10, v26 clamp
2200 ; GFX10-NEXT: v_add_nc_i32 v11, v11, v27 clamp
2201 ; GFX10-NEXT: v_add_nc_i32 v12, v12, v28 clamp
2202 ; GFX10-NEXT: v_add_nc_i32 v13, v13, v29 clamp
2203 ; GFX10-NEXT: v_add_nc_i32 v14, v14, v30 clamp
2204 ; GFX10-NEXT: s_waitcnt vmcnt(0)
2205 ; GFX10-NEXT: v_add_nc_i32 v15, v15, v31 clamp
2206 ; GFX10-NEXT: s_setpc_b64 s[30:31]
2207 %result = call <16 x i32> @llvm.sadd.sat.v16i32(<16 x i32> %lhs, <16 x i32> %rhs)
2208 ret <16 x i32> %result
2211 define amdgpu_ps <16 x i32> @s_saddsat_v16i32(<16 x i32> inreg %lhs, <16 x i32> inreg %rhs) {
2212 ; GFX6-LABEL: s_saddsat_v16i32:
2214 ; GFX6-NEXT: s_brev_b32 s33, 1
2215 ; GFX6-NEXT: s_min_i32 s35, s0, 0
2216 ; GFX6-NEXT: s_brev_b32 s32, -2
2217 ; GFX6-NEXT: s_max_i32 s34, s0, 0
2218 ; GFX6-NEXT: s_sub_i32 s35, s33, s35
2219 ; GFX6-NEXT: s_sub_i32 s34, s32, s34
2220 ; GFX6-NEXT: s_max_i32 s16, s35, s16
2221 ; GFX6-NEXT: s_min_i32 s16, s16, s34
2222 ; GFX6-NEXT: s_min_i32 s34, s1, 0
2223 ; GFX6-NEXT: s_add_i32 s0, s0, s16
2224 ; GFX6-NEXT: s_max_i32 s16, s1, 0
2225 ; GFX6-NEXT: s_sub_i32 s34, s33, s34
2226 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2227 ; GFX6-NEXT: s_max_i32 s17, s34, s17
2228 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2229 ; GFX6-NEXT: s_min_i32 s17, s2, 0
2230 ; GFX6-NEXT: s_add_i32 s1, s1, s16
2231 ; GFX6-NEXT: s_max_i32 s16, s2, 0
2232 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2233 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2234 ; GFX6-NEXT: s_max_i32 s17, s17, s18
2235 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2236 ; GFX6-NEXT: s_min_i32 s17, s3, 0
2237 ; GFX6-NEXT: s_add_i32 s2, s2, s16
2238 ; GFX6-NEXT: s_max_i32 s16, s3, 0
2239 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2240 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2241 ; GFX6-NEXT: s_max_i32 s17, s17, s19
2242 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2243 ; GFX6-NEXT: s_min_i32 s17, s4, 0
2244 ; GFX6-NEXT: s_add_i32 s3, s3, s16
2245 ; GFX6-NEXT: s_max_i32 s16, s4, 0
2246 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2247 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2248 ; GFX6-NEXT: s_max_i32 s17, s17, s20
2249 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2250 ; GFX6-NEXT: s_min_i32 s17, s5, 0
2251 ; GFX6-NEXT: s_add_i32 s4, s4, s16
2252 ; GFX6-NEXT: s_max_i32 s16, s5, 0
2253 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2254 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2255 ; GFX6-NEXT: s_max_i32 s17, s17, s21
2256 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2257 ; GFX6-NEXT: s_min_i32 s17, s6, 0
2258 ; GFX6-NEXT: s_add_i32 s5, s5, s16
2259 ; GFX6-NEXT: s_max_i32 s16, s6, 0
2260 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2261 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2262 ; GFX6-NEXT: s_max_i32 s17, s17, s22
2263 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2264 ; GFX6-NEXT: s_min_i32 s17, s7, 0
2265 ; GFX6-NEXT: s_add_i32 s6, s6, s16
2266 ; GFX6-NEXT: s_max_i32 s16, s7, 0
2267 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2268 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2269 ; GFX6-NEXT: s_max_i32 s17, s17, s23
2270 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2271 ; GFX6-NEXT: s_min_i32 s17, s8, 0
2272 ; GFX6-NEXT: s_add_i32 s7, s7, s16
2273 ; GFX6-NEXT: s_max_i32 s16, s8, 0
2274 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2275 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2276 ; GFX6-NEXT: s_max_i32 s17, s17, s24
2277 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2278 ; GFX6-NEXT: s_min_i32 s17, s9, 0
2279 ; GFX6-NEXT: s_add_i32 s8, s8, s16
2280 ; GFX6-NEXT: s_max_i32 s16, s9, 0
2281 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2282 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2283 ; GFX6-NEXT: s_max_i32 s17, s17, s25
2284 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2285 ; GFX6-NEXT: s_min_i32 s17, s10, 0
2286 ; GFX6-NEXT: s_add_i32 s9, s9, s16
2287 ; GFX6-NEXT: s_max_i32 s16, s10, 0
2288 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2289 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2290 ; GFX6-NEXT: s_max_i32 s17, s17, s26
2291 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2292 ; GFX6-NEXT: s_min_i32 s17, s11, 0
2293 ; GFX6-NEXT: s_add_i32 s10, s10, s16
2294 ; GFX6-NEXT: s_max_i32 s16, s11, 0
2295 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2296 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2297 ; GFX6-NEXT: s_max_i32 s17, s17, s27
2298 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2299 ; GFX6-NEXT: s_min_i32 s17, s12, 0
2300 ; GFX6-NEXT: s_add_i32 s11, s11, s16
2301 ; GFX6-NEXT: s_max_i32 s16, s12, 0
2302 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2303 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2304 ; GFX6-NEXT: s_max_i32 s17, s17, s28
2305 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2306 ; GFX6-NEXT: s_min_i32 s17, s13, 0
2307 ; GFX6-NEXT: s_add_i32 s12, s12, s16
2308 ; GFX6-NEXT: s_max_i32 s16, s13, 0
2309 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2310 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2311 ; GFX6-NEXT: s_max_i32 s17, s17, s29
2312 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2313 ; GFX6-NEXT: s_min_i32 s17, s14, 0
2314 ; GFX6-NEXT: s_add_i32 s13, s13, s16
2315 ; GFX6-NEXT: s_max_i32 s16, s14, 0
2316 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2317 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2318 ; GFX6-NEXT: s_max_i32 s17, s17, s30
2319 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2320 ; GFX6-NEXT: s_min_i32 s17, s15, 0
2321 ; GFX6-NEXT: s_add_i32 s14, s14, s16
2322 ; GFX6-NEXT: s_max_i32 s16, s15, 0
2323 ; GFX6-NEXT: s_sub_i32 s17, s33, s17
2324 ; GFX6-NEXT: s_sub_i32 s16, s32, s16
2325 ; GFX6-NEXT: s_max_i32 s17, s17, s31
2326 ; GFX6-NEXT: s_min_i32 s16, s17, s16
2327 ; GFX6-NEXT: s_add_i32 s15, s15, s16
2328 ; GFX6-NEXT: ; return to shader part epilog
2330 ; GFX8-LABEL: s_saddsat_v16i32:
2332 ; GFX8-NEXT: s_brev_b32 s33, 1
2333 ; GFX8-NEXT: s_min_i32 s35, s0, 0
2334 ; GFX8-NEXT: s_brev_b32 s32, -2
2335 ; GFX8-NEXT: s_max_i32 s34, s0, 0
2336 ; GFX8-NEXT: s_sub_i32 s35, s33, s35
2337 ; GFX8-NEXT: s_sub_i32 s34, s32, s34
2338 ; GFX8-NEXT: s_max_i32 s16, s35, s16
2339 ; GFX8-NEXT: s_min_i32 s16, s16, s34
2340 ; GFX8-NEXT: s_min_i32 s34, s1, 0
2341 ; GFX8-NEXT: s_add_i32 s0, s0, s16
2342 ; GFX8-NEXT: s_max_i32 s16, s1, 0
2343 ; GFX8-NEXT: s_sub_i32 s34, s33, s34
2344 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2345 ; GFX8-NEXT: s_max_i32 s17, s34, s17
2346 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2347 ; GFX8-NEXT: s_min_i32 s17, s2, 0
2348 ; GFX8-NEXT: s_add_i32 s1, s1, s16
2349 ; GFX8-NEXT: s_max_i32 s16, s2, 0
2350 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2351 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2352 ; GFX8-NEXT: s_max_i32 s17, s17, s18
2353 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2354 ; GFX8-NEXT: s_min_i32 s17, s3, 0
2355 ; GFX8-NEXT: s_add_i32 s2, s2, s16
2356 ; GFX8-NEXT: s_max_i32 s16, s3, 0
2357 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2358 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2359 ; GFX8-NEXT: s_max_i32 s17, s17, s19
2360 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2361 ; GFX8-NEXT: s_min_i32 s17, s4, 0
2362 ; GFX8-NEXT: s_add_i32 s3, s3, s16
2363 ; GFX8-NEXT: s_max_i32 s16, s4, 0
2364 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2365 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2366 ; GFX8-NEXT: s_max_i32 s17, s17, s20
2367 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2368 ; GFX8-NEXT: s_min_i32 s17, s5, 0
2369 ; GFX8-NEXT: s_add_i32 s4, s4, s16
2370 ; GFX8-NEXT: s_max_i32 s16, s5, 0
2371 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2372 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2373 ; GFX8-NEXT: s_max_i32 s17, s17, s21
2374 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2375 ; GFX8-NEXT: s_min_i32 s17, s6, 0
2376 ; GFX8-NEXT: s_add_i32 s5, s5, s16
2377 ; GFX8-NEXT: s_max_i32 s16, s6, 0
2378 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2379 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2380 ; GFX8-NEXT: s_max_i32 s17, s17, s22
2381 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2382 ; GFX8-NEXT: s_min_i32 s17, s7, 0
2383 ; GFX8-NEXT: s_add_i32 s6, s6, s16
2384 ; GFX8-NEXT: s_max_i32 s16, s7, 0
2385 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2386 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2387 ; GFX8-NEXT: s_max_i32 s17, s17, s23
2388 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2389 ; GFX8-NEXT: s_min_i32 s17, s8, 0
2390 ; GFX8-NEXT: s_add_i32 s7, s7, s16
2391 ; GFX8-NEXT: s_max_i32 s16, s8, 0
2392 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2393 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2394 ; GFX8-NEXT: s_max_i32 s17, s17, s24
2395 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2396 ; GFX8-NEXT: s_min_i32 s17, s9, 0
2397 ; GFX8-NEXT: s_add_i32 s8, s8, s16
2398 ; GFX8-NEXT: s_max_i32 s16, s9, 0
2399 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2400 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2401 ; GFX8-NEXT: s_max_i32 s17, s17, s25
2402 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2403 ; GFX8-NEXT: s_min_i32 s17, s10, 0
2404 ; GFX8-NEXT: s_add_i32 s9, s9, s16
2405 ; GFX8-NEXT: s_max_i32 s16, s10, 0
2406 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2407 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2408 ; GFX8-NEXT: s_max_i32 s17, s17, s26
2409 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2410 ; GFX8-NEXT: s_min_i32 s17, s11, 0
2411 ; GFX8-NEXT: s_add_i32 s10, s10, s16
2412 ; GFX8-NEXT: s_max_i32 s16, s11, 0
2413 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2414 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2415 ; GFX8-NEXT: s_max_i32 s17, s17, s27
2416 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2417 ; GFX8-NEXT: s_min_i32 s17, s12, 0
2418 ; GFX8-NEXT: s_add_i32 s11, s11, s16
2419 ; GFX8-NEXT: s_max_i32 s16, s12, 0
2420 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2421 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2422 ; GFX8-NEXT: s_max_i32 s17, s17, s28
2423 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2424 ; GFX8-NEXT: s_min_i32 s17, s13, 0
2425 ; GFX8-NEXT: s_add_i32 s12, s12, s16
2426 ; GFX8-NEXT: s_max_i32 s16, s13, 0
2427 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2428 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2429 ; GFX8-NEXT: s_max_i32 s17, s17, s29
2430 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2431 ; GFX8-NEXT: s_min_i32 s17, s14, 0
2432 ; GFX8-NEXT: s_add_i32 s13, s13, s16
2433 ; GFX8-NEXT: s_max_i32 s16, s14, 0
2434 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2435 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2436 ; GFX8-NEXT: s_max_i32 s17, s17, s30
2437 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2438 ; GFX8-NEXT: s_min_i32 s17, s15, 0
2439 ; GFX8-NEXT: s_add_i32 s14, s14, s16
2440 ; GFX8-NEXT: s_max_i32 s16, s15, 0
2441 ; GFX8-NEXT: s_sub_i32 s17, s33, s17
2442 ; GFX8-NEXT: s_sub_i32 s16, s32, s16
2443 ; GFX8-NEXT: s_max_i32 s17, s17, s31
2444 ; GFX8-NEXT: s_min_i32 s16, s17, s16
2445 ; GFX8-NEXT: s_add_i32 s15, s15, s16
2446 ; GFX8-NEXT: ; return to shader part epilog
2448 ; GFX9-LABEL: s_saddsat_v16i32:
2450 ; GFX9-NEXT: v_mov_b32_e32 v0, s16
2451 ; GFX9-NEXT: v_mov_b32_e32 v1, s17
2452 ; GFX9-NEXT: v_mov_b32_e32 v2, s18
2453 ; GFX9-NEXT: v_mov_b32_e32 v3, s19
2454 ; GFX9-NEXT: v_mov_b32_e32 v4, s20
2455 ; GFX9-NEXT: v_mov_b32_e32 v5, s21
2456 ; GFX9-NEXT: v_mov_b32_e32 v6, s22
2457 ; GFX9-NEXT: v_mov_b32_e32 v7, s23
2458 ; GFX9-NEXT: v_mov_b32_e32 v8, s24
2459 ; GFX9-NEXT: v_mov_b32_e32 v9, s25
2460 ; GFX9-NEXT: v_mov_b32_e32 v10, s26
2461 ; GFX9-NEXT: v_mov_b32_e32 v11, s27
2462 ; GFX9-NEXT: v_mov_b32_e32 v12, s28
2463 ; GFX9-NEXT: v_mov_b32_e32 v13, s29
2464 ; GFX9-NEXT: v_mov_b32_e32 v14, s30
2465 ; GFX9-NEXT: v_mov_b32_e32 v15, s31
2466 ; GFX9-NEXT: v_add_i32 v0, s0, v0 clamp
2467 ; GFX9-NEXT: v_add_i32 v1, s1, v1 clamp
2468 ; GFX9-NEXT: v_add_i32 v2, s2, v2 clamp
2469 ; GFX9-NEXT: v_add_i32 v3, s3, v3 clamp
2470 ; GFX9-NEXT: v_add_i32 v4, s4, v4 clamp
2471 ; GFX9-NEXT: v_add_i32 v5, s5, v5 clamp
2472 ; GFX9-NEXT: v_add_i32 v6, s6, v6 clamp
2473 ; GFX9-NEXT: v_add_i32 v7, s7, v7 clamp
2474 ; GFX9-NEXT: v_add_i32 v8, s8, v8 clamp
2475 ; GFX9-NEXT: v_add_i32 v9, s9, v9 clamp
2476 ; GFX9-NEXT: v_add_i32 v10, s10, v10 clamp
2477 ; GFX9-NEXT: v_add_i32 v11, s11, v11 clamp
2478 ; GFX9-NEXT: v_add_i32 v12, s12, v12 clamp
2479 ; GFX9-NEXT: v_add_i32 v13, s13, v13 clamp
2480 ; GFX9-NEXT: v_add_i32 v14, s14, v14 clamp
2481 ; GFX9-NEXT: v_add_i32 v15, s15, v15 clamp
2482 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
2483 ; GFX9-NEXT: v_readfirstlane_b32 s1, v1
2484 ; GFX9-NEXT: v_readfirstlane_b32 s2, v2
2485 ; GFX9-NEXT: v_readfirstlane_b32 s3, v3
2486 ; GFX9-NEXT: v_readfirstlane_b32 s4, v4
2487 ; GFX9-NEXT: v_readfirstlane_b32 s5, v5
2488 ; GFX9-NEXT: v_readfirstlane_b32 s6, v6
2489 ; GFX9-NEXT: v_readfirstlane_b32 s7, v7
2490 ; GFX9-NEXT: v_readfirstlane_b32 s8, v8
2491 ; GFX9-NEXT: v_readfirstlane_b32 s9, v9
2492 ; GFX9-NEXT: v_readfirstlane_b32 s10, v10
2493 ; GFX9-NEXT: v_readfirstlane_b32 s11, v11
2494 ; GFX9-NEXT: v_readfirstlane_b32 s12, v12
2495 ; GFX9-NEXT: v_readfirstlane_b32 s13, v13
2496 ; GFX9-NEXT: v_readfirstlane_b32 s14, v14
2497 ; GFX9-NEXT: v_readfirstlane_b32 s15, v15
2498 ; GFX9-NEXT: ; return to shader part epilog
2500 ; GFX10-LABEL: s_saddsat_v16i32:
2502 ; GFX10-NEXT: v_add_nc_i32 v0, s0, s16 clamp
2503 ; GFX10-NEXT: v_add_nc_i32 v1, s1, s17 clamp
2504 ; GFX10-NEXT: v_add_nc_i32 v2, s2, s18 clamp
2505 ; GFX10-NEXT: v_add_nc_i32 v3, s3, s19 clamp
2506 ; GFX10-NEXT: v_add_nc_i32 v4, s4, s20 clamp
2507 ; GFX10-NEXT: v_add_nc_i32 v5, s5, s21 clamp
2508 ; GFX10-NEXT: v_add_nc_i32 v6, s6, s22 clamp
2509 ; GFX10-NEXT: v_add_nc_i32 v7, s7, s23 clamp
2510 ; GFX10-NEXT: v_add_nc_i32 v8, s8, s24 clamp
2511 ; GFX10-NEXT: v_add_nc_i32 v9, s9, s25 clamp
2512 ; GFX10-NEXT: v_add_nc_i32 v10, s10, s26 clamp
2513 ; GFX10-NEXT: v_add_nc_i32 v11, s11, s27 clamp
2514 ; GFX10-NEXT: v_add_nc_i32 v12, s12, s28 clamp
2515 ; GFX10-NEXT: v_add_nc_i32 v13, s13, s29 clamp
2516 ; GFX10-NEXT: v_add_nc_i32 v14, s14, s30 clamp
2517 ; GFX10-NEXT: v_add_nc_i32 v15, s15, s31 clamp
2518 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
2519 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
2520 ; GFX10-NEXT: v_readfirstlane_b32 s2, v2
2521 ; GFX10-NEXT: v_readfirstlane_b32 s3, v3
2522 ; GFX10-NEXT: v_readfirstlane_b32 s4, v4
2523 ; GFX10-NEXT: v_readfirstlane_b32 s5, v5
2524 ; GFX10-NEXT: v_readfirstlane_b32 s6, v6
2525 ; GFX10-NEXT: v_readfirstlane_b32 s7, v7
2526 ; GFX10-NEXT: v_readfirstlane_b32 s8, v8
2527 ; GFX10-NEXT: v_readfirstlane_b32 s9, v9
2528 ; GFX10-NEXT: v_readfirstlane_b32 s10, v10
2529 ; GFX10-NEXT: v_readfirstlane_b32 s11, v11
2530 ; GFX10-NEXT: v_readfirstlane_b32 s12, v12
2531 ; GFX10-NEXT: v_readfirstlane_b32 s13, v13
2532 ; GFX10-NEXT: v_readfirstlane_b32 s14, v14
2533 ; GFX10-NEXT: v_readfirstlane_b32 s15, v15
2534 ; GFX10-NEXT: ; return to shader part epilog
2535 %result = call <16 x i32> @llvm.sadd.sat.v16i32(<16 x i32> %lhs, <16 x i32> %rhs)
2536 ret <16 x i32> %result
2539 define i16 @v_saddsat_i16(i16 %lhs, i16 %rhs) {
2540 ; GFX6-LABEL: v_saddsat_i16:
2542 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
2543 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 16, v0
2544 ; GFX6-NEXT: v_min_i32_e32 v3, 0, v0
2545 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
2546 ; GFX6-NEXT: v_max_i32_e32 v2, 0, v0
2547 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, 0x80000000, v3
2548 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, 0x7fffffff, v2
2549 ; GFX6-NEXT: v_max_i32_e32 v1, v3, v1
2550 ; GFX6-NEXT: v_min_i32_e32 v1, v1, v2
2551 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
2552 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 16, v0
2553 ; GFX6-NEXT: s_setpc_b64 s[30:31]
2555 ; GFX8-LABEL: v_saddsat_i16:
2557 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
2558 ; GFX8-NEXT: v_min_i16_e32 v3, 0, v0
2559 ; GFX8-NEXT: v_max_i16_e32 v2, 0, v0
2560 ; GFX8-NEXT: v_sub_u16_e32 v3, 0x8000, v3
2561 ; GFX8-NEXT: v_sub_u16_e32 v2, 0x7fff, v2
2562 ; GFX8-NEXT: v_max_i16_e32 v1, v3, v1
2563 ; GFX8-NEXT: v_min_i16_e32 v1, v1, v2
2564 ; GFX8-NEXT: v_add_u16_e32 v0, v0, v1
2565 ; GFX8-NEXT: s_setpc_b64 s[30:31]
2567 ; GFX9-LABEL: v_saddsat_i16:
2569 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
2570 ; GFX9-NEXT: v_add_i16 v0, v0, v1 clamp
2571 ; GFX9-NEXT: s_setpc_b64 s[30:31]
2573 ; GFX10-LABEL: v_saddsat_i16:
2575 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
2576 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
2577 ; GFX10-NEXT: v_add_nc_i16 v0, v0, v1 clamp
2578 ; GFX10-NEXT: s_setpc_b64 s[30:31]
2579 %result = call i16 @llvm.sadd.sat.i16(i16 %lhs, i16 %rhs)
2583 define amdgpu_ps i16 @s_saddsat_i16(i16 inreg %lhs, i16 inreg %rhs) {
2584 ; GFX6-LABEL: s_saddsat_i16:
2586 ; GFX6-NEXT: s_lshl_b32 s0, s0, 16
2587 ; GFX6-NEXT: s_min_i32 s3, s0, 0
2588 ; GFX6-NEXT: s_lshl_b32 s1, s1, 16
2589 ; GFX6-NEXT: s_max_i32 s2, s0, 0
2590 ; GFX6-NEXT: s_sub_i32 s3, 0x80000000, s3
2591 ; GFX6-NEXT: s_sub_i32 s2, 0x7fffffff, s2
2592 ; GFX6-NEXT: s_max_i32 s1, s3, s1
2593 ; GFX6-NEXT: s_min_i32 s1, s1, s2
2594 ; GFX6-NEXT: s_add_i32 s0, s0, s1
2595 ; GFX6-NEXT: s_ashr_i32 s0, s0, 16
2596 ; GFX6-NEXT: ; return to shader part epilog
2598 ; GFX8-LABEL: s_saddsat_i16:
2600 ; GFX8-NEXT: s_sext_i32_i16 s2, s0
2601 ; GFX8-NEXT: s_sext_i32_i16 s3, 0
2602 ; GFX8-NEXT: s_max_i32 s4, s2, s3
2603 ; GFX8-NEXT: s_min_i32 s2, s2, s3
2604 ; GFX8-NEXT: s_sub_i32 s2, 0xffff8000, s2
2605 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
2606 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
2607 ; GFX8-NEXT: s_sub_i32 s4, 0x7fff, s4
2608 ; GFX8-NEXT: s_max_i32 s1, s2, s1
2609 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
2610 ; GFX8-NEXT: s_sext_i32_i16 s2, s4
2611 ; GFX8-NEXT: s_min_i32 s1, s1, s2
2612 ; GFX8-NEXT: s_add_i32 s0, s0, s1
2613 ; GFX8-NEXT: ; return to shader part epilog
2615 ; GFX9-LABEL: s_saddsat_i16:
2617 ; GFX9-NEXT: v_mov_b32_e32 v0, s1
2618 ; GFX9-NEXT: v_add_i16 v0, s0, v0 clamp
2619 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
2620 ; GFX9-NEXT: ; return to shader part epilog
2622 ; GFX10-LABEL: s_saddsat_i16:
2624 ; GFX10-NEXT: v_add_nc_i16 v0, s0, s1 clamp
2625 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
2626 ; GFX10-NEXT: ; return to shader part epilog
2627 %result = call i16 @llvm.sadd.sat.i16(i16 %lhs, i16 %rhs)
2631 define amdgpu_ps half @saddsat_i16_sv(i16 inreg %lhs, i16 %rhs) {
2632 ; GFX6-LABEL: saddsat_i16_sv:
2634 ; GFX6-NEXT: s_lshl_b32 s0, s0, 16
2635 ; GFX6-NEXT: s_min_i32 s2, s0, 0
2636 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 16, v0
2637 ; GFX6-NEXT: s_max_i32 s1, s0, 0
2638 ; GFX6-NEXT: s_sub_i32 s2, 0x80000000, s2
2639 ; GFX6-NEXT: s_sub_i32 s1, 0x7fffffff, s1
2640 ; GFX6-NEXT: v_max_i32_e32 v0, s2, v0
2641 ; GFX6-NEXT: v_min_i32_e32 v0, s1, v0
2642 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s0, v0
2643 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 16, v0
2644 ; GFX6-NEXT: ; return to shader part epilog
2646 ; GFX8-LABEL: saddsat_i16_sv:
2648 ; GFX8-NEXT: s_sext_i32_i16 s1, s0
2649 ; GFX8-NEXT: s_sext_i32_i16 s2, 0
2650 ; GFX8-NEXT: s_max_i32 s3, s1, s2
2651 ; GFX8-NEXT: s_min_i32 s1, s1, s2
2652 ; GFX8-NEXT: s_sub_i32 s1, 0xffff8000, s1
2653 ; GFX8-NEXT: s_sub_i32 s3, 0x7fff, s3
2654 ; GFX8-NEXT: v_max_i16_e32 v0, s1, v0
2655 ; GFX8-NEXT: v_min_i16_e32 v0, s3, v0
2656 ; GFX8-NEXT: v_add_u16_e32 v0, s0, v0
2657 ; GFX8-NEXT: ; return to shader part epilog
2659 ; GFX9-LABEL: saddsat_i16_sv:
2661 ; GFX9-NEXT: v_add_i16 v0, s0, v0 clamp
2662 ; GFX9-NEXT: ; return to shader part epilog
2664 ; GFX10-LABEL: saddsat_i16_sv:
2666 ; GFX10-NEXT: v_add_nc_i16 v0, s0, v0 clamp
2667 ; GFX10-NEXT: ; return to shader part epilog
2668 %result = call i16 @llvm.sadd.sat.i16(i16 %lhs, i16 %rhs)
2669 %cast = bitcast i16 %result to half
2673 define amdgpu_ps half @saddsat_i16_vs(i16 %lhs, i16 inreg %rhs) {
2674 ; GFX6-LABEL: saddsat_i16_vs:
2676 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 16, v0
2677 ; GFX6-NEXT: v_min_i32_e32 v2, 0, v0
2678 ; GFX6-NEXT: s_lshl_b32 s0, s0, 16
2679 ; GFX6-NEXT: v_max_i32_e32 v1, 0, v0
2680 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, 0x80000000, v2
2681 ; GFX6-NEXT: v_sub_i32_e32 v1, vcc, 0x7fffffff, v1
2682 ; GFX6-NEXT: v_max_i32_e32 v2, s0, v2
2683 ; GFX6-NEXT: v_min_i32_e32 v1, v2, v1
2684 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v1
2685 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 16, v0
2686 ; GFX6-NEXT: ; return to shader part epilog
2688 ; GFX8-LABEL: saddsat_i16_vs:
2690 ; GFX8-NEXT: v_min_i16_e32 v2, 0, v0
2691 ; GFX8-NEXT: v_max_i16_e32 v1, 0, v0
2692 ; GFX8-NEXT: v_sub_u16_e32 v2, 0x8000, v2
2693 ; GFX8-NEXT: v_sub_u16_e32 v1, 0x7fff, v1
2694 ; GFX8-NEXT: v_max_i16_e32 v2, s0, v2
2695 ; GFX8-NEXT: v_min_i16_e32 v1, v2, v1
2696 ; GFX8-NEXT: v_add_u16_e32 v0, v0, v1
2697 ; GFX8-NEXT: ; return to shader part epilog
2699 ; GFX9-LABEL: saddsat_i16_vs:
2701 ; GFX9-NEXT: v_add_i16 v0, v0, s0 clamp
2702 ; GFX9-NEXT: ; return to shader part epilog
2704 ; GFX10-LABEL: saddsat_i16_vs:
2706 ; GFX10-NEXT: v_add_nc_i16 v0, v0, s0 clamp
2707 ; GFX10-NEXT: ; return to shader part epilog
2708 %result = call i16 @llvm.sadd.sat.i16(i16 %lhs, i16 %rhs)
2709 %cast = bitcast i16 %result to half
2713 define <2 x i16> @v_saddsat_v2i16(<2 x i16> %lhs, <2 x i16> %rhs) {
2714 ; GFX6-LABEL: v_saddsat_v2i16:
2716 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
2717 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 16, v0
2718 ; GFX6-NEXT: s_brev_b32 s5, 1
2719 ; GFX6-NEXT: v_min_i32_e32 v5, 0, v0
2720 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
2721 ; GFX6-NEXT: s_brev_b32 s4, -2
2722 ; GFX6-NEXT: v_max_i32_e32 v4, 0, v0
2723 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, s5, v5
2724 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s4, v4
2725 ; GFX6-NEXT: v_max_i32_e32 v2, v5, v2
2726 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
2727 ; GFX6-NEXT: v_min_i32_e32 v2, v2, v4
2728 ; GFX6-NEXT: v_min_i32_e32 v4, 0, v1
2729 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
2730 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v3
2731 ; GFX6-NEXT: v_max_i32_e32 v3, 0, v1
2732 ; GFX6-NEXT: v_sub_i32_e32 v4, vcc, s5, v4
2733 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, s4, v3
2734 ; GFX6-NEXT: v_max_i32_e32 v2, v4, v2
2735 ; GFX6-NEXT: v_min_i32_e32 v2, v2, v3
2736 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v2
2737 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 16, v0
2738 ; GFX6-NEXT: v_ashrrev_i32_e32 v1, 16, v1
2739 ; GFX6-NEXT: s_setpc_b64 s[30:31]
2741 ; GFX8-LABEL: v_saddsat_v2i16:
2743 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
2744 ; GFX8-NEXT: s_movk_i32 s5, 0x8000
2745 ; GFX8-NEXT: v_min_i16_e32 v4, 0, v0
2746 ; GFX8-NEXT: v_lshrrev_b32_e32 v2, 16, v0
2747 ; GFX8-NEXT: s_movk_i32 s4, 0x7fff
2748 ; GFX8-NEXT: v_max_i16_e32 v3, 0, v0
2749 ; GFX8-NEXT: v_sub_u16_e32 v4, s5, v4
2750 ; GFX8-NEXT: v_sub_u16_e32 v3, s4, v3
2751 ; GFX8-NEXT: v_max_i16_e32 v4, v4, v1
2752 ; GFX8-NEXT: v_min_i16_e32 v5, 0, v2
2753 ; GFX8-NEXT: v_min_i16_e32 v3, v4, v3
2754 ; GFX8-NEXT: v_max_i16_e32 v4, 0, v2
2755 ; GFX8-NEXT: v_sub_u16_e32 v5, s5, v5
2756 ; GFX8-NEXT: v_sub_u16_e32 v4, s4, v4
2757 ; GFX8-NEXT: v_max_i16_sdwa v1, v5, v1 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
2758 ; GFX8-NEXT: v_min_i16_e32 v1, v1, v4
2759 ; GFX8-NEXT: v_add_u16_e32 v0, v0, v3
2760 ; GFX8-NEXT: v_add_u16_sdwa v1, v2, v1 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
2761 ; GFX8-NEXT: v_or_b32_e32 v0, v0, v1
2762 ; GFX8-NEXT: s_setpc_b64 s[30:31]
2764 ; GFX9-LABEL: v_saddsat_v2i16:
2766 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
2767 ; GFX9-NEXT: v_pk_add_i16 v0, v0, v1 clamp
2768 ; GFX9-NEXT: s_setpc_b64 s[30:31]
2770 ; GFX10-LABEL: v_saddsat_v2i16:
2772 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
2773 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
2774 ; GFX10-NEXT: v_pk_add_i16 v0, v0, v1 clamp
2775 ; GFX10-NEXT: s_setpc_b64 s[30:31]
2776 %result = call <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16> %lhs, <2 x i16> %rhs)
2777 ret <2 x i16> %result
2780 define amdgpu_ps i32 @s_saddsat_v2i16(<2 x i16> inreg %lhs, <2 x i16> inreg %rhs) {
2781 ; GFX6-LABEL: s_saddsat_v2i16:
2783 ; GFX6-NEXT: s_lshl_b32 s0, s0, 16
2784 ; GFX6-NEXT: s_brev_b32 s5, 1
2785 ; GFX6-NEXT: s_min_i32 s7, s0, 0
2786 ; GFX6-NEXT: s_lshl_b32 s2, s2, 16
2787 ; GFX6-NEXT: s_brev_b32 s4, -2
2788 ; GFX6-NEXT: s_max_i32 s6, s0, 0
2789 ; GFX6-NEXT: s_sub_i32 s7, s5, s7
2790 ; GFX6-NEXT: s_sub_i32 s6, s4, s6
2791 ; GFX6-NEXT: s_max_i32 s2, s7, s2
2792 ; GFX6-NEXT: s_min_i32 s2, s2, s6
2793 ; GFX6-NEXT: s_lshl_b32 s1, s1, 16
2794 ; GFX6-NEXT: s_add_i32 s0, s0, s2
2795 ; GFX6-NEXT: s_lshl_b32 s2, s3, 16
2796 ; GFX6-NEXT: s_max_i32 s3, s1, 0
2797 ; GFX6-NEXT: s_sub_i32 s3, s4, s3
2798 ; GFX6-NEXT: s_min_i32 s4, s1, 0
2799 ; GFX6-NEXT: s_sub_i32 s4, s5, s4
2800 ; GFX6-NEXT: s_max_i32 s2, s4, s2
2801 ; GFX6-NEXT: s_min_i32 s2, s2, s3
2802 ; GFX6-NEXT: s_add_i32 s1, s1, s2
2803 ; GFX6-NEXT: s_ashr_i32 s1, s1, 16
2804 ; GFX6-NEXT: s_mov_b32 s2, 0xffff
2805 ; GFX6-NEXT: s_ashr_i32 s0, s0, 16
2806 ; GFX6-NEXT: s_and_b32 s1, s1, s2
2807 ; GFX6-NEXT: s_and_b32 s0, s0, s2
2808 ; GFX6-NEXT: s_lshl_b32 s1, s1, 16
2809 ; GFX6-NEXT: s_or_b32 s0, s0, s1
2810 ; GFX6-NEXT: ; return to shader part epilog
2812 ; GFX8-LABEL: s_saddsat_v2i16:
2814 ; GFX8-NEXT: s_sext_i32_i16 s6, s0
2815 ; GFX8-NEXT: s_sext_i32_i16 s7, 0
2816 ; GFX8-NEXT: s_movk_i32 s5, 0x8000
2817 ; GFX8-NEXT: s_max_i32 s8, s6, s7
2818 ; GFX8-NEXT: s_min_i32 s6, s6, s7
2819 ; GFX8-NEXT: s_sub_i32 s6, s5, s6
2820 ; GFX8-NEXT: s_lshr_b32 s3, s1, 16
2821 ; GFX8-NEXT: s_movk_i32 s4, 0x7fff
2822 ; GFX8-NEXT: s_sext_i32_i16 s6, s6
2823 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
2824 ; GFX8-NEXT: s_sub_i32 s8, s4, s8
2825 ; GFX8-NEXT: s_max_i32 s1, s6, s1
2826 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
2827 ; GFX8-NEXT: s_sext_i32_i16 s6, s8
2828 ; GFX8-NEXT: s_lshr_b32 s2, s0, 16
2829 ; GFX8-NEXT: s_min_i32 s1, s1, s6
2830 ; GFX8-NEXT: s_add_i32 s0, s0, s1
2831 ; GFX8-NEXT: s_sext_i32_i16 s1, s2
2832 ; GFX8-NEXT: s_max_i32 s6, s1, s7
2833 ; GFX8-NEXT: s_min_i32 s1, s1, s7
2834 ; GFX8-NEXT: s_sub_i32 s1, s5, s1
2835 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
2836 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
2837 ; GFX8-NEXT: s_sub_i32 s4, s4, s6
2838 ; GFX8-NEXT: s_max_i32 s1, s1, s3
2839 ; GFX8-NEXT: s_sext_i32_i16 s1, s1
2840 ; GFX8-NEXT: s_sext_i32_i16 s3, s4
2841 ; GFX8-NEXT: s_min_i32 s1, s1, s3
2842 ; GFX8-NEXT: s_add_i32 s2, s2, s1
2843 ; GFX8-NEXT: s_bfe_u32 s1, s2, 0x100000
2844 ; GFX8-NEXT: s_bfe_u32 s0, s0, 0x100000
2845 ; GFX8-NEXT: s_lshl_b32 s1, s1, 16
2846 ; GFX8-NEXT: s_or_b32 s0, s0, s1
2847 ; GFX8-NEXT: ; return to shader part epilog
2849 ; GFX9-LABEL: s_saddsat_v2i16:
2851 ; GFX9-NEXT: v_mov_b32_e32 v0, s1
2852 ; GFX9-NEXT: v_pk_add_i16 v0, s0, v0 clamp
2853 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
2854 ; GFX9-NEXT: ; return to shader part epilog
2856 ; GFX10-LABEL: s_saddsat_v2i16:
2858 ; GFX10-NEXT: v_pk_add_i16 v0, s0, s1 clamp
2859 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
2860 ; GFX10-NEXT: ; return to shader part epilog
2861 %result = call <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16> %lhs, <2 x i16> %rhs)
2862 %cast = bitcast <2 x i16> %result to i32
2866 define amdgpu_ps float @saddsat_v2i16_sv(<2 x i16> inreg %lhs, <2 x i16> %rhs) {
2867 ; GFX6-LABEL: saddsat_v2i16_sv:
2869 ; GFX6-NEXT: s_lshl_b32 s0, s0, 16
2870 ; GFX6-NEXT: s_brev_b32 s3, 1
2871 ; GFX6-NEXT: s_min_i32 s5, s0, 0
2872 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 16, v0
2873 ; GFX6-NEXT: s_brev_b32 s2, -2
2874 ; GFX6-NEXT: s_max_i32 s4, s0, 0
2875 ; GFX6-NEXT: s_sub_i32 s5, s3, s5
2876 ; GFX6-NEXT: s_sub_i32 s4, s2, s4
2877 ; GFX6-NEXT: v_max_i32_e32 v0, s5, v0
2878 ; GFX6-NEXT: v_min_i32_e32 v0, s4, v0
2879 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s0, v0
2880 ; GFX6-NEXT: s_lshl_b32 s0, s1, 16
2881 ; GFX6-NEXT: s_max_i32 s1, s0, 0
2882 ; GFX6-NEXT: s_sub_i32 s1, s2, s1
2883 ; GFX6-NEXT: s_min_i32 s2, s0, 0
2884 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
2885 ; GFX6-NEXT: s_sub_i32 s2, s3, s2
2886 ; GFX6-NEXT: v_max_i32_e32 v1, s2, v1
2887 ; GFX6-NEXT: v_min_i32_e32 v1, s1, v1
2888 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, s0, v1
2889 ; GFX6-NEXT: v_ashrrev_i32_e32 v1, 16, v1
2890 ; GFX6-NEXT: s_mov_b32 s0, 0xffff
2891 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 16, v0
2892 ; GFX6-NEXT: v_and_b32_e32 v1, s0, v1
2893 ; GFX6-NEXT: v_and_b32_e32 v0, s0, v0
2894 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
2895 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
2896 ; GFX6-NEXT: ; return to shader part epilog
2898 ; GFX8-LABEL: saddsat_v2i16_sv:
2900 ; GFX8-NEXT: s_sext_i32_i16 s4, s0
2901 ; GFX8-NEXT: s_sext_i32_i16 s5, 0
2902 ; GFX8-NEXT: s_movk_i32 s3, 0x8000
2903 ; GFX8-NEXT: s_max_i32 s6, s4, s5
2904 ; GFX8-NEXT: s_min_i32 s4, s4, s5
2905 ; GFX8-NEXT: s_lshr_b32 s1, s0, 16
2906 ; GFX8-NEXT: s_movk_i32 s2, 0x7fff
2907 ; GFX8-NEXT: s_sub_i32 s4, s3, s4
2908 ; GFX8-NEXT: s_sub_i32 s6, s2, s6
2909 ; GFX8-NEXT: v_max_i16_e32 v1, s4, v0
2910 ; GFX8-NEXT: s_sext_i32_i16 s4, s1
2911 ; GFX8-NEXT: v_min_i16_e32 v1, s6, v1
2912 ; GFX8-NEXT: s_max_i32 s6, s4, s5
2913 ; GFX8-NEXT: s_min_i32 s4, s4, s5
2914 ; GFX8-NEXT: s_sub_i32 s3, s3, s4
2915 ; GFX8-NEXT: v_mov_b32_e32 v2, s3
2916 ; GFX8-NEXT: s_sub_i32 s2, s2, s6
2917 ; GFX8-NEXT: v_max_i16_sdwa v0, v2, v0 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
2918 ; GFX8-NEXT: v_min_i16_e32 v0, s2, v0
2919 ; GFX8-NEXT: v_mov_b32_e32 v2, s1
2920 ; GFX8-NEXT: v_add_u16_e32 v1, s0, v1
2921 ; GFX8-NEXT: v_add_u16_sdwa v0, v2, v0 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
2922 ; GFX8-NEXT: v_or_b32_e32 v0, v1, v0
2923 ; GFX8-NEXT: ; return to shader part epilog
2925 ; GFX9-LABEL: saddsat_v2i16_sv:
2927 ; GFX9-NEXT: v_pk_add_i16 v0, s0, v0 clamp
2928 ; GFX9-NEXT: ; return to shader part epilog
2930 ; GFX10-LABEL: saddsat_v2i16_sv:
2932 ; GFX10-NEXT: v_pk_add_i16 v0, s0, v0 clamp
2933 ; GFX10-NEXT: ; return to shader part epilog
2934 %result = call <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16> %lhs, <2 x i16> %rhs)
2935 %cast = bitcast <2 x i16> %result to float
2939 define amdgpu_ps float @saddsat_v2i16_vs(<2 x i16> %lhs, <2 x i16> inreg %rhs) {
2940 ; GFX6-LABEL: saddsat_v2i16_vs:
2942 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 16, v0
2943 ; GFX6-NEXT: s_brev_b32 s3, 1
2944 ; GFX6-NEXT: v_min_i32_e32 v3, 0, v0
2945 ; GFX6-NEXT: s_lshl_b32 s0, s0, 16
2946 ; GFX6-NEXT: s_brev_b32 s2, -2
2947 ; GFX6-NEXT: v_max_i32_e32 v2, 0, v0
2948 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, s3, v3
2949 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s2, v2
2950 ; GFX6-NEXT: v_max_i32_e32 v3, s0, v3
2951 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
2952 ; GFX6-NEXT: v_min_i32_e32 v2, v3, v2
2953 ; GFX6-NEXT: v_min_i32_e32 v3, 0, v1
2954 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v2
2955 ; GFX6-NEXT: s_lshl_b32 s0, s1, 16
2956 ; GFX6-NEXT: v_max_i32_e32 v2, 0, v1
2957 ; GFX6-NEXT: v_sub_i32_e32 v3, vcc, s3, v3
2958 ; GFX6-NEXT: v_sub_i32_e32 v2, vcc, s2, v2
2959 ; GFX6-NEXT: v_max_i32_e32 v3, s0, v3
2960 ; GFX6-NEXT: v_min_i32_e32 v2, v3, v2
2961 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v2
2962 ; GFX6-NEXT: v_ashrrev_i32_e32 v1, 16, v1
2963 ; GFX6-NEXT: s_mov_b32 s0, 0xffff
2964 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 16, v0
2965 ; GFX6-NEXT: v_and_b32_e32 v1, s0, v1
2966 ; GFX6-NEXT: v_and_b32_e32 v0, s0, v0
2967 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
2968 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
2969 ; GFX6-NEXT: ; return to shader part epilog
2971 ; GFX8-LABEL: saddsat_v2i16_vs:
2973 ; GFX8-NEXT: s_movk_i32 s3, 0x8000
2974 ; GFX8-NEXT: v_min_i16_e32 v3, 0, v0
2975 ; GFX8-NEXT: v_lshrrev_b32_e32 v1, 16, v0
2976 ; GFX8-NEXT: s_movk_i32 s2, 0x7fff
2977 ; GFX8-NEXT: v_max_i16_e32 v2, 0, v0
2978 ; GFX8-NEXT: v_sub_u16_e32 v3, s3, v3
2979 ; GFX8-NEXT: v_sub_u16_e32 v2, s2, v2
2980 ; GFX8-NEXT: v_max_i16_e32 v3, s0, v3
2981 ; GFX8-NEXT: v_min_i16_e32 v4, 0, v1
2982 ; GFX8-NEXT: s_lshr_b32 s1, s0, 16
2983 ; GFX8-NEXT: v_min_i16_e32 v2, v3, v2
2984 ; GFX8-NEXT: v_max_i16_e32 v3, 0, v1
2985 ; GFX8-NEXT: v_sub_u16_e32 v4, s3, v4
2986 ; GFX8-NEXT: v_sub_u16_e32 v3, s2, v3
2987 ; GFX8-NEXT: v_max_i16_e32 v4, s1, v4
2988 ; GFX8-NEXT: v_min_i16_e32 v3, v4, v3
2989 ; GFX8-NEXT: v_add_u16_e32 v0, v0, v2
2990 ; GFX8-NEXT: v_add_u16_sdwa v1, v1, v3 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
2991 ; GFX8-NEXT: v_or_b32_e32 v0, v0, v1
2992 ; GFX8-NEXT: ; return to shader part epilog
2994 ; GFX9-LABEL: saddsat_v2i16_vs:
2996 ; GFX9-NEXT: v_pk_add_i16 v0, v0, s0 clamp
2997 ; GFX9-NEXT: ; return to shader part epilog
2999 ; GFX10-LABEL: saddsat_v2i16_vs:
3001 ; GFX10-NEXT: v_pk_add_i16 v0, v0, s0 clamp
3002 ; GFX10-NEXT: ; return to shader part epilog
3003 %result = call <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16> %lhs, <2 x i16> %rhs)
3004 %cast = bitcast <2 x i16> %result to float
3008 ; FIXME: v3i16 insert/extract
3009 ; define <3 x i16> @v_saddsat_v3i16(<3 x i16> %lhs, <3 x i16> %rhs) {
3010 ; %result = call <3 x i16> @llvm.sadd.sat.v3i16(<3 x i16> %lhs, <3 x i16> %rhs)
3011 ; ret <3 x i16> %result
3014 ; define amdgpu_ps <3 x i16> @s_saddsat_v3i16(<3 x i16> inreg %lhs, <3 x i16> inreg %rhs) {
3015 ; %result = call <3 x i16> @llvm.sadd.sat.v3i16(<3 x i16> %lhs, <3 x i16> %rhs)
3016 ; ret <3 x i16> %result
3019 define <2 x float> @v_saddsat_v4i16(<4 x i16> %lhs, <4 x i16> %rhs) {
3020 ; GFX6-LABEL: v_saddsat_v4i16:
3022 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3023 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 16, v0
3024 ; GFX6-NEXT: s_brev_b32 s5, 1
3025 ; GFX6-NEXT: v_min_i32_e32 v10, 0, v0
3026 ; GFX6-NEXT: v_lshlrev_b32_e32 v4, 16, v4
3027 ; GFX6-NEXT: s_brev_b32 s4, -2
3028 ; GFX6-NEXT: v_max_i32_e32 v8, 0, v0
3029 ; GFX6-NEXT: v_sub_i32_e32 v10, vcc, s5, v10
3030 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, s4, v8
3031 ; GFX6-NEXT: v_max_i32_e32 v4, v10, v4
3032 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
3033 ; GFX6-NEXT: v_min_i32_e32 v4, v4, v8
3034 ; GFX6-NEXT: v_min_i32_e32 v8, 0, v1
3035 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v4
3036 ; GFX6-NEXT: v_lshlrev_b32_e32 v4, 16, v5
3037 ; GFX6-NEXT: v_max_i32_e32 v5, 0, v1
3038 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, s5, v8
3039 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, s4, v5
3040 ; GFX6-NEXT: v_max_i32_e32 v4, v8, v4
3041 ; GFX6-NEXT: v_min_i32_e32 v4, v4, v5
3042 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
3043 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v4
3044 ; GFX6-NEXT: v_lshlrev_b32_e32 v4, 16, v6
3045 ; GFX6-NEXT: v_min_i32_e32 v6, 0, v2
3046 ; GFX6-NEXT: v_bfrev_b32_e32 v9, -2
3047 ; GFX6-NEXT: v_max_i32_e32 v5, 0, v2
3048 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, s5, v6
3049 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, v9, v5
3050 ; GFX6-NEXT: v_max_i32_e32 v4, v6, v4
3051 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 16, v3
3052 ; GFX6-NEXT: v_bfrev_b32_e32 v11, 1
3053 ; GFX6-NEXT: v_min_i32_e32 v4, v4, v5
3054 ; GFX6-NEXT: v_min_i32_e32 v6, 0, v3
3055 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v4
3056 ; GFX6-NEXT: v_lshlrev_b32_e32 v4, 16, v7
3057 ; GFX6-NEXT: v_max_i32_e32 v5, 0, v3
3058 ; GFX6-NEXT: v_sub_i32_e32 v6, vcc, v11, v6
3059 ; GFX6-NEXT: v_sub_i32_e32 v5, vcc, v9, v5
3060 ; GFX6-NEXT: v_max_i32_e32 v4, v6, v4
3061 ; GFX6-NEXT: v_ashrrev_i32_e32 v1, 16, v1
3062 ; GFX6-NEXT: v_min_i32_e32 v4, v4, v5
3063 ; GFX6-NEXT: s_mov_b32 s4, 0xffff
3064 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 16, v0
3065 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v4
3066 ; GFX6-NEXT: v_and_b32_e32 v1, s4, v1
3067 ; GFX6-NEXT: v_ashrrev_i32_e32 v2, 16, v2
3068 ; GFX6-NEXT: v_ashrrev_i32_e32 v3, 16, v3
3069 ; GFX6-NEXT: v_and_b32_e32 v0, s4, v0
3070 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
3071 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
3072 ; GFX6-NEXT: v_and_b32_e32 v1, s4, v2
3073 ; GFX6-NEXT: v_and_b32_e32 v2, s4, v3
3074 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
3075 ; GFX6-NEXT: v_or_b32_e32 v1, v1, v2
3076 ; GFX6-NEXT: s_setpc_b64 s[30:31]
3078 ; GFX8-LABEL: v_saddsat_v4i16:
3080 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3081 ; GFX8-NEXT: s_movk_i32 s5, 0x8000
3082 ; GFX8-NEXT: v_min_i16_e32 v7, 0, v0
3083 ; GFX8-NEXT: v_lshrrev_b32_e32 v4, 16, v0
3084 ; GFX8-NEXT: s_movk_i32 s4, 0x7fff
3085 ; GFX8-NEXT: v_max_i16_e32 v6, 0, v0
3086 ; GFX8-NEXT: v_sub_u16_e32 v7, s5, v7
3087 ; GFX8-NEXT: v_sub_u16_e32 v6, s4, v6
3088 ; GFX8-NEXT: v_max_i16_e32 v7, v7, v2
3089 ; GFX8-NEXT: v_min_i16_e32 v8, 0, v4
3090 ; GFX8-NEXT: v_min_i16_e32 v6, v7, v6
3091 ; GFX8-NEXT: v_max_i16_e32 v7, 0, v4
3092 ; GFX8-NEXT: v_sub_u16_e32 v8, s5, v8
3093 ; GFX8-NEXT: v_sub_u16_e32 v7, s4, v7
3094 ; GFX8-NEXT: v_max_i16_sdwa v2, v8, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
3095 ; GFX8-NEXT: v_min_i16_e32 v8, 0, v1
3096 ; GFX8-NEXT: v_lshrrev_b32_e32 v5, 16, v1
3097 ; GFX8-NEXT: v_min_i16_e32 v2, v2, v7
3098 ; GFX8-NEXT: v_max_i16_e32 v7, 0, v1
3099 ; GFX8-NEXT: v_sub_u16_e32 v8, s5, v8
3100 ; GFX8-NEXT: v_sub_u16_e32 v7, s4, v7
3101 ; GFX8-NEXT: v_max_i16_e32 v8, v8, v3
3102 ; GFX8-NEXT: v_min_i16_e32 v9, 0, v5
3103 ; GFX8-NEXT: v_min_i16_e32 v7, v8, v7
3104 ; GFX8-NEXT: v_max_i16_e32 v8, 0, v5
3105 ; GFX8-NEXT: v_sub_u16_e32 v9, s5, v9
3106 ; GFX8-NEXT: v_sub_u16_e32 v8, s4, v8
3107 ; GFX8-NEXT: v_max_i16_sdwa v3, v9, v3 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
3108 ; GFX8-NEXT: v_min_i16_e32 v3, v3, v8
3109 ; GFX8-NEXT: v_add_u16_e32 v0, v0, v6
3110 ; GFX8-NEXT: v_add_u16_sdwa v2, v4, v2 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
3111 ; GFX8-NEXT: v_or_b32_e32 v0, v0, v2
3112 ; GFX8-NEXT: v_add_u16_e32 v1, v1, v7
3113 ; GFX8-NEXT: v_add_u16_sdwa v2, v5, v3 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
3114 ; GFX8-NEXT: v_or_b32_e32 v1, v1, v2
3115 ; GFX8-NEXT: s_setpc_b64 s[30:31]
3117 ; GFX9-LABEL: v_saddsat_v4i16:
3119 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3120 ; GFX9-NEXT: v_pk_add_i16 v0, v0, v2 clamp
3121 ; GFX9-NEXT: v_pk_add_i16 v1, v1, v3 clamp
3122 ; GFX9-NEXT: s_setpc_b64 s[30:31]
3124 ; GFX10-LABEL: v_saddsat_v4i16:
3126 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3127 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
3128 ; GFX10-NEXT: v_pk_add_i16 v0, v0, v2 clamp
3129 ; GFX10-NEXT: v_pk_add_i16 v1, v1, v3 clamp
3130 ; GFX10-NEXT: s_setpc_b64 s[30:31]
3131 %result = call <4 x i16> @llvm.sadd.sat.v4i16(<4 x i16> %lhs, <4 x i16> %rhs)
3132 %cast = bitcast <4 x i16> %result to <2 x float>
3133 ret <2 x float> %cast
3136 define amdgpu_ps <2 x i32> @s_saddsat_v4i16(<4 x i16> inreg %lhs, <4 x i16> inreg %rhs) {
3137 ; GFX6-LABEL: s_saddsat_v4i16:
3139 ; GFX6-NEXT: s_lshl_b32 s0, s0, 16
3140 ; GFX6-NEXT: s_brev_b32 s9, 1
3141 ; GFX6-NEXT: s_min_i32 s11, s0, 0
3142 ; GFX6-NEXT: s_lshl_b32 s4, s4, 16
3143 ; GFX6-NEXT: s_brev_b32 s8, -2
3144 ; GFX6-NEXT: s_max_i32 s10, s0, 0
3145 ; GFX6-NEXT: s_sub_i32 s11, s9, s11
3146 ; GFX6-NEXT: s_sub_i32 s10, s8, s10
3147 ; GFX6-NEXT: s_max_i32 s4, s11, s4
3148 ; GFX6-NEXT: s_lshl_b32 s1, s1, 16
3149 ; GFX6-NEXT: s_min_i32 s4, s4, s10
3150 ; GFX6-NEXT: s_min_i32 s10, s1, 0
3151 ; GFX6-NEXT: s_add_i32 s0, s0, s4
3152 ; GFX6-NEXT: s_lshl_b32 s4, s5, 16
3153 ; GFX6-NEXT: s_max_i32 s5, s1, 0
3154 ; GFX6-NEXT: s_sub_i32 s10, s9, s10
3155 ; GFX6-NEXT: s_sub_i32 s5, s8, s5
3156 ; GFX6-NEXT: s_max_i32 s4, s10, s4
3157 ; GFX6-NEXT: s_min_i32 s4, s4, s5
3158 ; GFX6-NEXT: s_lshl_b32 s2, s2, 16
3159 ; GFX6-NEXT: s_add_i32 s1, s1, s4
3160 ; GFX6-NEXT: s_lshl_b32 s4, s6, 16
3161 ; GFX6-NEXT: s_min_i32 s6, s2, 0
3162 ; GFX6-NEXT: s_max_i32 s5, s2, 0
3163 ; GFX6-NEXT: s_sub_i32 s6, s9, s6
3164 ; GFX6-NEXT: s_sub_i32 s5, s8, s5
3165 ; GFX6-NEXT: s_max_i32 s4, s6, s4
3166 ; GFX6-NEXT: s_lshl_b32 s3, s3, 16
3167 ; GFX6-NEXT: s_min_i32 s4, s4, s5
3168 ; GFX6-NEXT: s_min_i32 s6, s3, 0
3169 ; GFX6-NEXT: s_add_i32 s2, s2, s4
3170 ; GFX6-NEXT: s_lshl_b32 s4, s7, 16
3171 ; GFX6-NEXT: s_max_i32 s5, s3, 0
3172 ; GFX6-NEXT: s_sub_i32 s6, s9, s6
3173 ; GFX6-NEXT: s_sub_i32 s5, s8, s5
3174 ; GFX6-NEXT: s_max_i32 s4, s6, s4
3175 ; GFX6-NEXT: s_min_i32 s4, s4, s5
3176 ; GFX6-NEXT: s_ashr_i32 s1, s1, 16
3177 ; GFX6-NEXT: s_add_i32 s3, s3, s4
3178 ; GFX6-NEXT: s_mov_b32 s4, 0xffff
3179 ; GFX6-NEXT: s_ashr_i32 s0, s0, 16
3180 ; GFX6-NEXT: s_and_b32 s1, s1, s4
3181 ; GFX6-NEXT: s_ashr_i32 s2, s2, 16
3182 ; GFX6-NEXT: s_ashr_i32 s3, s3, 16
3183 ; GFX6-NEXT: s_and_b32 s0, s0, s4
3184 ; GFX6-NEXT: s_lshl_b32 s1, s1, 16
3185 ; GFX6-NEXT: s_or_b32 s0, s0, s1
3186 ; GFX6-NEXT: s_and_b32 s1, s2, s4
3187 ; GFX6-NEXT: s_and_b32 s2, s3, s4
3188 ; GFX6-NEXT: s_lshl_b32 s2, s2, 16
3189 ; GFX6-NEXT: s_or_b32 s1, s1, s2
3190 ; GFX6-NEXT: ; return to shader part epilog
3192 ; GFX8-LABEL: s_saddsat_v4i16:
3194 ; GFX8-NEXT: s_sext_i32_i16 s10, s0
3195 ; GFX8-NEXT: s_sext_i32_i16 s11, 0
3196 ; GFX8-NEXT: s_movk_i32 s9, 0x8000
3197 ; GFX8-NEXT: s_max_i32 s12, s10, s11
3198 ; GFX8-NEXT: s_min_i32 s10, s10, s11
3199 ; GFX8-NEXT: s_sub_i32 s10, s9, s10
3200 ; GFX8-NEXT: s_lshr_b32 s6, s2, 16
3201 ; GFX8-NEXT: s_movk_i32 s8, 0x7fff
3202 ; GFX8-NEXT: s_sext_i32_i16 s10, s10
3203 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
3204 ; GFX8-NEXT: s_sub_i32 s12, s8, s12
3205 ; GFX8-NEXT: s_max_i32 s2, s10, s2
3206 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
3207 ; GFX8-NEXT: s_sext_i32_i16 s10, s12
3208 ; GFX8-NEXT: s_lshr_b32 s4, s0, 16
3209 ; GFX8-NEXT: s_min_i32 s2, s2, s10
3210 ; GFX8-NEXT: s_add_i32 s0, s0, s2
3211 ; GFX8-NEXT: s_sext_i32_i16 s2, s4
3212 ; GFX8-NEXT: s_max_i32 s10, s2, s11
3213 ; GFX8-NEXT: s_min_i32 s2, s2, s11
3214 ; GFX8-NEXT: s_sub_i32 s2, s9, s2
3215 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
3216 ; GFX8-NEXT: s_sext_i32_i16 s6, s6
3217 ; GFX8-NEXT: s_sub_i32 s10, s8, s10
3218 ; GFX8-NEXT: s_max_i32 s2, s2, s6
3219 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
3220 ; GFX8-NEXT: s_sext_i32_i16 s6, s10
3221 ; GFX8-NEXT: s_min_i32 s2, s2, s6
3222 ; GFX8-NEXT: s_add_i32 s4, s4, s2
3223 ; GFX8-NEXT: s_sext_i32_i16 s2, s1
3224 ; GFX8-NEXT: s_max_i32 s6, s2, s11
3225 ; GFX8-NEXT: s_min_i32 s2, s2, s11
3226 ; GFX8-NEXT: s_sub_i32 s2, s9, s2
3227 ; GFX8-NEXT: s_lshr_b32 s7, s3, 16
3228 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
3229 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3230 ; GFX8-NEXT: s_sub_i32 s6, s8, s6
3231 ; GFX8-NEXT: s_max_i32 s2, s2, s3
3232 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
3233 ; GFX8-NEXT: s_sext_i32_i16 s3, s6
3234 ; GFX8-NEXT: s_lshr_b32 s5, s1, 16
3235 ; GFX8-NEXT: s_min_i32 s2, s2, s3
3236 ; GFX8-NEXT: s_add_i32 s1, s1, s2
3237 ; GFX8-NEXT: s_sext_i32_i16 s2, s5
3238 ; GFX8-NEXT: s_max_i32 s3, s2, s11
3239 ; GFX8-NEXT: s_min_i32 s2, s2, s11
3240 ; GFX8-NEXT: s_sub_i32 s2, s9, s2
3241 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
3242 ; GFX8-NEXT: s_sext_i32_i16 s6, s7
3243 ; GFX8-NEXT: s_sub_i32 s3, s8, s3
3244 ; GFX8-NEXT: s_max_i32 s2, s2, s6
3245 ; GFX8-NEXT: s_sext_i32_i16 s2, s2
3246 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3247 ; GFX8-NEXT: s_min_i32 s2, s2, s3
3248 ; GFX8-NEXT: s_add_i32 s5, s5, s2
3249 ; GFX8-NEXT: s_bfe_u32 s2, s4, 0x100000
3250 ; GFX8-NEXT: s_bfe_u32 s0, s0, 0x100000
3251 ; GFX8-NEXT: s_lshl_b32 s2, s2, 16
3252 ; GFX8-NEXT: s_or_b32 s0, s0, s2
3253 ; GFX8-NEXT: s_bfe_u32 s2, s5, 0x100000
3254 ; GFX8-NEXT: s_bfe_u32 s1, s1, 0x100000
3255 ; GFX8-NEXT: s_lshl_b32 s2, s2, 16
3256 ; GFX8-NEXT: s_or_b32 s1, s1, s2
3257 ; GFX8-NEXT: ; return to shader part epilog
3259 ; GFX9-LABEL: s_saddsat_v4i16:
3261 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
3262 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
3263 ; GFX9-NEXT: v_pk_add_i16 v0, s0, v0 clamp
3264 ; GFX9-NEXT: v_pk_add_i16 v1, s1, v1 clamp
3265 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
3266 ; GFX9-NEXT: v_readfirstlane_b32 s1, v1
3267 ; GFX9-NEXT: ; return to shader part epilog
3269 ; GFX10-LABEL: s_saddsat_v4i16:
3271 ; GFX10-NEXT: v_pk_add_i16 v0, s0, s2 clamp
3272 ; GFX10-NEXT: v_pk_add_i16 v1, s1, s3 clamp
3273 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
3274 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
3275 ; GFX10-NEXT: ; return to shader part epilog
3276 %result = call <4 x i16> @llvm.sadd.sat.v4i16(<4 x i16> %lhs, <4 x i16> %rhs)
3277 %cast = bitcast <4 x i16> %result to <2 x i32>
3282 ; define <5 x i16> @v_saddsat_v5i16(<5 x i16> %lhs, <5 x i16> %rhs) {
3283 ; %result = call <5 x i16> @llvm.sadd.sat.v5i16(<5 x i16> %lhs, <5 x i16> %rhs)
3284 ; ret <5 x i16> %result
3287 ; define amdgpu_ps <5 x i16> @s_saddsat_v5i16(<5 x i16> inreg %lhs, <5 x i16> inreg %rhs) {
3288 ; %result = call <5 x i16> @llvm.sadd.sat.v5i16(<5 x i16> %lhs, <5 x i16> %rhs)
3289 ; ret <5 x i16> %result
3292 define <3 x float> @v_saddsat_v6i16(<6 x i16> %lhs, <6 x i16> %rhs) {
3293 ; GFX6-LABEL: v_saddsat_v6i16:
3295 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3296 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 16, v0
3297 ; GFX6-NEXT: s_brev_b32 s5, 1
3298 ; GFX6-NEXT: v_min_i32_e32 v14, 0, v0
3299 ; GFX6-NEXT: v_lshlrev_b32_e32 v6, 16, v6
3300 ; GFX6-NEXT: s_brev_b32 s4, -2
3301 ; GFX6-NEXT: v_max_i32_e32 v12, 0, v0
3302 ; GFX6-NEXT: v_sub_i32_e32 v14, vcc, s5, v14
3303 ; GFX6-NEXT: v_sub_i32_e32 v12, vcc, s4, v12
3304 ; GFX6-NEXT: v_max_i32_e32 v6, v14, v6
3305 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
3306 ; GFX6-NEXT: v_min_i32_e32 v6, v6, v12
3307 ; GFX6-NEXT: v_min_i32_e32 v12, 0, v1
3308 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v6
3309 ; GFX6-NEXT: v_lshlrev_b32_e32 v6, 16, v7
3310 ; GFX6-NEXT: v_max_i32_e32 v7, 0, v1
3311 ; GFX6-NEXT: v_sub_i32_e32 v12, vcc, s5, v12
3312 ; GFX6-NEXT: v_sub_i32_e32 v7, vcc, s4, v7
3313 ; GFX6-NEXT: v_max_i32_e32 v6, v12, v6
3314 ; GFX6-NEXT: v_min_i32_e32 v6, v6, v7
3315 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
3316 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v6
3317 ; GFX6-NEXT: v_lshlrev_b32_e32 v6, 16, v8
3318 ; GFX6-NEXT: v_min_i32_e32 v8, 0, v2
3319 ; GFX6-NEXT: v_bfrev_b32_e32 v13, -2
3320 ; GFX6-NEXT: v_max_i32_e32 v7, 0, v2
3321 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, s5, v8
3322 ; GFX6-NEXT: v_sub_i32_e32 v7, vcc, v13, v7
3323 ; GFX6-NEXT: v_max_i32_e32 v6, v8, v6
3324 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 16, v3
3325 ; GFX6-NEXT: v_bfrev_b32_e32 v15, 1
3326 ; GFX6-NEXT: v_min_i32_e32 v6, v6, v7
3327 ; GFX6-NEXT: v_min_i32_e32 v8, 0, v3
3328 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v6
3329 ; GFX6-NEXT: v_lshlrev_b32_e32 v6, 16, v9
3330 ; GFX6-NEXT: v_max_i32_e32 v7, 0, v3
3331 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, v15, v8
3332 ; GFX6-NEXT: v_sub_i32_e32 v7, vcc, v13, v7
3333 ; GFX6-NEXT: v_max_i32_e32 v6, v8, v6
3334 ; GFX6-NEXT: v_lshlrev_b32_e32 v4, 16, v4
3335 ; GFX6-NEXT: v_min_i32_e32 v6, v6, v7
3336 ; GFX6-NEXT: v_min_i32_e32 v8, 0, v4
3337 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v6
3338 ; GFX6-NEXT: v_lshlrev_b32_e32 v6, 16, v10
3339 ; GFX6-NEXT: v_max_i32_e32 v7, 0, v4
3340 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, v15, v8
3341 ; GFX6-NEXT: v_sub_i32_e32 v7, vcc, v13, v7
3342 ; GFX6-NEXT: v_max_i32_e32 v6, v8, v6
3343 ; GFX6-NEXT: v_lshlrev_b32_e32 v5, 16, v5
3344 ; GFX6-NEXT: v_min_i32_e32 v6, v6, v7
3345 ; GFX6-NEXT: v_min_i32_e32 v8, 0, v5
3346 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v6
3347 ; GFX6-NEXT: v_lshlrev_b32_e32 v6, 16, v11
3348 ; GFX6-NEXT: v_max_i32_e32 v7, 0, v5
3349 ; GFX6-NEXT: v_sub_i32_e32 v8, vcc, v15, v8
3350 ; GFX6-NEXT: v_ashrrev_i32_e32 v1, 16, v1
3351 ; GFX6-NEXT: v_sub_i32_e32 v7, vcc, v13, v7
3352 ; GFX6-NEXT: v_max_i32_e32 v6, v8, v6
3353 ; GFX6-NEXT: s_mov_b32 s4, 0xffff
3354 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 16, v0
3355 ; GFX6-NEXT: v_min_i32_e32 v6, v6, v7
3356 ; GFX6-NEXT: v_and_b32_e32 v1, s4, v1
3357 ; GFX6-NEXT: v_ashrrev_i32_e32 v2, 16, v2
3358 ; GFX6-NEXT: v_ashrrev_i32_e32 v3, 16, v3
3359 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, v5, v6
3360 ; GFX6-NEXT: v_and_b32_e32 v0, s4, v0
3361 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
3362 ; GFX6-NEXT: v_ashrrev_i32_e32 v5, 16, v5
3363 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
3364 ; GFX6-NEXT: v_and_b32_e32 v1, s4, v2
3365 ; GFX6-NEXT: v_and_b32_e32 v2, s4, v3
3366 ; GFX6-NEXT: v_ashrrev_i32_e32 v4, 16, v4
3367 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
3368 ; GFX6-NEXT: v_and_b32_e32 v3, s4, v5
3369 ; GFX6-NEXT: v_or_b32_e32 v1, v1, v2
3370 ; GFX6-NEXT: v_and_b32_e32 v2, s4, v4
3371 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 16, v3
3372 ; GFX6-NEXT: v_or_b32_e32 v2, v2, v3
3373 ; GFX6-NEXT: s_setpc_b64 s[30:31]
3375 ; GFX8-LABEL: v_saddsat_v6i16:
3377 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3378 ; GFX8-NEXT: s_movk_i32 s5, 0x8000
3379 ; GFX8-NEXT: v_min_i16_e32 v11, 0, v0
3380 ; GFX8-NEXT: v_lshrrev_b32_e32 v6, 16, v0
3381 ; GFX8-NEXT: s_movk_i32 s4, 0x7fff
3382 ; GFX8-NEXT: v_max_i16_e32 v9, 0, v0
3383 ; GFX8-NEXT: v_sub_u16_e32 v11, s5, v11
3384 ; GFX8-NEXT: v_sub_u16_e32 v9, s4, v9
3385 ; GFX8-NEXT: v_max_i16_e32 v11, v11, v3
3386 ; GFX8-NEXT: v_min_i16_e32 v13, 0, v6
3387 ; GFX8-NEXT: v_min_i16_e32 v9, v11, v9
3388 ; GFX8-NEXT: v_max_i16_e32 v11, 0, v6
3389 ; GFX8-NEXT: v_sub_u16_e32 v13, s5, v13
3390 ; GFX8-NEXT: v_sub_u16_e32 v11, s4, v11
3391 ; GFX8-NEXT: v_max_i16_sdwa v3, v13, v3 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
3392 ; GFX8-NEXT: v_min_i16_e32 v13, 0, v1
3393 ; GFX8-NEXT: v_lshrrev_b32_e32 v7, 16, v1
3394 ; GFX8-NEXT: v_min_i16_e32 v3, v3, v11
3395 ; GFX8-NEXT: v_max_i16_e32 v11, 0, v1
3396 ; GFX8-NEXT: v_sub_u16_e32 v13, s5, v13
3397 ; GFX8-NEXT: v_sub_u16_e32 v11, s4, v11
3398 ; GFX8-NEXT: v_max_i16_e32 v13, v13, v4
3399 ; GFX8-NEXT: v_min_i16_e32 v14, 0, v7
3400 ; GFX8-NEXT: v_min_i16_e32 v11, v13, v11
3401 ; GFX8-NEXT: v_max_i16_e32 v13, 0, v7
3402 ; GFX8-NEXT: v_sub_u16_e32 v14, s5, v14
3403 ; GFX8-NEXT: v_mov_b32_e32 v12, 0xffff8000
3404 ; GFX8-NEXT: v_sub_u16_e32 v13, s4, v13
3405 ; GFX8-NEXT: v_max_i16_sdwa v4, v14, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
3406 ; GFX8-NEXT: v_min_i16_e32 v14, 0, v2
3407 ; GFX8-NEXT: v_mov_b32_e32 v10, 0x7fff
3408 ; GFX8-NEXT: v_min_i16_e32 v4, v4, v13
3409 ; GFX8-NEXT: v_max_i16_e32 v13, 0, v2
3410 ; GFX8-NEXT: v_sub_u16_e32 v14, v12, v14
3411 ; GFX8-NEXT: v_lshrrev_b32_e32 v8, 16, v2
3412 ; GFX8-NEXT: v_sub_u16_e32 v13, v10, v13
3413 ; GFX8-NEXT: v_max_i16_e32 v14, v14, v5
3414 ; GFX8-NEXT: v_min_i16_e32 v13, v14, v13
3415 ; GFX8-NEXT: v_max_i16_e32 v14, 0, v8
3416 ; GFX8-NEXT: v_sub_u16_e32 v10, v10, v14
3417 ; GFX8-NEXT: v_min_i16_e32 v14, 0, v8
3418 ; GFX8-NEXT: v_sub_u16_e32 v12, v12, v14
3419 ; GFX8-NEXT: v_max_i16_sdwa v5, v12, v5 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
3420 ; GFX8-NEXT: v_add_u16_e32 v0, v0, v9
3421 ; GFX8-NEXT: v_add_u16_sdwa v3, v6, v3 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
3422 ; GFX8-NEXT: v_min_i16_e32 v5, v5, v10
3423 ; GFX8-NEXT: v_or_b32_e32 v0, v0, v3
3424 ; GFX8-NEXT: v_add_u16_e32 v1, v1, v11
3425 ; GFX8-NEXT: v_add_u16_sdwa v3, v7, v4 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
3426 ; GFX8-NEXT: v_or_b32_e32 v1, v1, v3
3427 ; GFX8-NEXT: v_add_u16_e32 v2, v2, v13
3428 ; GFX8-NEXT: v_add_u16_sdwa v3, v8, v5 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
3429 ; GFX8-NEXT: v_or_b32_e32 v2, v2, v3
3430 ; GFX8-NEXT: s_setpc_b64 s[30:31]
3432 ; GFX9-LABEL: v_saddsat_v6i16:
3434 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3435 ; GFX9-NEXT: v_pk_add_i16 v0, v0, v3 clamp
3436 ; GFX9-NEXT: v_pk_add_i16 v1, v1, v4 clamp
3437 ; GFX9-NEXT: v_pk_add_i16 v2, v2, v5 clamp
3438 ; GFX9-NEXT: s_setpc_b64 s[30:31]
3440 ; GFX10-LABEL: v_saddsat_v6i16:
3442 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3443 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
3444 ; GFX10-NEXT: v_pk_add_i16 v0, v0, v3 clamp
3445 ; GFX10-NEXT: v_pk_add_i16 v1, v1, v4 clamp
3446 ; GFX10-NEXT: v_pk_add_i16 v2, v2, v5 clamp
3447 ; GFX10-NEXT: s_setpc_b64 s[30:31]
3448 %result = call <6 x i16> @llvm.sadd.sat.v6i16(<6 x i16> %lhs, <6 x i16> %rhs)
3449 %cast = bitcast <6 x i16> %result to <3 x float>
3450 ret <3 x float> %cast
3453 define amdgpu_ps <3 x i32> @s_saddsat_v6i16(<6 x i16> inreg %lhs, <6 x i16> inreg %rhs) {
3454 ; GFX6-LABEL: s_saddsat_v6i16:
3456 ; GFX6-NEXT: s_lshl_b32 s0, s0, 16
3457 ; GFX6-NEXT: s_brev_b32 s13, 1
3458 ; GFX6-NEXT: s_min_i32 s15, s0, 0
3459 ; GFX6-NEXT: s_lshl_b32 s6, s6, 16
3460 ; GFX6-NEXT: s_brev_b32 s12, -2
3461 ; GFX6-NEXT: s_max_i32 s14, s0, 0
3462 ; GFX6-NEXT: s_sub_i32 s15, s13, s15
3463 ; GFX6-NEXT: s_sub_i32 s14, s12, s14
3464 ; GFX6-NEXT: s_max_i32 s6, s15, s6
3465 ; GFX6-NEXT: s_lshl_b32 s1, s1, 16
3466 ; GFX6-NEXT: s_min_i32 s6, s6, s14
3467 ; GFX6-NEXT: s_min_i32 s14, s1, 0
3468 ; GFX6-NEXT: s_add_i32 s0, s0, s6
3469 ; GFX6-NEXT: s_lshl_b32 s6, s7, 16
3470 ; GFX6-NEXT: s_max_i32 s7, s1, 0
3471 ; GFX6-NEXT: s_sub_i32 s14, s13, s14
3472 ; GFX6-NEXT: s_sub_i32 s7, s12, s7
3473 ; GFX6-NEXT: s_max_i32 s6, s14, s6
3474 ; GFX6-NEXT: s_min_i32 s6, s6, s7
3475 ; GFX6-NEXT: s_lshl_b32 s2, s2, 16
3476 ; GFX6-NEXT: s_add_i32 s1, s1, s6
3477 ; GFX6-NEXT: s_lshl_b32 s6, s8, 16
3478 ; GFX6-NEXT: s_min_i32 s8, s2, 0
3479 ; GFX6-NEXT: s_max_i32 s7, s2, 0
3480 ; GFX6-NEXT: s_sub_i32 s8, s13, s8
3481 ; GFX6-NEXT: s_sub_i32 s7, s12, s7
3482 ; GFX6-NEXT: s_max_i32 s6, s8, s6
3483 ; GFX6-NEXT: s_lshl_b32 s3, s3, 16
3484 ; GFX6-NEXT: s_min_i32 s6, s6, s7
3485 ; GFX6-NEXT: s_min_i32 s8, s3, 0
3486 ; GFX6-NEXT: s_add_i32 s2, s2, s6
3487 ; GFX6-NEXT: s_lshl_b32 s6, s9, 16
3488 ; GFX6-NEXT: s_max_i32 s7, s3, 0
3489 ; GFX6-NEXT: s_sub_i32 s8, s13, s8
3490 ; GFX6-NEXT: s_sub_i32 s7, s12, s7
3491 ; GFX6-NEXT: s_max_i32 s6, s8, s6
3492 ; GFX6-NEXT: s_lshl_b32 s4, s4, 16
3493 ; GFX6-NEXT: s_min_i32 s6, s6, s7
3494 ; GFX6-NEXT: s_min_i32 s8, s4, 0
3495 ; GFX6-NEXT: s_add_i32 s3, s3, s6
3496 ; GFX6-NEXT: s_lshl_b32 s6, s10, 16
3497 ; GFX6-NEXT: s_max_i32 s7, s4, 0
3498 ; GFX6-NEXT: s_sub_i32 s8, s13, s8
3499 ; GFX6-NEXT: s_sub_i32 s7, s12, s7
3500 ; GFX6-NEXT: s_max_i32 s6, s8, s6
3501 ; GFX6-NEXT: s_lshl_b32 s5, s5, 16
3502 ; GFX6-NEXT: s_min_i32 s6, s6, s7
3503 ; GFX6-NEXT: s_min_i32 s8, s5, 0
3504 ; GFX6-NEXT: s_add_i32 s4, s4, s6
3505 ; GFX6-NEXT: s_lshl_b32 s6, s11, 16
3506 ; GFX6-NEXT: s_max_i32 s7, s5, 0
3507 ; GFX6-NEXT: s_sub_i32 s8, s13, s8
3508 ; GFX6-NEXT: s_sub_i32 s7, s12, s7
3509 ; GFX6-NEXT: s_max_i32 s6, s8, s6
3510 ; GFX6-NEXT: s_min_i32 s6, s6, s7
3511 ; GFX6-NEXT: s_ashr_i32 s1, s1, 16
3512 ; GFX6-NEXT: s_add_i32 s5, s5, s6
3513 ; GFX6-NEXT: s_mov_b32 s6, 0xffff
3514 ; GFX6-NEXT: s_ashr_i32 s0, s0, 16
3515 ; GFX6-NEXT: s_and_b32 s1, s1, s6
3516 ; GFX6-NEXT: s_ashr_i32 s2, s2, 16
3517 ; GFX6-NEXT: s_ashr_i32 s3, s3, 16
3518 ; GFX6-NEXT: s_and_b32 s0, s0, s6
3519 ; GFX6-NEXT: s_lshl_b32 s1, s1, 16
3520 ; GFX6-NEXT: s_ashr_i32 s5, s5, 16
3521 ; GFX6-NEXT: s_or_b32 s0, s0, s1
3522 ; GFX6-NEXT: s_and_b32 s1, s2, s6
3523 ; GFX6-NEXT: s_and_b32 s2, s3, s6
3524 ; GFX6-NEXT: s_ashr_i32 s4, s4, 16
3525 ; GFX6-NEXT: s_lshl_b32 s2, s2, 16
3526 ; GFX6-NEXT: s_and_b32 s3, s5, s6
3527 ; GFX6-NEXT: s_or_b32 s1, s1, s2
3528 ; GFX6-NEXT: s_and_b32 s2, s4, s6
3529 ; GFX6-NEXT: s_lshl_b32 s3, s3, 16
3530 ; GFX6-NEXT: s_or_b32 s2, s2, s3
3531 ; GFX6-NEXT: ; return to shader part epilog
3533 ; GFX8-LABEL: s_saddsat_v6i16:
3535 ; GFX8-NEXT: s_sext_i32_i16 s14, s0
3536 ; GFX8-NEXT: s_sext_i32_i16 s15, 0
3537 ; GFX8-NEXT: s_movk_i32 s13, 0x8000
3538 ; GFX8-NEXT: s_max_i32 s16, s14, s15
3539 ; GFX8-NEXT: s_min_i32 s14, s14, s15
3540 ; GFX8-NEXT: s_sub_i32 s14, s13, s14
3541 ; GFX8-NEXT: s_lshr_b32 s9, s3, 16
3542 ; GFX8-NEXT: s_movk_i32 s12, 0x7fff
3543 ; GFX8-NEXT: s_sext_i32_i16 s14, s14
3544 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3545 ; GFX8-NEXT: s_sub_i32 s16, s12, s16
3546 ; GFX8-NEXT: s_max_i32 s3, s14, s3
3547 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3548 ; GFX8-NEXT: s_sext_i32_i16 s14, s16
3549 ; GFX8-NEXT: s_lshr_b32 s6, s0, 16
3550 ; GFX8-NEXT: s_min_i32 s3, s3, s14
3551 ; GFX8-NEXT: s_add_i32 s0, s0, s3
3552 ; GFX8-NEXT: s_sext_i32_i16 s3, s6
3553 ; GFX8-NEXT: s_max_i32 s14, s3, s15
3554 ; GFX8-NEXT: s_min_i32 s3, s3, s15
3555 ; GFX8-NEXT: s_sub_i32 s3, s13, s3
3556 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3557 ; GFX8-NEXT: s_sext_i32_i16 s9, s9
3558 ; GFX8-NEXT: s_sub_i32 s14, s12, s14
3559 ; GFX8-NEXT: s_max_i32 s3, s3, s9
3560 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3561 ; GFX8-NEXT: s_sext_i32_i16 s9, s14
3562 ; GFX8-NEXT: s_min_i32 s3, s3, s9
3563 ; GFX8-NEXT: s_add_i32 s6, s6, s3
3564 ; GFX8-NEXT: s_sext_i32_i16 s3, s1
3565 ; GFX8-NEXT: s_max_i32 s9, s3, s15
3566 ; GFX8-NEXT: s_min_i32 s3, s3, s15
3567 ; GFX8-NEXT: s_sub_i32 s3, s13, s3
3568 ; GFX8-NEXT: s_lshr_b32 s10, s4, 16
3569 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3570 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
3571 ; GFX8-NEXT: s_sub_i32 s9, s12, s9
3572 ; GFX8-NEXT: s_max_i32 s3, s3, s4
3573 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3574 ; GFX8-NEXT: s_sext_i32_i16 s4, s9
3575 ; GFX8-NEXT: s_lshr_b32 s7, s1, 16
3576 ; GFX8-NEXT: s_min_i32 s3, s3, s4
3577 ; GFX8-NEXT: s_add_i32 s1, s1, s3
3578 ; GFX8-NEXT: s_sext_i32_i16 s3, s7
3579 ; GFX8-NEXT: s_max_i32 s4, s3, s15
3580 ; GFX8-NEXT: s_min_i32 s3, s3, s15
3581 ; GFX8-NEXT: s_sub_i32 s3, s13, s3
3582 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3583 ; GFX8-NEXT: s_sext_i32_i16 s9, s10
3584 ; GFX8-NEXT: s_sub_i32 s4, s12, s4
3585 ; GFX8-NEXT: s_max_i32 s3, s3, s9
3586 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3587 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
3588 ; GFX8-NEXT: s_min_i32 s3, s3, s4
3589 ; GFX8-NEXT: s_add_i32 s7, s7, s3
3590 ; GFX8-NEXT: s_sext_i32_i16 s3, s2
3591 ; GFX8-NEXT: s_max_i32 s4, s3, s15
3592 ; GFX8-NEXT: s_min_i32 s3, s3, s15
3593 ; GFX8-NEXT: s_sub_i32 s3, s13, s3
3594 ; GFX8-NEXT: s_lshr_b32 s11, s5, 16
3595 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3596 ; GFX8-NEXT: s_sext_i32_i16 s5, s5
3597 ; GFX8-NEXT: s_sub_i32 s4, s12, s4
3598 ; GFX8-NEXT: s_max_i32 s3, s3, s5
3599 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3600 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
3601 ; GFX8-NEXT: s_lshr_b32 s8, s2, 16
3602 ; GFX8-NEXT: s_min_i32 s3, s3, s4
3603 ; GFX8-NEXT: s_add_i32 s2, s2, s3
3604 ; GFX8-NEXT: s_sext_i32_i16 s3, s8
3605 ; GFX8-NEXT: s_max_i32 s4, s3, s15
3606 ; GFX8-NEXT: s_min_i32 s3, s3, s15
3607 ; GFX8-NEXT: s_sub_i32 s3, s13, s3
3608 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3609 ; GFX8-NEXT: s_sext_i32_i16 s5, s11
3610 ; GFX8-NEXT: s_sub_i32 s4, s12, s4
3611 ; GFX8-NEXT: s_max_i32 s3, s3, s5
3612 ; GFX8-NEXT: s_sext_i32_i16 s3, s3
3613 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
3614 ; GFX8-NEXT: s_min_i32 s3, s3, s4
3615 ; GFX8-NEXT: s_add_i32 s8, s8, s3
3616 ; GFX8-NEXT: s_bfe_u32 s3, s6, 0x100000
3617 ; GFX8-NEXT: s_bfe_u32 s0, s0, 0x100000
3618 ; GFX8-NEXT: s_lshl_b32 s3, s3, 16
3619 ; GFX8-NEXT: s_or_b32 s0, s0, s3
3620 ; GFX8-NEXT: s_bfe_u32 s3, s7, 0x100000
3621 ; GFX8-NEXT: s_bfe_u32 s1, s1, 0x100000
3622 ; GFX8-NEXT: s_lshl_b32 s3, s3, 16
3623 ; GFX8-NEXT: s_or_b32 s1, s1, s3
3624 ; GFX8-NEXT: s_bfe_u32 s3, s8, 0x100000
3625 ; GFX8-NEXT: s_bfe_u32 s2, s2, 0x100000
3626 ; GFX8-NEXT: s_lshl_b32 s3, s3, 16
3627 ; GFX8-NEXT: s_or_b32 s2, s2, s3
3628 ; GFX8-NEXT: ; return to shader part epilog
3630 ; GFX9-LABEL: s_saddsat_v6i16:
3632 ; GFX9-NEXT: v_mov_b32_e32 v0, s3
3633 ; GFX9-NEXT: v_mov_b32_e32 v1, s4
3634 ; GFX9-NEXT: v_mov_b32_e32 v2, s5
3635 ; GFX9-NEXT: v_pk_add_i16 v0, s0, v0 clamp
3636 ; GFX9-NEXT: v_pk_add_i16 v1, s1, v1 clamp
3637 ; GFX9-NEXT: v_pk_add_i16 v2, s2, v2 clamp
3638 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
3639 ; GFX9-NEXT: v_readfirstlane_b32 s1, v1
3640 ; GFX9-NEXT: v_readfirstlane_b32 s2, v2
3641 ; GFX9-NEXT: ; return to shader part epilog
3643 ; GFX10-LABEL: s_saddsat_v6i16:
3645 ; GFX10-NEXT: v_pk_add_i16 v0, s0, s3 clamp
3646 ; GFX10-NEXT: v_pk_add_i16 v1, s1, s4 clamp
3647 ; GFX10-NEXT: v_pk_add_i16 v2, s2, s5 clamp
3648 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
3649 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
3650 ; GFX10-NEXT: v_readfirstlane_b32 s2, v2
3651 ; GFX10-NEXT: ; return to shader part epilog
3652 %result = call <6 x i16> @llvm.sadd.sat.v6i16(<6 x i16> %lhs, <6 x i16> %rhs)
3653 %cast = bitcast <6 x i16> %result to <3 x i32>
3657 define <4 x float> @v_saddsat_v8i16(<8 x i16> %lhs, <8 x i16> %rhs) {
3658 ; GFX6-LABEL: v_saddsat_v8i16:
3660 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3661 ; GFX6-NEXT: v_lshlrev_b32_e32 v0, 16, v0
3662 ; GFX6-NEXT: s_brev_b32 s5, 1
3663 ; GFX6-NEXT: v_min_i32_e32 v18, 0, v0
3664 ; GFX6-NEXT: v_lshlrev_b32_e32 v8, 16, v8
3665 ; GFX6-NEXT: s_brev_b32 s4, -2
3666 ; GFX6-NEXT: v_max_i32_e32 v16, 0, v0
3667 ; GFX6-NEXT: v_sub_i32_e32 v18, vcc, s5, v18
3668 ; GFX6-NEXT: v_sub_i32_e32 v16, vcc, s4, v16
3669 ; GFX6-NEXT: v_max_i32_e32 v8, v18, v8
3670 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
3671 ; GFX6-NEXT: v_min_i32_e32 v8, v8, v16
3672 ; GFX6-NEXT: v_min_i32_e32 v16, 0, v1
3673 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, v0, v8
3674 ; GFX6-NEXT: v_lshlrev_b32_e32 v8, 16, v9
3675 ; GFX6-NEXT: v_max_i32_e32 v9, 0, v1
3676 ; GFX6-NEXT: v_sub_i32_e32 v16, vcc, s5, v16
3677 ; GFX6-NEXT: v_sub_i32_e32 v9, vcc, s4, v9
3678 ; GFX6-NEXT: v_max_i32_e32 v8, v16, v8
3679 ; GFX6-NEXT: v_min_i32_e32 v8, v8, v9
3680 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
3681 ; GFX6-NEXT: v_add_i32_e32 v1, vcc, v1, v8
3682 ; GFX6-NEXT: v_lshlrev_b32_e32 v8, 16, v10
3683 ; GFX6-NEXT: v_min_i32_e32 v10, 0, v2
3684 ; GFX6-NEXT: v_bfrev_b32_e32 v17, -2
3685 ; GFX6-NEXT: v_max_i32_e32 v9, 0, v2
3686 ; GFX6-NEXT: v_sub_i32_e32 v10, vcc, s5, v10
3687 ; GFX6-NEXT: v_sub_i32_e32 v9, vcc, v17, v9
3688 ; GFX6-NEXT: v_max_i32_e32 v8, v10, v8
3689 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 16, v3
3690 ; GFX6-NEXT: v_bfrev_b32_e32 v19, 1
3691 ; GFX6-NEXT: v_min_i32_e32 v8, v8, v9
3692 ; GFX6-NEXT: v_min_i32_e32 v10, 0, v3
3693 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, v2, v8
3694 ; GFX6-NEXT: v_lshlrev_b32_e32 v8, 16, v11
3695 ; GFX6-NEXT: v_max_i32_e32 v9, 0, v3
3696 ; GFX6-NEXT: v_sub_i32_e32 v10, vcc, v19, v10
3697 ; GFX6-NEXT: v_sub_i32_e32 v9, vcc, v17, v9
3698 ; GFX6-NEXT: v_max_i32_e32 v8, v10, v8
3699 ; GFX6-NEXT: v_lshlrev_b32_e32 v4, 16, v4
3700 ; GFX6-NEXT: v_min_i32_e32 v8, v8, v9
3701 ; GFX6-NEXT: v_min_i32_e32 v10, 0, v4
3702 ; GFX6-NEXT: v_add_i32_e32 v3, vcc, v3, v8
3703 ; GFX6-NEXT: v_lshlrev_b32_e32 v8, 16, v12
3704 ; GFX6-NEXT: v_max_i32_e32 v9, 0, v4
3705 ; GFX6-NEXT: v_sub_i32_e32 v10, vcc, v19, v10
3706 ; GFX6-NEXT: v_sub_i32_e32 v9, vcc, v17, v9
3707 ; GFX6-NEXT: v_max_i32_e32 v8, v10, v8
3708 ; GFX6-NEXT: v_lshlrev_b32_e32 v5, 16, v5
3709 ; GFX6-NEXT: v_min_i32_e32 v8, v8, v9
3710 ; GFX6-NEXT: v_min_i32_e32 v10, 0, v5
3711 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v4, v8
3712 ; GFX6-NEXT: v_lshlrev_b32_e32 v8, 16, v13
3713 ; GFX6-NEXT: v_max_i32_e32 v9, 0, v5
3714 ; GFX6-NEXT: v_sub_i32_e32 v10, vcc, v19, v10
3715 ; GFX6-NEXT: v_sub_i32_e32 v9, vcc, v17, v9
3716 ; GFX6-NEXT: v_max_i32_e32 v8, v10, v8
3717 ; GFX6-NEXT: v_lshlrev_b32_e32 v6, 16, v6
3718 ; GFX6-NEXT: v_min_i32_e32 v8, v8, v9
3719 ; GFX6-NEXT: v_min_i32_e32 v10, 0, v6
3720 ; GFX6-NEXT: v_add_i32_e32 v5, vcc, v5, v8
3721 ; GFX6-NEXT: v_lshlrev_b32_e32 v8, 16, v14
3722 ; GFX6-NEXT: v_max_i32_e32 v9, 0, v6
3723 ; GFX6-NEXT: v_sub_i32_e32 v10, vcc, v19, v10
3724 ; GFX6-NEXT: v_sub_i32_e32 v9, vcc, v17, v9
3725 ; GFX6-NEXT: v_max_i32_e32 v8, v10, v8
3726 ; GFX6-NEXT: v_lshlrev_b32_e32 v7, 16, v7
3727 ; GFX6-NEXT: v_min_i32_e32 v8, v8, v9
3728 ; GFX6-NEXT: v_min_i32_e32 v10, 0, v7
3729 ; GFX6-NEXT: v_ashrrev_i32_e32 v1, 16, v1
3730 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, v6, v8
3731 ; GFX6-NEXT: v_lshlrev_b32_e32 v8, 16, v15
3732 ; GFX6-NEXT: v_max_i32_e32 v9, 0, v7
3733 ; GFX6-NEXT: v_sub_i32_e32 v10, vcc, v19, v10
3734 ; GFX6-NEXT: s_mov_b32 s4, 0xffff
3735 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 16, v0
3736 ; GFX6-NEXT: v_sub_i32_e32 v9, vcc, v17, v9
3737 ; GFX6-NEXT: v_max_i32_e32 v8, v10, v8
3738 ; GFX6-NEXT: v_and_b32_e32 v1, s4, v1
3739 ; GFX6-NEXT: v_ashrrev_i32_e32 v2, 16, v2
3740 ; GFX6-NEXT: v_ashrrev_i32_e32 v3, 16, v3
3741 ; GFX6-NEXT: v_min_i32_e32 v8, v8, v9
3742 ; GFX6-NEXT: v_and_b32_e32 v0, s4, v0
3743 ; GFX6-NEXT: v_lshlrev_b32_e32 v1, 16, v1
3744 ; GFX6-NEXT: v_ashrrev_i32_e32 v5, 16, v5
3745 ; GFX6-NEXT: v_add_i32_e32 v7, vcc, v7, v8
3746 ; GFX6-NEXT: v_or_b32_e32 v0, v0, v1
3747 ; GFX6-NEXT: v_and_b32_e32 v1, s4, v2
3748 ; GFX6-NEXT: v_and_b32_e32 v2, s4, v3
3749 ; GFX6-NEXT: v_ashrrev_i32_e32 v4, 16, v4
3750 ; GFX6-NEXT: v_ashrrev_i32_e32 v7, 16, v7
3751 ; GFX6-NEXT: v_lshlrev_b32_e32 v2, 16, v2
3752 ; GFX6-NEXT: v_and_b32_e32 v3, s4, v5
3753 ; GFX6-NEXT: v_ashrrev_i32_e32 v6, 16, v6
3754 ; GFX6-NEXT: v_or_b32_e32 v1, v1, v2
3755 ; GFX6-NEXT: v_and_b32_e32 v2, s4, v4
3756 ; GFX6-NEXT: v_lshlrev_b32_e32 v3, 16, v3
3757 ; GFX6-NEXT: v_and_b32_e32 v4, s4, v7
3758 ; GFX6-NEXT: v_or_b32_e32 v2, v2, v3
3759 ; GFX6-NEXT: v_and_b32_e32 v3, s4, v6
3760 ; GFX6-NEXT: v_lshlrev_b32_e32 v4, 16, v4
3761 ; GFX6-NEXT: v_or_b32_e32 v3, v3, v4
3762 ; GFX6-NEXT: s_setpc_b64 s[30:31]
3764 ; GFX8-LABEL: v_saddsat_v8i16:
3766 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3767 ; GFX8-NEXT: s_movk_i32 s5, 0x8000
3768 ; GFX8-NEXT: v_min_i16_e32 v14, 0, v0
3769 ; GFX8-NEXT: v_lshrrev_b32_e32 v8, 16, v0
3770 ; GFX8-NEXT: s_movk_i32 s4, 0x7fff
3771 ; GFX8-NEXT: v_max_i16_e32 v12, 0, v0
3772 ; GFX8-NEXT: v_sub_u16_e32 v14, s5, v14
3773 ; GFX8-NEXT: v_sub_u16_e32 v12, s4, v12
3774 ; GFX8-NEXT: v_max_i16_e32 v14, v14, v4
3775 ; GFX8-NEXT: v_min_i16_e32 v16, 0, v8
3776 ; GFX8-NEXT: v_min_i16_e32 v12, v14, v12
3777 ; GFX8-NEXT: v_max_i16_e32 v14, 0, v8
3778 ; GFX8-NEXT: v_sub_u16_e32 v16, s5, v16
3779 ; GFX8-NEXT: v_sub_u16_e32 v14, s4, v14
3780 ; GFX8-NEXT: v_max_i16_sdwa v4, v16, v4 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
3781 ; GFX8-NEXT: v_min_i16_e32 v16, 0, v1
3782 ; GFX8-NEXT: v_lshrrev_b32_e32 v9, 16, v1
3783 ; GFX8-NEXT: v_min_i16_e32 v4, v4, v14
3784 ; GFX8-NEXT: v_max_i16_e32 v14, 0, v1
3785 ; GFX8-NEXT: v_sub_u16_e32 v16, s5, v16
3786 ; GFX8-NEXT: v_sub_u16_e32 v14, s4, v14
3787 ; GFX8-NEXT: v_max_i16_e32 v16, v16, v5
3788 ; GFX8-NEXT: v_min_i16_e32 v17, 0, v9
3789 ; GFX8-NEXT: v_min_i16_e32 v14, v16, v14
3790 ; GFX8-NEXT: v_max_i16_e32 v16, 0, v9
3791 ; GFX8-NEXT: v_sub_u16_e32 v17, s5, v17
3792 ; GFX8-NEXT: v_mov_b32_e32 v15, 0xffff8000
3793 ; GFX8-NEXT: v_sub_u16_e32 v16, s4, v16
3794 ; GFX8-NEXT: v_max_i16_sdwa v5, v17, v5 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
3795 ; GFX8-NEXT: v_min_i16_e32 v17, 0, v2
3796 ; GFX8-NEXT: v_lshrrev_b32_e32 v10, 16, v2
3797 ; GFX8-NEXT: v_mov_b32_e32 v13, 0x7fff
3798 ; GFX8-NEXT: v_min_i16_e32 v5, v5, v16
3799 ; GFX8-NEXT: v_max_i16_e32 v16, 0, v2
3800 ; GFX8-NEXT: v_sub_u16_e32 v17, v15, v17
3801 ; GFX8-NEXT: v_sub_u16_e32 v16, v13, v16
3802 ; GFX8-NEXT: v_max_i16_e32 v17, v17, v6
3803 ; GFX8-NEXT: v_min_i16_e32 v18, 0, v10
3804 ; GFX8-NEXT: v_min_i16_e32 v16, v17, v16
3805 ; GFX8-NEXT: v_max_i16_e32 v17, 0, v10
3806 ; GFX8-NEXT: v_sub_u16_e32 v18, v15, v18
3807 ; GFX8-NEXT: v_sub_u16_e32 v17, v13, v17
3808 ; GFX8-NEXT: v_max_i16_sdwa v6, v18, v6 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
3809 ; GFX8-NEXT: v_min_i16_e32 v18, 0, v3
3810 ; GFX8-NEXT: v_min_i16_e32 v6, v6, v17
3811 ; GFX8-NEXT: v_max_i16_e32 v17, 0, v3
3812 ; GFX8-NEXT: v_sub_u16_e32 v18, v15, v18
3813 ; GFX8-NEXT: v_lshrrev_b32_e32 v11, 16, v3
3814 ; GFX8-NEXT: v_sub_u16_e32 v17, v13, v17
3815 ; GFX8-NEXT: v_max_i16_e32 v18, v18, v7
3816 ; GFX8-NEXT: v_min_i16_e32 v17, v18, v17
3817 ; GFX8-NEXT: v_max_i16_e32 v18, 0, v11
3818 ; GFX8-NEXT: v_sub_u16_e32 v13, v13, v18
3819 ; GFX8-NEXT: v_min_i16_e32 v18, 0, v11
3820 ; GFX8-NEXT: v_sub_u16_e32 v15, v15, v18
3821 ; GFX8-NEXT: v_add_u16_e32 v0, v0, v12
3822 ; GFX8-NEXT: v_add_u16_sdwa v4, v8, v4 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
3823 ; GFX8-NEXT: v_max_i16_sdwa v7, v15, v7 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:WORD_1
3824 ; GFX8-NEXT: v_or_b32_e32 v0, v0, v4
3825 ; GFX8-NEXT: v_add_u16_e32 v1, v1, v14
3826 ; GFX8-NEXT: v_add_u16_sdwa v4, v9, v5 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
3827 ; GFX8-NEXT: v_min_i16_e32 v7, v7, v13
3828 ; GFX8-NEXT: v_or_b32_e32 v1, v1, v4
3829 ; GFX8-NEXT: v_add_u16_e32 v2, v2, v16
3830 ; GFX8-NEXT: v_add_u16_sdwa v4, v10, v6 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
3831 ; GFX8-NEXT: v_or_b32_e32 v2, v2, v4
3832 ; GFX8-NEXT: v_add_u16_e32 v3, v3, v17
3833 ; GFX8-NEXT: v_add_u16_sdwa v4, v11, v7 dst_sel:WORD_1 dst_unused:UNUSED_PAD src0_sel:DWORD src1_sel:DWORD
3834 ; GFX8-NEXT: v_or_b32_e32 v3, v3, v4
3835 ; GFX8-NEXT: s_setpc_b64 s[30:31]
3837 ; GFX9-LABEL: v_saddsat_v8i16:
3839 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3840 ; GFX9-NEXT: v_pk_add_i16 v0, v0, v4 clamp
3841 ; GFX9-NEXT: v_pk_add_i16 v1, v1, v5 clamp
3842 ; GFX9-NEXT: v_pk_add_i16 v2, v2, v6 clamp
3843 ; GFX9-NEXT: v_pk_add_i16 v3, v3, v7 clamp
3844 ; GFX9-NEXT: s_setpc_b64 s[30:31]
3846 ; GFX10-LABEL: v_saddsat_v8i16:
3848 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
3849 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
3850 ; GFX10-NEXT: v_pk_add_i16 v0, v0, v4 clamp
3851 ; GFX10-NEXT: v_pk_add_i16 v1, v1, v5 clamp
3852 ; GFX10-NEXT: v_pk_add_i16 v2, v2, v6 clamp
3853 ; GFX10-NEXT: v_pk_add_i16 v3, v3, v7 clamp
3854 ; GFX10-NEXT: s_setpc_b64 s[30:31]
3855 %result = call <8 x i16> @llvm.sadd.sat.v8i16(<8 x i16> %lhs, <8 x i16> %rhs)
3856 %cast = bitcast <8 x i16> %result to <4 x float>
3857 ret <4 x float> %cast
3860 define amdgpu_ps <4 x i32> @s_saddsat_v8i16(<8 x i16> inreg %lhs, <8 x i16> inreg %rhs) {
3861 ; GFX6-LABEL: s_saddsat_v8i16:
3863 ; GFX6-NEXT: s_lshl_b32 s0, s0, 16
3864 ; GFX6-NEXT: s_brev_b32 s17, 1
3865 ; GFX6-NEXT: s_min_i32 s19, s0, 0
3866 ; GFX6-NEXT: s_lshl_b32 s8, s8, 16
3867 ; GFX6-NEXT: s_brev_b32 s16, -2
3868 ; GFX6-NEXT: s_max_i32 s18, s0, 0
3869 ; GFX6-NEXT: s_sub_i32 s19, s17, s19
3870 ; GFX6-NEXT: s_sub_i32 s18, s16, s18
3871 ; GFX6-NEXT: s_max_i32 s8, s19, s8
3872 ; GFX6-NEXT: s_lshl_b32 s1, s1, 16
3873 ; GFX6-NEXT: s_min_i32 s8, s8, s18
3874 ; GFX6-NEXT: s_min_i32 s18, s1, 0
3875 ; GFX6-NEXT: s_add_i32 s0, s0, s8
3876 ; GFX6-NEXT: s_lshl_b32 s8, s9, 16
3877 ; GFX6-NEXT: s_max_i32 s9, s1, 0
3878 ; GFX6-NEXT: s_sub_i32 s18, s17, s18
3879 ; GFX6-NEXT: s_sub_i32 s9, s16, s9
3880 ; GFX6-NEXT: s_max_i32 s8, s18, s8
3881 ; GFX6-NEXT: s_min_i32 s8, s8, s9
3882 ; GFX6-NEXT: s_lshl_b32 s2, s2, 16
3883 ; GFX6-NEXT: s_add_i32 s1, s1, s8
3884 ; GFX6-NEXT: s_lshl_b32 s8, s10, 16
3885 ; GFX6-NEXT: s_min_i32 s10, s2, 0
3886 ; GFX6-NEXT: s_max_i32 s9, s2, 0
3887 ; GFX6-NEXT: s_sub_i32 s10, s17, s10
3888 ; GFX6-NEXT: s_sub_i32 s9, s16, s9
3889 ; GFX6-NEXT: s_max_i32 s8, s10, s8
3890 ; GFX6-NEXT: s_lshl_b32 s3, s3, 16
3891 ; GFX6-NEXT: s_min_i32 s8, s8, s9
3892 ; GFX6-NEXT: s_min_i32 s10, s3, 0
3893 ; GFX6-NEXT: s_add_i32 s2, s2, s8
3894 ; GFX6-NEXT: s_lshl_b32 s8, s11, 16
3895 ; GFX6-NEXT: s_max_i32 s9, s3, 0
3896 ; GFX6-NEXT: s_sub_i32 s10, s17, s10
3897 ; GFX6-NEXT: s_sub_i32 s9, s16, s9
3898 ; GFX6-NEXT: s_max_i32 s8, s10, s8
3899 ; GFX6-NEXT: s_lshl_b32 s4, s4, 16
3900 ; GFX6-NEXT: s_min_i32 s8, s8, s9
3901 ; GFX6-NEXT: s_min_i32 s10, s4, 0
3902 ; GFX6-NEXT: s_add_i32 s3, s3, s8
3903 ; GFX6-NEXT: s_lshl_b32 s8, s12, 16
3904 ; GFX6-NEXT: s_max_i32 s9, s4, 0
3905 ; GFX6-NEXT: s_sub_i32 s10, s17, s10
3906 ; GFX6-NEXT: s_sub_i32 s9, s16, s9
3907 ; GFX6-NEXT: s_max_i32 s8, s10, s8
3908 ; GFX6-NEXT: s_lshl_b32 s5, s5, 16
3909 ; GFX6-NEXT: s_min_i32 s8, s8, s9
3910 ; GFX6-NEXT: s_min_i32 s10, s5, 0
3911 ; GFX6-NEXT: s_add_i32 s4, s4, s8
3912 ; GFX6-NEXT: s_lshl_b32 s8, s13, 16
3913 ; GFX6-NEXT: s_max_i32 s9, s5, 0
3914 ; GFX6-NEXT: s_sub_i32 s10, s17, s10
3915 ; GFX6-NEXT: s_sub_i32 s9, s16, s9
3916 ; GFX6-NEXT: s_max_i32 s8, s10, s8
3917 ; GFX6-NEXT: s_lshl_b32 s6, s6, 16
3918 ; GFX6-NEXT: s_min_i32 s8, s8, s9
3919 ; GFX6-NEXT: s_min_i32 s10, s6, 0
3920 ; GFX6-NEXT: s_add_i32 s5, s5, s8
3921 ; GFX6-NEXT: s_lshl_b32 s8, s14, 16
3922 ; GFX6-NEXT: s_max_i32 s9, s6, 0
3923 ; GFX6-NEXT: s_sub_i32 s10, s17, s10
3924 ; GFX6-NEXT: s_sub_i32 s9, s16, s9
3925 ; GFX6-NEXT: s_max_i32 s8, s10, s8
3926 ; GFX6-NEXT: s_lshl_b32 s7, s7, 16
3927 ; GFX6-NEXT: s_min_i32 s8, s8, s9
3928 ; GFX6-NEXT: s_min_i32 s10, s7, 0
3929 ; GFX6-NEXT: s_add_i32 s6, s6, s8
3930 ; GFX6-NEXT: s_lshl_b32 s8, s15, 16
3931 ; GFX6-NEXT: s_max_i32 s9, s7, 0
3932 ; GFX6-NEXT: s_sub_i32 s10, s17, s10
3933 ; GFX6-NEXT: s_sub_i32 s9, s16, s9
3934 ; GFX6-NEXT: s_max_i32 s8, s10, s8
3935 ; GFX6-NEXT: s_min_i32 s8, s8, s9
3936 ; GFX6-NEXT: s_ashr_i32 s1, s1, 16
3937 ; GFX6-NEXT: s_add_i32 s7, s7, s8
3938 ; GFX6-NEXT: s_mov_b32 s8, 0xffff
3939 ; GFX6-NEXT: s_ashr_i32 s0, s0, 16
3940 ; GFX6-NEXT: s_and_b32 s1, s1, s8
3941 ; GFX6-NEXT: s_ashr_i32 s2, s2, 16
3942 ; GFX6-NEXT: s_ashr_i32 s3, s3, 16
3943 ; GFX6-NEXT: s_and_b32 s0, s0, s8
3944 ; GFX6-NEXT: s_lshl_b32 s1, s1, 16
3945 ; GFX6-NEXT: s_ashr_i32 s5, s5, 16
3946 ; GFX6-NEXT: s_or_b32 s0, s0, s1
3947 ; GFX6-NEXT: s_and_b32 s1, s2, s8
3948 ; GFX6-NEXT: s_and_b32 s2, s3, s8
3949 ; GFX6-NEXT: s_ashr_i32 s4, s4, 16
3950 ; GFX6-NEXT: s_ashr_i32 s7, s7, 16
3951 ; GFX6-NEXT: s_lshl_b32 s2, s2, 16
3952 ; GFX6-NEXT: s_and_b32 s3, s5, s8
3953 ; GFX6-NEXT: s_ashr_i32 s6, s6, 16
3954 ; GFX6-NEXT: s_or_b32 s1, s1, s2
3955 ; GFX6-NEXT: s_and_b32 s2, s4, s8
3956 ; GFX6-NEXT: s_lshl_b32 s3, s3, 16
3957 ; GFX6-NEXT: s_and_b32 s4, s7, s8
3958 ; GFX6-NEXT: s_or_b32 s2, s2, s3
3959 ; GFX6-NEXT: s_and_b32 s3, s6, s8
3960 ; GFX6-NEXT: s_lshl_b32 s4, s4, 16
3961 ; GFX6-NEXT: s_or_b32 s3, s3, s4
3962 ; GFX6-NEXT: ; return to shader part epilog
3964 ; GFX8-LABEL: s_saddsat_v8i16:
3966 ; GFX8-NEXT: s_sext_i32_i16 s18, s0
3967 ; GFX8-NEXT: s_sext_i32_i16 s19, 0
3968 ; GFX8-NEXT: s_movk_i32 s17, 0x8000
3969 ; GFX8-NEXT: s_max_i32 s20, s18, s19
3970 ; GFX8-NEXT: s_min_i32 s18, s18, s19
3971 ; GFX8-NEXT: s_sub_i32 s18, s17, s18
3972 ; GFX8-NEXT: s_lshr_b32 s12, s4, 16
3973 ; GFX8-NEXT: s_movk_i32 s16, 0x7fff
3974 ; GFX8-NEXT: s_sext_i32_i16 s18, s18
3975 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
3976 ; GFX8-NEXT: s_sub_i32 s20, s16, s20
3977 ; GFX8-NEXT: s_max_i32 s4, s18, s4
3978 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
3979 ; GFX8-NEXT: s_sext_i32_i16 s18, s20
3980 ; GFX8-NEXT: s_lshr_b32 s8, s0, 16
3981 ; GFX8-NEXT: s_min_i32 s4, s4, s18
3982 ; GFX8-NEXT: s_add_i32 s0, s0, s4
3983 ; GFX8-NEXT: s_sext_i32_i16 s4, s8
3984 ; GFX8-NEXT: s_max_i32 s18, s4, s19
3985 ; GFX8-NEXT: s_min_i32 s4, s4, s19
3986 ; GFX8-NEXT: s_sub_i32 s4, s17, s4
3987 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
3988 ; GFX8-NEXT: s_sext_i32_i16 s12, s12
3989 ; GFX8-NEXT: s_sub_i32 s18, s16, s18
3990 ; GFX8-NEXT: s_max_i32 s4, s4, s12
3991 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
3992 ; GFX8-NEXT: s_sext_i32_i16 s12, s18
3993 ; GFX8-NEXT: s_min_i32 s4, s4, s12
3994 ; GFX8-NEXT: s_add_i32 s8, s8, s4
3995 ; GFX8-NEXT: s_sext_i32_i16 s4, s1
3996 ; GFX8-NEXT: s_max_i32 s12, s4, s19
3997 ; GFX8-NEXT: s_min_i32 s4, s4, s19
3998 ; GFX8-NEXT: s_sub_i32 s4, s17, s4
3999 ; GFX8-NEXT: s_lshr_b32 s13, s5, 16
4000 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4001 ; GFX8-NEXT: s_sext_i32_i16 s5, s5
4002 ; GFX8-NEXT: s_sub_i32 s12, s16, s12
4003 ; GFX8-NEXT: s_max_i32 s4, s4, s5
4004 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4005 ; GFX8-NEXT: s_sext_i32_i16 s5, s12
4006 ; GFX8-NEXT: s_lshr_b32 s9, s1, 16
4007 ; GFX8-NEXT: s_min_i32 s4, s4, s5
4008 ; GFX8-NEXT: s_add_i32 s1, s1, s4
4009 ; GFX8-NEXT: s_sext_i32_i16 s4, s9
4010 ; GFX8-NEXT: s_max_i32 s5, s4, s19
4011 ; GFX8-NEXT: s_min_i32 s4, s4, s19
4012 ; GFX8-NEXT: s_sub_i32 s4, s17, s4
4013 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4014 ; GFX8-NEXT: s_sext_i32_i16 s12, s13
4015 ; GFX8-NEXT: s_sub_i32 s5, s16, s5
4016 ; GFX8-NEXT: s_max_i32 s4, s4, s12
4017 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4018 ; GFX8-NEXT: s_sext_i32_i16 s5, s5
4019 ; GFX8-NEXT: s_min_i32 s4, s4, s5
4020 ; GFX8-NEXT: s_add_i32 s9, s9, s4
4021 ; GFX8-NEXT: s_sext_i32_i16 s4, s2
4022 ; GFX8-NEXT: s_max_i32 s5, s4, s19
4023 ; GFX8-NEXT: s_min_i32 s4, s4, s19
4024 ; GFX8-NEXT: s_sub_i32 s4, s17, s4
4025 ; GFX8-NEXT: s_lshr_b32 s14, s6, 16
4026 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4027 ; GFX8-NEXT: s_sext_i32_i16 s6, s6
4028 ; GFX8-NEXT: s_sub_i32 s5, s16, s5
4029 ; GFX8-NEXT: s_max_i32 s4, s4, s6
4030 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4031 ; GFX8-NEXT: s_sext_i32_i16 s5, s5
4032 ; GFX8-NEXT: s_lshr_b32 s10, s2, 16
4033 ; GFX8-NEXT: s_min_i32 s4, s4, s5
4034 ; GFX8-NEXT: s_add_i32 s2, s2, s4
4035 ; GFX8-NEXT: s_sext_i32_i16 s4, s10
4036 ; GFX8-NEXT: s_max_i32 s5, s4, s19
4037 ; GFX8-NEXT: s_min_i32 s4, s4, s19
4038 ; GFX8-NEXT: s_sub_i32 s4, s17, s4
4039 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4040 ; GFX8-NEXT: s_sext_i32_i16 s6, s14
4041 ; GFX8-NEXT: s_sub_i32 s5, s16, s5
4042 ; GFX8-NEXT: s_max_i32 s4, s4, s6
4043 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4044 ; GFX8-NEXT: s_sext_i32_i16 s5, s5
4045 ; GFX8-NEXT: s_min_i32 s4, s4, s5
4046 ; GFX8-NEXT: s_add_i32 s10, s10, s4
4047 ; GFX8-NEXT: s_sext_i32_i16 s4, s3
4048 ; GFX8-NEXT: s_max_i32 s5, s4, s19
4049 ; GFX8-NEXT: s_min_i32 s4, s4, s19
4050 ; GFX8-NEXT: s_sub_i32 s4, s17, s4
4051 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4052 ; GFX8-NEXT: s_sext_i32_i16 s6, s7
4053 ; GFX8-NEXT: s_sub_i32 s5, s16, s5
4054 ; GFX8-NEXT: s_max_i32 s4, s4, s6
4055 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4056 ; GFX8-NEXT: s_sext_i32_i16 s5, s5
4057 ; GFX8-NEXT: s_lshr_b32 s11, s3, 16
4058 ; GFX8-NEXT: s_min_i32 s4, s4, s5
4059 ; GFX8-NEXT: s_add_i32 s3, s3, s4
4060 ; GFX8-NEXT: s_sext_i32_i16 s4, s11
4061 ; GFX8-NEXT: s_max_i32 s5, s4, s19
4062 ; GFX8-NEXT: s_min_i32 s4, s4, s19
4063 ; GFX8-NEXT: s_lshr_b32 s15, s7, 16
4064 ; GFX8-NEXT: s_sub_i32 s4, s17, s4
4065 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4066 ; GFX8-NEXT: s_sext_i32_i16 s6, s15
4067 ; GFX8-NEXT: s_sub_i32 s5, s16, s5
4068 ; GFX8-NEXT: s_max_i32 s4, s4, s6
4069 ; GFX8-NEXT: s_sext_i32_i16 s4, s4
4070 ; GFX8-NEXT: s_sext_i32_i16 s5, s5
4071 ; GFX8-NEXT: s_min_i32 s4, s4, s5
4072 ; GFX8-NEXT: s_add_i32 s11, s11, s4
4073 ; GFX8-NEXT: s_bfe_u32 s4, s8, 0x100000
4074 ; GFX8-NEXT: s_bfe_u32 s0, s0, 0x100000
4075 ; GFX8-NEXT: s_lshl_b32 s4, s4, 16
4076 ; GFX8-NEXT: s_or_b32 s0, s0, s4
4077 ; GFX8-NEXT: s_bfe_u32 s4, s9, 0x100000
4078 ; GFX8-NEXT: s_bfe_u32 s1, s1, 0x100000
4079 ; GFX8-NEXT: s_lshl_b32 s4, s4, 16
4080 ; GFX8-NEXT: s_or_b32 s1, s1, s4
4081 ; GFX8-NEXT: s_bfe_u32 s4, s10, 0x100000
4082 ; GFX8-NEXT: s_bfe_u32 s2, s2, 0x100000
4083 ; GFX8-NEXT: s_lshl_b32 s4, s4, 16
4084 ; GFX8-NEXT: s_or_b32 s2, s2, s4
4085 ; GFX8-NEXT: s_bfe_u32 s4, s11, 0x100000
4086 ; GFX8-NEXT: s_bfe_u32 s3, s3, 0x100000
4087 ; GFX8-NEXT: s_lshl_b32 s4, s4, 16
4088 ; GFX8-NEXT: s_or_b32 s3, s3, s4
4089 ; GFX8-NEXT: ; return to shader part epilog
4091 ; GFX9-LABEL: s_saddsat_v8i16:
4093 ; GFX9-NEXT: v_mov_b32_e32 v0, s4
4094 ; GFX9-NEXT: v_mov_b32_e32 v1, s5
4095 ; GFX9-NEXT: v_mov_b32_e32 v2, s6
4096 ; GFX9-NEXT: v_mov_b32_e32 v3, s7
4097 ; GFX9-NEXT: v_pk_add_i16 v0, s0, v0 clamp
4098 ; GFX9-NEXT: v_pk_add_i16 v1, s1, v1 clamp
4099 ; GFX9-NEXT: v_pk_add_i16 v2, s2, v2 clamp
4100 ; GFX9-NEXT: v_pk_add_i16 v3, s3, v3 clamp
4101 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
4102 ; GFX9-NEXT: v_readfirstlane_b32 s1, v1
4103 ; GFX9-NEXT: v_readfirstlane_b32 s2, v2
4104 ; GFX9-NEXT: v_readfirstlane_b32 s3, v3
4105 ; GFX9-NEXT: ; return to shader part epilog
4107 ; GFX10-LABEL: s_saddsat_v8i16:
4109 ; GFX10-NEXT: v_pk_add_i16 v0, s0, s4 clamp
4110 ; GFX10-NEXT: v_pk_add_i16 v1, s1, s5 clamp
4111 ; GFX10-NEXT: v_pk_add_i16 v2, s2, s6 clamp
4112 ; GFX10-NEXT: v_pk_add_i16 v3, s3, s7 clamp
4113 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
4114 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
4115 ; GFX10-NEXT: v_readfirstlane_b32 s2, v2
4116 ; GFX10-NEXT: v_readfirstlane_b32 s3, v3
4117 ; GFX10-NEXT: ; return to shader part epilog
4118 %result = call <8 x i16> @llvm.sadd.sat.v8i16(<8 x i16> %lhs, <8 x i16> %rhs)
4119 %cast = bitcast <8 x i16> %result to <4 x i32>
4123 ; FIXME: i48 broken because i48 add broken
4124 ; define i48 @v_saddsat_i48(i48 %lhs, i48 %rhs) {
4125 ; %result = call i48 @llvm.sadd.sat.i48(i48 %lhs, i48 %rhs)
4129 ; define amdgpu_ps i48 @s_saddsat_i48(i48 inreg %lhs, i48 inreg %rhs) {
4130 ; %result = call i48 @llvm.sadd.sat.i48(i48 %lhs, i48 %rhs)
4134 ; define amdgpu_ps <2 x float> @saddsat_i48_sv(i48 inreg %lhs, i48 %rhs) {
4135 ; %result = call i48 @llvm.sadd.sat.i48(i48 %lhs, i48 %rhs)
4136 ; %ext.result = zext i48 %result to i64
4137 ; %cast = bitcast i64 %ext.result to <2 x float>
4138 ; ret <2 x float> %cast
4141 ; define amdgpu_ps <2 x float> @saddsat_i48_vs(i48 %lhs, i48 inreg %rhs) {
4142 ; %result = call i48 @llvm.sadd.sat.i48(i48 %lhs, i48 %rhs)
4143 ; %ext.result = zext i48 %result to i64
4144 ; %cast = bitcast i64 %ext.result to <2 x float>
4145 ; ret <2 x float> %cast
4148 define i64 @v_saddsat_i64(i64 %lhs, i64 %rhs) {
4149 ; GFX6-LABEL: v_saddsat_i64:
4151 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
4152 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v0, v2
4153 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, v1, v3, vcc
4154 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, v[4:5], v[0:1]
4155 ; GFX6-NEXT: v_cmp_gt_i64_e64 s[4:5], 0, v[2:3]
4156 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 31, v5
4157 ; GFX6-NEXT: v_bfrev_b32_e32 v1, 1
4158 ; GFX6-NEXT: v_add_i32_e64 v2, s[6:7], 0, v0
4159 ; GFX6-NEXT: v_addc_u32_e64 v1, s[6:7], v0, v1, s[6:7]
4160 ; GFX6-NEXT: s_xor_b64 vcc, s[4:5], vcc
4161 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v4, v2, vcc
4162 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v5, v1, vcc
4163 ; GFX6-NEXT: s_setpc_b64 s[30:31]
4165 ; GFX8-LABEL: v_saddsat_i64:
4167 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
4168 ; GFX8-NEXT: v_add_u32_e32 v4, vcc, v0, v2
4169 ; GFX8-NEXT: v_addc_u32_e32 v5, vcc, v1, v3, vcc
4170 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, v[4:5], v[0:1]
4171 ; GFX8-NEXT: v_cmp_gt_i64_e64 s[4:5], 0, v[2:3]
4172 ; GFX8-NEXT: v_ashrrev_i32_e32 v0, 31, v5
4173 ; GFX8-NEXT: v_bfrev_b32_e32 v1, 1
4174 ; GFX8-NEXT: v_add_u32_e64 v2, s[6:7], 0, v0
4175 ; GFX8-NEXT: v_addc_u32_e64 v1, s[6:7], v0, v1, s[6:7]
4176 ; GFX8-NEXT: s_xor_b64 vcc, s[4:5], vcc
4177 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v4, v2, vcc
4178 ; GFX8-NEXT: v_cndmask_b32_e32 v1, v5, v1, vcc
4179 ; GFX8-NEXT: s_setpc_b64 s[30:31]
4181 ; GFX9-LABEL: v_saddsat_i64:
4183 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
4184 ; GFX9-NEXT: v_add_co_u32_e32 v4, vcc, v0, v2
4185 ; GFX9-NEXT: v_addc_co_u32_e32 v5, vcc, v1, v3, vcc
4186 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, v[4:5], v[0:1]
4187 ; GFX9-NEXT: v_cmp_gt_i64_e64 s[4:5], 0, v[2:3]
4188 ; GFX9-NEXT: v_ashrrev_i32_e32 v0, 31, v5
4189 ; GFX9-NEXT: v_bfrev_b32_e32 v1, 1
4190 ; GFX9-NEXT: v_add_co_u32_e64 v2, s[6:7], 0, v0
4191 ; GFX9-NEXT: v_addc_co_u32_e64 v1, s[6:7], v0, v1, s[6:7]
4192 ; GFX9-NEXT: s_xor_b64 vcc, s[4:5], vcc
4193 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v4, v2, vcc
4194 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v5, v1, vcc
4195 ; GFX9-NEXT: s_setpc_b64 s[30:31]
4197 ; GFX10-LABEL: v_saddsat_i64:
4199 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
4200 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
4201 ; GFX10-NEXT: v_add_co_u32 v4, vcc_lo, v0, v2
4202 ; GFX10-NEXT: v_add_co_ci_u32_e32 v5, vcc_lo, v1, v3, vcc_lo
4203 ; GFX10-NEXT: v_cmp_gt_i64_e32 vcc_lo, 0, v[2:3]
4204 ; GFX10-NEXT: v_ashrrev_i32_e32 v6, 31, v5
4205 ; GFX10-NEXT: v_cmp_lt_i64_e64 s4, v[4:5], v[0:1]
4206 ; GFX10-NEXT: v_add_co_u32 v0, s5, v6, 0
4207 ; GFX10-NEXT: v_add_co_ci_u32_e64 v1, s5, 0x80000000, v6, s5
4208 ; GFX10-NEXT: s_xor_b32 vcc_lo, vcc_lo, s4
4209 ; GFX10-NEXT: v_cndmask_b32_e32 v0, v4, v0, vcc_lo
4210 ; GFX10-NEXT: v_cndmask_b32_e32 v1, v5, v1, vcc_lo
4211 ; GFX10-NEXT: s_setpc_b64 s[30:31]
4212 %result = call i64 @llvm.sadd.sat.i64(i64 %lhs, i64 %rhs)
4216 define amdgpu_ps i64 @s_saddsat_i64(i64 inreg %lhs, i64 inreg %rhs) {
4217 ; GFX6-LABEL: s_saddsat_i64:
4219 ; GFX6-NEXT: s_add_u32 s4, s0, s2
4220 ; GFX6-NEXT: s_cselect_b32 s5, 1, 0
4221 ; GFX6-NEXT: s_and_b32 s5, s5, 1
4222 ; GFX6-NEXT: s_cmp_lg_u32 s5, 0
4223 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
4224 ; GFX6-NEXT: s_addc_u32 s5, s1, s3
4225 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
4226 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, s[4:5], v[0:1]
4227 ; GFX6-NEXT: v_cmp_lt_i64_e64 s[0:1], s[2:3], 0
4228 ; GFX6-NEXT: s_ashr_i32 s2, s5, 31
4229 ; GFX6-NEXT: s_xor_b64 vcc, s[0:1], vcc
4230 ; GFX6-NEXT: s_add_u32 s0, s2, 0
4231 ; GFX6-NEXT: s_cselect_b32 s1, 1, 0
4232 ; GFX6-NEXT: s_and_b32 s1, s1, 1
4233 ; GFX6-NEXT: s_cmp_lg_u32 s1, 0
4234 ; GFX6-NEXT: s_addc_u32 s1, s2, 0x80000000
4235 ; GFX6-NEXT: v_mov_b32_e32 v0, s4
4236 ; GFX6-NEXT: v_mov_b32_e32 v1, s0
4237 ; GFX6-NEXT: v_mov_b32_e32 v2, s1
4238 ; GFX6-NEXT: v_mov_b32_e32 v3, s5
4239 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
4240 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v3, v2, vcc
4241 ; GFX6-NEXT: v_readfirstlane_b32 s0, v0
4242 ; GFX6-NEXT: v_readfirstlane_b32 s1, v1
4243 ; GFX6-NEXT: ; return to shader part epilog
4245 ; GFX8-LABEL: s_saddsat_i64:
4247 ; GFX8-NEXT: s_add_u32 s4, s0, s2
4248 ; GFX8-NEXT: s_cselect_b32 s5, 1, 0
4249 ; GFX8-NEXT: s_and_b32 s5, s5, 1
4250 ; GFX8-NEXT: s_cmp_lg_u32 s5, 0
4251 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
4252 ; GFX8-NEXT: s_addc_u32 s5, s1, s3
4253 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
4254 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, s[4:5], v[0:1]
4255 ; GFX8-NEXT: v_cmp_lt_i64_e64 s[0:1], s[2:3], 0
4256 ; GFX8-NEXT: s_ashr_i32 s2, s5, 31
4257 ; GFX8-NEXT: s_xor_b64 vcc, s[0:1], vcc
4258 ; GFX8-NEXT: s_add_u32 s0, s2, 0
4259 ; GFX8-NEXT: s_cselect_b32 s1, 1, 0
4260 ; GFX8-NEXT: s_and_b32 s1, s1, 1
4261 ; GFX8-NEXT: s_cmp_lg_u32 s1, 0
4262 ; GFX8-NEXT: s_addc_u32 s1, s2, 0x80000000
4263 ; GFX8-NEXT: v_mov_b32_e32 v0, s4
4264 ; GFX8-NEXT: v_mov_b32_e32 v1, s0
4265 ; GFX8-NEXT: v_mov_b32_e32 v2, s1
4266 ; GFX8-NEXT: v_mov_b32_e32 v3, s5
4267 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
4268 ; GFX8-NEXT: v_cndmask_b32_e32 v1, v3, v2, vcc
4269 ; GFX8-NEXT: v_readfirstlane_b32 s0, v0
4270 ; GFX8-NEXT: v_readfirstlane_b32 s1, v1
4271 ; GFX8-NEXT: ; return to shader part epilog
4273 ; GFX9-LABEL: s_saddsat_i64:
4275 ; GFX9-NEXT: s_add_u32 s4, s0, s2
4276 ; GFX9-NEXT: s_cselect_b32 s5, 1, 0
4277 ; GFX9-NEXT: s_and_b32 s5, s5, 1
4278 ; GFX9-NEXT: s_cmp_lg_u32 s5, 0
4279 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
4280 ; GFX9-NEXT: s_addc_u32 s5, s1, s3
4281 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
4282 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, s[4:5], v[0:1]
4283 ; GFX9-NEXT: v_cmp_lt_i64_e64 s[0:1], s[2:3], 0
4284 ; GFX9-NEXT: s_ashr_i32 s2, s5, 31
4285 ; GFX9-NEXT: s_xor_b64 vcc, s[0:1], vcc
4286 ; GFX9-NEXT: s_add_u32 s0, s2, 0
4287 ; GFX9-NEXT: s_cselect_b32 s1, 1, 0
4288 ; GFX9-NEXT: s_and_b32 s1, s1, 1
4289 ; GFX9-NEXT: s_cmp_lg_u32 s1, 0
4290 ; GFX9-NEXT: s_addc_u32 s1, s2, 0x80000000
4291 ; GFX9-NEXT: v_mov_b32_e32 v0, s4
4292 ; GFX9-NEXT: v_mov_b32_e32 v1, s0
4293 ; GFX9-NEXT: v_mov_b32_e32 v2, s1
4294 ; GFX9-NEXT: v_mov_b32_e32 v3, s5
4295 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
4296 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v3, v2, vcc
4297 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
4298 ; GFX9-NEXT: v_readfirstlane_b32 s1, v1
4299 ; GFX9-NEXT: ; return to shader part epilog
4301 ; GFX10-LABEL: s_saddsat_i64:
4303 ; GFX10-NEXT: s_add_u32 s4, s0, s2
4304 ; GFX10-NEXT: s_cselect_b32 s5, 1, 0
4305 ; GFX10-NEXT: v_mov_b32_e32 v0, s4
4306 ; GFX10-NEXT: s_and_b32 s5, s5, 1
4307 ; GFX10-NEXT: s_cmp_lg_u32 s5, 0
4308 ; GFX10-NEXT: s_addc_u32 s5, s1, s3
4309 ; GFX10-NEXT: v_cmp_lt_i64_e64 s0, s[4:5], s[0:1]
4310 ; GFX10-NEXT: v_cmp_lt_i64_e64 s1, s[2:3], 0
4311 ; GFX10-NEXT: s_ashr_i32 s2, s5, 31
4312 ; GFX10-NEXT: v_mov_b32_e32 v1, s5
4313 ; GFX10-NEXT: s_xor_b32 s3, s1, s0
4314 ; GFX10-NEXT: s_add_u32 s0, s2, 0
4315 ; GFX10-NEXT: s_cselect_b32 s1, 1, 0
4316 ; GFX10-NEXT: v_cndmask_b32_e64 v0, v0, s0, s3
4317 ; GFX10-NEXT: s_and_b32 s1, s1, 1
4318 ; GFX10-NEXT: s_cmp_lg_u32 s1, 0
4319 ; GFX10-NEXT: s_addc_u32 s1, s2, 0x80000000
4320 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
4321 ; GFX10-NEXT: v_cndmask_b32_e64 v1, v1, s1, s3
4322 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
4323 ; GFX10-NEXT: ; return to shader part epilog
4324 %result = call i64 @llvm.sadd.sat.i64(i64 %lhs, i64 %rhs)
4328 define amdgpu_ps <2 x float> @saddsat_i64_sv(i64 inreg %lhs, i64 %rhs) {
4329 ; GFX6-LABEL: saddsat_i64_sv:
4331 ; GFX6-NEXT: v_mov_b32_e32 v3, s1
4332 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, s0, v0
4333 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v3, v1, vcc
4334 ; GFX6-NEXT: v_cmp_gt_i64_e32 vcc, s[0:1], v[2:3]
4335 ; GFX6-NEXT: v_cmp_gt_i64_e64 s[0:1], 0, v[0:1]
4336 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 31, v3
4337 ; GFX6-NEXT: v_bfrev_b32_e32 v1, 1
4338 ; GFX6-NEXT: v_add_i32_e64 v4, s[2:3], 0, v0
4339 ; GFX6-NEXT: v_addc_u32_e64 v1, s[2:3], v0, v1, s[2:3]
4340 ; GFX6-NEXT: s_xor_b64 vcc, s[0:1], vcc
4341 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v2, v4, vcc
4342 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
4343 ; GFX6-NEXT: ; return to shader part epilog
4345 ; GFX8-LABEL: saddsat_i64_sv:
4347 ; GFX8-NEXT: v_mov_b32_e32 v3, s1
4348 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, s0, v0
4349 ; GFX8-NEXT: v_addc_u32_e32 v3, vcc, v3, v1, vcc
4350 ; GFX8-NEXT: v_cmp_gt_i64_e32 vcc, s[0:1], v[2:3]
4351 ; GFX8-NEXT: v_cmp_gt_i64_e64 s[0:1], 0, v[0:1]
4352 ; GFX8-NEXT: v_ashrrev_i32_e32 v0, 31, v3
4353 ; GFX8-NEXT: v_bfrev_b32_e32 v1, 1
4354 ; GFX8-NEXT: v_add_u32_e64 v4, s[2:3], 0, v0
4355 ; GFX8-NEXT: v_addc_u32_e64 v1, s[2:3], v0, v1, s[2:3]
4356 ; GFX8-NEXT: s_xor_b64 vcc, s[0:1], vcc
4357 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v2, v4, vcc
4358 ; GFX8-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
4359 ; GFX8-NEXT: ; return to shader part epilog
4361 ; GFX9-LABEL: saddsat_i64_sv:
4363 ; GFX9-NEXT: v_mov_b32_e32 v3, s1
4364 ; GFX9-NEXT: v_add_co_u32_e32 v2, vcc, s0, v0
4365 ; GFX9-NEXT: v_addc_co_u32_e32 v3, vcc, v3, v1, vcc
4366 ; GFX9-NEXT: v_cmp_gt_i64_e32 vcc, s[0:1], v[2:3]
4367 ; GFX9-NEXT: v_cmp_gt_i64_e64 s[0:1], 0, v[0:1]
4368 ; GFX9-NEXT: v_ashrrev_i32_e32 v0, 31, v3
4369 ; GFX9-NEXT: v_bfrev_b32_e32 v1, 1
4370 ; GFX9-NEXT: v_add_co_u32_e64 v4, s[2:3], 0, v0
4371 ; GFX9-NEXT: v_addc_co_u32_e64 v1, s[2:3], v0, v1, s[2:3]
4372 ; GFX9-NEXT: s_xor_b64 vcc, s[0:1], vcc
4373 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v2, v4, vcc
4374 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
4375 ; GFX9-NEXT: ; return to shader part epilog
4377 ; GFX10-LABEL: saddsat_i64_sv:
4379 ; GFX10-NEXT: v_add_co_u32 v2, vcc_lo, s0, v0
4380 ; GFX10-NEXT: v_add_co_ci_u32_e32 v3, vcc_lo, s1, v1, vcc_lo
4381 ; GFX10-NEXT: v_cmp_gt_i64_e32 vcc_lo, 0, v[0:1]
4382 ; GFX10-NEXT: v_ashrrev_i32_e32 v4, 31, v3
4383 ; GFX10-NEXT: v_cmp_gt_i64_e64 s0, s[0:1], v[2:3]
4384 ; GFX10-NEXT: v_add_co_u32 v0, s1, v4, 0
4385 ; GFX10-NEXT: v_add_co_ci_u32_e64 v1, s1, 0x80000000, v4, s1
4386 ; GFX10-NEXT: s_xor_b32 vcc_lo, vcc_lo, s0
4387 ; GFX10-NEXT: v_cndmask_b32_e32 v0, v2, v0, vcc_lo
4388 ; GFX10-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc_lo
4389 ; GFX10-NEXT: ; return to shader part epilog
4390 %result = call i64 @llvm.sadd.sat.i64(i64 %lhs, i64 %rhs)
4391 %cast = bitcast i64 %result to <2 x float>
4392 ret <2 x float> %cast
4395 define amdgpu_ps <2 x float> @saddsat_i64_vs(i64 %lhs, i64 inreg %rhs) {
4396 ; GFX6-LABEL: saddsat_i64_vs:
4398 ; GFX6-NEXT: v_mov_b32_e32 v3, s1
4399 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, s0, v0
4400 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v1, v3, vcc
4401 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, v[2:3], v[0:1]
4402 ; GFX6-NEXT: v_cmp_lt_i64_e64 s[2:3], s[0:1], 0
4403 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 31, v3
4404 ; GFX6-NEXT: v_bfrev_b32_e32 v1, 1
4405 ; GFX6-NEXT: v_add_i32_e64 v4, s[0:1], 0, v0
4406 ; GFX6-NEXT: v_addc_u32_e64 v1, s[0:1], v0, v1, s[0:1]
4407 ; GFX6-NEXT: s_xor_b64 vcc, s[2:3], vcc
4408 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v2, v4, vcc
4409 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
4410 ; GFX6-NEXT: ; return to shader part epilog
4412 ; GFX8-LABEL: saddsat_i64_vs:
4414 ; GFX8-NEXT: v_mov_b32_e32 v3, s1
4415 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, s0, v0
4416 ; GFX8-NEXT: v_addc_u32_e32 v3, vcc, v1, v3, vcc
4417 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, v[2:3], v[0:1]
4418 ; GFX8-NEXT: v_cmp_lt_i64_e64 s[2:3], s[0:1], 0
4419 ; GFX8-NEXT: v_ashrrev_i32_e32 v0, 31, v3
4420 ; GFX8-NEXT: v_bfrev_b32_e32 v1, 1
4421 ; GFX8-NEXT: v_add_u32_e64 v4, s[0:1], 0, v0
4422 ; GFX8-NEXT: v_addc_u32_e64 v1, s[0:1], v0, v1, s[0:1]
4423 ; GFX8-NEXT: s_xor_b64 vcc, s[2:3], vcc
4424 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v2, v4, vcc
4425 ; GFX8-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
4426 ; GFX8-NEXT: ; return to shader part epilog
4428 ; GFX9-LABEL: saddsat_i64_vs:
4430 ; GFX9-NEXT: v_mov_b32_e32 v3, s1
4431 ; GFX9-NEXT: v_add_co_u32_e32 v2, vcc, s0, v0
4432 ; GFX9-NEXT: v_addc_co_u32_e32 v3, vcc, v1, v3, vcc
4433 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, v[2:3], v[0:1]
4434 ; GFX9-NEXT: v_cmp_lt_i64_e64 s[2:3], s[0:1], 0
4435 ; GFX9-NEXT: v_ashrrev_i32_e32 v0, 31, v3
4436 ; GFX9-NEXT: v_bfrev_b32_e32 v1, 1
4437 ; GFX9-NEXT: v_add_co_u32_e64 v4, s[0:1], 0, v0
4438 ; GFX9-NEXT: v_addc_co_u32_e64 v1, s[0:1], v0, v1, s[0:1]
4439 ; GFX9-NEXT: s_xor_b64 vcc, s[2:3], vcc
4440 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v2, v4, vcc
4441 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc
4442 ; GFX9-NEXT: ; return to shader part epilog
4444 ; GFX10-LABEL: saddsat_i64_vs:
4446 ; GFX10-NEXT: v_add_co_u32 v2, vcc_lo, v0, s0
4447 ; GFX10-NEXT: v_add_co_ci_u32_e32 v3, vcc_lo, s1, v1, vcc_lo
4448 ; GFX10-NEXT: v_cmp_lt_i64_e64 s1, s[0:1], 0
4449 ; GFX10-NEXT: v_ashrrev_i32_e32 v4, 31, v3
4450 ; GFX10-NEXT: v_cmp_lt_i64_e32 vcc_lo, v[2:3], v[0:1]
4451 ; GFX10-NEXT: v_add_co_u32 v0, s0, v4, 0
4452 ; GFX10-NEXT: v_add_co_ci_u32_e64 v1, s0, 0x80000000, v4, s0
4453 ; GFX10-NEXT: s_xor_b32 vcc_lo, s1, vcc_lo
4454 ; GFX10-NEXT: v_cndmask_b32_e32 v0, v2, v0, vcc_lo
4455 ; GFX10-NEXT: v_cndmask_b32_e32 v1, v3, v1, vcc_lo
4456 ; GFX10-NEXT: ; return to shader part epilog
4457 %result = call i64 @llvm.sadd.sat.i64(i64 %lhs, i64 %rhs)
4458 %cast = bitcast i64 %result to <2 x float>
4459 ret <2 x float> %cast
4462 define <2 x i64> @v_saddsat_v2i64(<2 x i64> %lhs, <2 x i64> %rhs) {
4463 ; GFX6-LABEL: v_saddsat_v2i64:
4465 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
4466 ; GFX6-NEXT: v_add_i32_e32 v8, vcc, v0, v4
4467 ; GFX6-NEXT: v_addc_u32_e32 v9, vcc, v1, v5, vcc
4468 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, v[8:9], v[0:1]
4469 ; GFX6-NEXT: v_cmp_gt_i64_e64 s[4:5], 0, v[4:5]
4470 ; GFX6-NEXT: v_ashrrev_i32_e32 v0, 31, v9
4471 ; GFX6-NEXT: v_bfrev_b32_e32 v10, 1
4472 ; GFX6-NEXT: v_add_i32_e64 v1, s[6:7], 0, v0
4473 ; GFX6-NEXT: v_addc_u32_e64 v4, s[6:7], v0, v10, s[6:7]
4474 ; GFX6-NEXT: s_xor_b64 vcc, s[4:5], vcc
4475 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v8, v1, vcc
4476 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v9, v4, vcc
4477 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, v2, v6
4478 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, v3, v7, vcc
4479 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, v[4:5], v[2:3]
4480 ; GFX6-NEXT: v_cmp_gt_i64_e64 s[4:5], 0, v[6:7]
4481 ; GFX6-NEXT: v_ashrrev_i32_e32 v2, 31, v5
4482 ; GFX6-NEXT: v_add_i32_e64 v3, s[6:7], 0, v2
4483 ; GFX6-NEXT: v_addc_u32_e64 v6, s[6:7], v2, v10, s[6:7]
4484 ; GFX6-NEXT: s_xor_b64 vcc, s[4:5], vcc
4485 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v4, v3, vcc
4486 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v5, v6, vcc
4487 ; GFX6-NEXT: s_setpc_b64 s[30:31]
4489 ; GFX8-LABEL: v_saddsat_v2i64:
4491 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
4492 ; GFX8-NEXT: v_add_u32_e32 v8, vcc, v0, v4
4493 ; GFX8-NEXT: v_addc_u32_e32 v9, vcc, v1, v5, vcc
4494 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, v[8:9], v[0:1]
4495 ; GFX8-NEXT: v_cmp_gt_i64_e64 s[4:5], 0, v[4:5]
4496 ; GFX8-NEXT: v_ashrrev_i32_e32 v0, 31, v9
4497 ; GFX8-NEXT: v_bfrev_b32_e32 v10, 1
4498 ; GFX8-NEXT: v_add_u32_e64 v1, s[6:7], 0, v0
4499 ; GFX8-NEXT: v_addc_u32_e64 v4, s[6:7], v0, v10, s[6:7]
4500 ; GFX8-NEXT: s_xor_b64 vcc, s[4:5], vcc
4501 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v8, v1, vcc
4502 ; GFX8-NEXT: v_cndmask_b32_e32 v1, v9, v4, vcc
4503 ; GFX8-NEXT: v_add_u32_e32 v4, vcc, v2, v6
4504 ; GFX8-NEXT: v_addc_u32_e32 v5, vcc, v3, v7, vcc
4505 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, v[4:5], v[2:3]
4506 ; GFX8-NEXT: v_cmp_gt_i64_e64 s[4:5], 0, v[6:7]
4507 ; GFX8-NEXT: v_ashrrev_i32_e32 v2, 31, v5
4508 ; GFX8-NEXT: v_add_u32_e64 v3, s[6:7], 0, v2
4509 ; GFX8-NEXT: v_addc_u32_e64 v6, s[6:7], v2, v10, s[6:7]
4510 ; GFX8-NEXT: s_xor_b64 vcc, s[4:5], vcc
4511 ; GFX8-NEXT: v_cndmask_b32_e32 v2, v4, v3, vcc
4512 ; GFX8-NEXT: v_cndmask_b32_e32 v3, v5, v6, vcc
4513 ; GFX8-NEXT: s_setpc_b64 s[30:31]
4515 ; GFX9-LABEL: v_saddsat_v2i64:
4517 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
4518 ; GFX9-NEXT: v_add_co_u32_e32 v8, vcc, v0, v4
4519 ; GFX9-NEXT: v_addc_co_u32_e32 v9, vcc, v1, v5, vcc
4520 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, v[8:9], v[0:1]
4521 ; GFX9-NEXT: v_cmp_gt_i64_e64 s[4:5], 0, v[4:5]
4522 ; GFX9-NEXT: v_ashrrev_i32_e32 v0, 31, v9
4523 ; GFX9-NEXT: v_bfrev_b32_e32 v10, 1
4524 ; GFX9-NEXT: v_add_co_u32_e64 v1, s[6:7], 0, v0
4525 ; GFX9-NEXT: v_addc_co_u32_e64 v4, s[6:7], v0, v10, s[6:7]
4526 ; GFX9-NEXT: s_xor_b64 vcc, s[4:5], vcc
4527 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v8, v1, vcc
4528 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v9, v4, vcc
4529 ; GFX9-NEXT: v_add_co_u32_e32 v4, vcc, v2, v6
4530 ; GFX9-NEXT: v_addc_co_u32_e32 v5, vcc, v3, v7, vcc
4531 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, v[4:5], v[2:3]
4532 ; GFX9-NEXT: v_cmp_gt_i64_e64 s[4:5], 0, v[6:7]
4533 ; GFX9-NEXT: v_ashrrev_i32_e32 v2, 31, v5
4534 ; GFX9-NEXT: v_add_co_u32_e64 v3, s[6:7], 0, v2
4535 ; GFX9-NEXT: v_addc_co_u32_e64 v6, s[6:7], v2, v10, s[6:7]
4536 ; GFX9-NEXT: s_xor_b64 vcc, s[4:5], vcc
4537 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v4, v3, vcc
4538 ; GFX9-NEXT: v_cndmask_b32_e32 v3, v5, v6, vcc
4539 ; GFX9-NEXT: s_setpc_b64 s[30:31]
4541 ; GFX10-LABEL: v_saddsat_v2i64:
4543 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
4544 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
4545 ; GFX10-NEXT: v_add_co_u32 v8, vcc_lo, v0, v4
4546 ; GFX10-NEXT: v_add_co_ci_u32_e32 v9, vcc_lo, v1, v5, vcc_lo
4547 ; GFX10-NEXT: v_add_co_u32 v10, vcc_lo, v2, v6
4548 ; GFX10-NEXT: v_add_co_ci_u32_e32 v11, vcc_lo, v3, v7, vcc_lo
4549 ; GFX10-NEXT: v_ashrrev_i32_e32 v12, 31, v9
4550 ; GFX10-NEXT: v_cmp_lt_i64_e32 vcc_lo, v[8:9], v[0:1]
4551 ; GFX10-NEXT: v_cmp_gt_i64_e64 s4, 0, v[4:5]
4552 ; GFX10-NEXT: v_ashrrev_i32_e32 v0, 31, v11
4553 ; GFX10-NEXT: v_cmp_gt_i64_e64 s6, 0, v[6:7]
4554 ; GFX10-NEXT: v_add_co_u32 v1, s5, v12, 0
4555 ; GFX10-NEXT: v_add_co_ci_u32_e64 v4, s5, 0x80000000, v12, s5
4556 ; GFX10-NEXT: v_cmp_lt_i64_e64 s5, v[10:11], v[2:3]
4557 ; GFX10-NEXT: v_add_co_u32 v2, s7, v0, 0
4558 ; GFX10-NEXT: v_add_co_ci_u32_e64 v3, s7, 0x80000000, v0, s7
4559 ; GFX10-NEXT: s_xor_b32 vcc_lo, s4, vcc_lo
4560 ; GFX10-NEXT: v_cndmask_b32_e32 v0, v8, v1, vcc_lo
4561 ; GFX10-NEXT: v_cndmask_b32_e32 v1, v9, v4, vcc_lo
4562 ; GFX10-NEXT: s_xor_b32 vcc_lo, s6, s5
4563 ; GFX10-NEXT: v_cndmask_b32_e32 v2, v10, v2, vcc_lo
4564 ; GFX10-NEXT: v_cndmask_b32_e32 v3, v11, v3, vcc_lo
4565 ; GFX10-NEXT: s_setpc_b64 s[30:31]
4566 %result = call <2 x i64> @llvm.sadd.sat.v2i64(<2 x i64> %lhs, <2 x i64> %rhs)
4567 ret <2 x i64> %result
4570 define amdgpu_ps <2 x i64> @s_saddsat_v2i64(<2 x i64> inreg %lhs, <2 x i64> inreg %rhs) {
4571 ; GFX6-LABEL: s_saddsat_v2i64:
4573 ; GFX6-NEXT: s_add_u32 s8, s0, s4
4574 ; GFX6-NEXT: s_cselect_b32 s9, 1, 0
4575 ; GFX6-NEXT: s_and_b32 s9, s9, 1
4576 ; GFX6-NEXT: s_cmp_lg_u32 s9, 0
4577 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
4578 ; GFX6-NEXT: s_addc_u32 s9, s1, s5
4579 ; GFX6-NEXT: v_mov_b32_e32 v1, s1
4580 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, s[8:9], v[0:1]
4581 ; GFX6-NEXT: v_cmp_lt_i64_e64 s[0:1], s[4:5], 0
4582 ; GFX6-NEXT: s_ashr_i32 s4, s9, 31
4583 ; GFX6-NEXT: s_xor_b64 vcc, s[0:1], vcc
4584 ; GFX6-NEXT: s_add_u32 s0, s4, 0
4585 ; GFX6-NEXT: s_cselect_b32 s1, 1, 0
4586 ; GFX6-NEXT: s_and_b32 s1, s1, 1
4587 ; GFX6-NEXT: s_brev_b32 s5, 1
4588 ; GFX6-NEXT: s_cmp_lg_u32 s1, 0
4589 ; GFX6-NEXT: s_addc_u32 s1, s4, s5
4590 ; GFX6-NEXT: v_mov_b32_e32 v1, s0
4591 ; GFX6-NEXT: s_add_u32 s0, s2, s6
4592 ; GFX6-NEXT: v_mov_b32_e32 v2, s1
4593 ; GFX6-NEXT: s_cselect_b32 s1, 1, 0
4594 ; GFX6-NEXT: v_mov_b32_e32 v0, s8
4595 ; GFX6-NEXT: s_and_b32 s1, s1, 1
4596 ; GFX6-NEXT: v_cndmask_b32_e32 v4, v0, v1, vcc
4597 ; GFX6-NEXT: s_cmp_lg_u32 s1, 0
4598 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
4599 ; GFX6-NEXT: v_mov_b32_e32 v3, s9
4600 ; GFX6-NEXT: s_addc_u32 s1, s3, s7
4601 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
4602 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v3, v2, vcc
4603 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, s[0:1], v[0:1]
4604 ; GFX6-NEXT: v_cmp_lt_i64_e64 s[2:3], s[6:7], 0
4605 ; GFX6-NEXT: s_ashr_i32 s4, s1, 31
4606 ; GFX6-NEXT: s_xor_b64 vcc, s[2:3], vcc
4607 ; GFX6-NEXT: v_mov_b32_e32 v0, s0
4608 ; GFX6-NEXT: s_add_u32 s0, s4, 0
4609 ; GFX6-NEXT: s_cselect_b32 s2, 1, 0
4610 ; GFX6-NEXT: s_and_b32 s2, s2, 1
4611 ; GFX6-NEXT: s_cmp_lg_u32 s2, 0
4612 ; GFX6-NEXT: s_addc_u32 s3, s4, s5
4613 ; GFX6-NEXT: v_mov_b32_e32 v1, s0
4614 ; GFX6-NEXT: v_mov_b32_e32 v3, s3
4615 ; GFX6-NEXT: v_mov_b32_e32 v5, s1
4616 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
4617 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v5, v3, vcc
4618 ; GFX6-NEXT: v_readfirstlane_b32 s0, v4
4619 ; GFX6-NEXT: v_readfirstlane_b32 s1, v2
4620 ; GFX6-NEXT: v_readfirstlane_b32 s2, v0
4621 ; GFX6-NEXT: v_readfirstlane_b32 s3, v1
4622 ; GFX6-NEXT: ; return to shader part epilog
4624 ; GFX8-LABEL: s_saddsat_v2i64:
4626 ; GFX8-NEXT: s_add_u32 s8, s0, s4
4627 ; GFX8-NEXT: s_cselect_b32 s9, 1, 0
4628 ; GFX8-NEXT: s_and_b32 s9, s9, 1
4629 ; GFX8-NEXT: s_cmp_lg_u32 s9, 0
4630 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
4631 ; GFX8-NEXT: s_addc_u32 s9, s1, s5
4632 ; GFX8-NEXT: v_mov_b32_e32 v1, s1
4633 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, s[8:9], v[0:1]
4634 ; GFX8-NEXT: v_cmp_lt_i64_e64 s[0:1], s[4:5], 0
4635 ; GFX8-NEXT: s_ashr_i32 s4, s9, 31
4636 ; GFX8-NEXT: s_xor_b64 vcc, s[0:1], vcc
4637 ; GFX8-NEXT: s_add_u32 s0, s4, 0
4638 ; GFX8-NEXT: s_cselect_b32 s1, 1, 0
4639 ; GFX8-NEXT: s_and_b32 s1, s1, 1
4640 ; GFX8-NEXT: s_brev_b32 s5, 1
4641 ; GFX8-NEXT: s_cmp_lg_u32 s1, 0
4642 ; GFX8-NEXT: s_addc_u32 s1, s4, s5
4643 ; GFX8-NEXT: v_mov_b32_e32 v1, s0
4644 ; GFX8-NEXT: s_add_u32 s0, s2, s6
4645 ; GFX8-NEXT: v_mov_b32_e32 v2, s1
4646 ; GFX8-NEXT: s_cselect_b32 s1, 1, 0
4647 ; GFX8-NEXT: v_mov_b32_e32 v0, s8
4648 ; GFX8-NEXT: s_and_b32 s1, s1, 1
4649 ; GFX8-NEXT: v_cndmask_b32_e32 v4, v0, v1, vcc
4650 ; GFX8-NEXT: s_cmp_lg_u32 s1, 0
4651 ; GFX8-NEXT: v_mov_b32_e32 v0, s2
4652 ; GFX8-NEXT: v_mov_b32_e32 v3, s9
4653 ; GFX8-NEXT: s_addc_u32 s1, s3, s7
4654 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
4655 ; GFX8-NEXT: v_cndmask_b32_e32 v2, v3, v2, vcc
4656 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, s[0:1], v[0:1]
4657 ; GFX8-NEXT: v_cmp_lt_i64_e64 s[2:3], s[6:7], 0
4658 ; GFX8-NEXT: s_ashr_i32 s4, s1, 31
4659 ; GFX8-NEXT: s_xor_b64 vcc, s[2:3], vcc
4660 ; GFX8-NEXT: v_mov_b32_e32 v0, s0
4661 ; GFX8-NEXT: s_add_u32 s0, s4, 0
4662 ; GFX8-NEXT: s_cselect_b32 s2, 1, 0
4663 ; GFX8-NEXT: s_and_b32 s2, s2, 1
4664 ; GFX8-NEXT: s_cmp_lg_u32 s2, 0
4665 ; GFX8-NEXT: s_addc_u32 s3, s4, s5
4666 ; GFX8-NEXT: v_mov_b32_e32 v1, s0
4667 ; GFX8-NEXT: v_mov_b32_e32 v3, s3
4668 ; GFX8-NEXT: v_mov_b32_e32 v5, s1
4669 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
4670 ; GFX8-NEXT: v_cndmask_b32_e32 v1, v5, v3, vcc
4671 ; GFX8-NEXT: v_readfirstlane_b32 s0, v4
4672 ; GFX8-NEXT: v_readfirstlane_b32 s1, v2
4673 ; GFX8-NEXT: v_readfirstlane_b32 s2, v0
4674 ; GFX8-NEXT: v_readfirstlane_b32 s3, v1
4675 ; GFX8-NEXT: ; return to shader part epilog
4677 ; GFX9-LABEL: s_saddsat_v2i64:
4679 ; GFX9-NEXT: s_add_u32 s8, s0, s4
4680 ; GFX9-NEXT: s_cselect_b32 s9, 1, 0
4681 ; GFX9-NEXT: s_and_b32 s9, s9, 1
4682 ; GFX9-NEXT: s_cmp_lg_u32 s9, 0
4683 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
4684 ; GFX9-NEXT: s_addc_u32 s9, s1, s5
4685 ; GFX9-NEXT: v_mov_b32_e32 v1, s1
4686 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, s[8:9], v[0:1]
4687 ; GFX9-NEXT: v_cmp_lt_i64_e64 s[0:1], s[4:5], 0
4688 ; GFX9-NEXT: s_ashr_i32 s4, s9, 31
4689 ; GFX9-NEXT: s_xor_b64 vcc, s[0:1], vcc
4690 ; GFX9-NEXT: s_add_u32 s0, s4, 0
4691 ; GFX9-NEXT: s_cselect_b32 s1, 1, 0
4692 ; GFX9-NEXT: s_and_b32 s1, s1, 1
4693 ; GFX9-NEXT: s_brev_b32 s5, 1
4694 ; GFX9-NEXT: s_cmp_lg_u32 s1, 0
4695 ; GFX9-NEXT: s_addc_u32 s1, s4, s5
4696 ; GFX9-NEXT: v_mov_b32_e32 v1, s0
4697 ; GFX9-NEXT: s_add_u32 s0, s2, s6
4698 ; GFX9-NEXT: v_mov_b32_e32 v2, s1
4699 ; GFX9-NEXT: s_cselect_b32 s1, 1, 0
4700 ; GFX9-NEXT: v_mov_b32_e32 v0, s8
4701 ; GFX9-NEXT: s_and_b32 s1, s1, 1
4702 ; GFX9-NEXT: v_cndmask_b32_e32 v4, v0, v1, vcc
4703 ; GFX9-NEXT: s_cmp_lg_u32 s1, 0
4704 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
4705 ; GFX9-NEXT: v_mov_b32_e32 v3, s9
4706 ; GFX9-NEXT: s_addc_u32 s1, s3, s7
4707 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
4708 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v3, v2, vcc
4709 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, s[0:1], v[0:1]
4710 ; GFX9-NEXT: v_cmp_lt_i64_e64 s[2:3], s[6:7], 0
4711 ; GFX9-NEXT: s_ashr_i32 s4, s1, 31
4712 ; GFX9-NEXT: s_xor_b64 vcc, s[2:3], vcc
4713 ; GFX9-NEXT: v_mov_b32_e32 v0, s0
4714 ; GFX9-NEXT: s_add_u32 s0, s4, 0
4715 ; GFX9-NEXT: s_cselect_b32 s2, 1, 0
4716 ; GFX9-NEXT: s_and_b32 s2, s2, 1
4717 ; GFX9-NEXT: s_cmp_lg_u32 s2, 0
4718 ; GFX9-NEXT: s_addc_u32 s3, s4, s5
4719 ; GFX9-NEXT: v_mov_b32_e32 v1, s0
4720 ; GFX9-NEXT: v_mov_b32_e32 v3, s3
4721 ; GFX9-NEXT: v_mov_b32_e32 v5, s1
4722 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v1, vcc
4723 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v5, v3, vcc
4724 ; GFX9-NEXT: v_readfirstlane_b32 s0, v4
4725 ; GFX9-NEXT: v_readfirstlane_b32 s1, v2
4726 ; GFX9-NEXT: v_readfirstlane_b32 s2, v0
4727 ; GFX9-NEXT: v_readfirstlane_b32 s3, v1
4728 ; GFX9-NEXT: ; return to shader part epilog
4730 ; GFX10-LABEL: s_saddsat_v2i64:
4732 ; GFX10-NEXT: s_add_u32 s8, s0, s4
4733 ; GFX10-NEXT: s_cselect_b32 s9, 1, 0
4734 ; GFX10-NEXT: v_cmp_lt_i64_e64 s4, s[4:5], 0
4735 ; GFX10-NEXT: s_and_b32 s9, s9, 1
4736 ; GFX10-NEXT: v_mov_b32_e32 v0, s8
4737 ; GFX10-NEXT: s_cmp_lg_u32 s9, 0
4738 ; GFX10-NEXT: s_brev_b32 s10, 1
4739 ; GFX10-NEXT: s_addc_u32 s9, s1, s5
4740 ; GFX10-NEXT: v_cmp_lt_i64_e64 s0, s[8:9], s[0:1]
4741 ; GFX10-NEXT: s_ashr_i32 s1, s9, 31
4742 ; GFX10-NEXT: v_mov_b32_e32 v1, s9
4743 ; GFX10-NEXT: s_xor_b32 s8, s4, s0
4744 ; GFX10-NEXT: s_add_u32 s0, s1, 0
4745 ; GFX10-NEXT: s_cselect_b32 s4, 1, 0
4746 ; GFX10-NEXT: v_cndmask_b32_e64 v0, v0, s0, s8
4747 ; GFX10-NEXT: s_and_b32 s4, s4, 1
4748 ; GFX10-NEXT: s_cmp_lg_u32 s4, 0
4749 ; GFX10-NEXT: s_addc_u32 s1, s1, s10
4750 ; GFX10-NEXT: s_add_u32 s4, s2, s6
4751 ; GFX10-NEXT: s_cselect_b32 s5, 1, 0
4752 ; GFX10-NEXT: v_cndmask_b32_e64 v1, v1, s1, s8
4753 ; GFX10-NEXT: s_and_b32 s5, s5, 1
4754 ; GFX10-NEXT: v_mov_b32_e32 v2, s4
4755 ; GFX10-NEXT: s_cmp_lg_u32 s5, 0
4756 ; GFX10-NEXT: s_addc_u32 s5, s3, s7
4757 ; GFX10-NEXT: v_cmp_lt_i64_e64 s2, s[4:5], s[2:3]
4758 ; GFX10-NEXT: v_cmp_lt_i64_e64 s3, s[6:7], 0
4759 ; GFX10-NEXT: s_ashr_i32 s1, s5, 31
4760 ; GFX10-NEXT: v_mov_b32_e32 v3, s5
4761 ; GFX10-NEXT: s_xor_b32 s2, s3, s2
4762 ; GFX10-NEXT: s_add_u32 s0, s1, 0
4763 ; GFX10-NEXT: s_cselect_b32 s3, 1, 0
4764 ; GFX10-NEXT: v_cndmask_b32_e64 v2, v2, s0, s2
4765 ; GFX10-NEXT: s_and_b32 s3, s3, 1
4766 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
4767 ; GFX10-NEXT: s_cmp_lg_u32 s3, 0
4768 ; GFX10-NEXT: s_addc_u32 s1, s1, s10
4769 ; GFX10-NEXT: v_cndmask_b32_e64 v3, v3, s1, s2
4770 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
4771 ; GFX10-NEXT: v_readfirstlane_b32 s2, v2
4772 ; GFX10-NEXT: v_readfirstlane_b32 s3, v3
4773 ; GFX10-NEXT: ; return to shader part epilog
4774 %result = call <2 x i64> @llvm.sadd.sat.v2i64(<2 x i64> %lhs, <2 x i64> %rhs)
4775 ret <2 x i64> %result
4778 define amdgpu_ps i128 @s_saddsat_i128(i128 inreg %lhs, i128 inreg %rhs) {
4779 ; GFX6-LABEL: s_saddsat_i128:
4781 ; GFX6-NEXT: s_add_u32 s4, s0, s4
4782 ; GFX6-NEXT: s_cselect_b32 s8, 1, 0
4783 ; GFX6-NEXT: s_and_b32 s8, s8, 1
4784 ; GFX6-NEXT: s_cmp_lg_u32 s8, 0
4785 ; GFX6-NEXT: s_addc_u32 s5, s1, s5
4786 ; GFX6-NEXT: s_cselect_b32 s8, 1, 0
4787 ; GFX6-NEXT: s_and_b32 s8, s8, 1
4788 ; GFX6-NEXT: s_cmp_lg_u32 s8, 0
4789 ; GFX6-NEXT: s_addc_u32 s8, s2, s6
4790 ; GFX6-NEXT: s_cselect_b32 s9, 1, 0
4791 ; GFX6-NEXT: v_mov_b32_e32 v3, s1
4792 ; GFX6-NEXT: s_and_b32 s9, s9, 1
4793 ; GFX6-NEXT: v_mov_b32_e32 v2, s0
4794 ; GFX6-NEXT: s_cmp_lg_u32 s9, 0
4795 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
4796 ; GFX6-NEXT: v_cmp_lt_u64_e32 vcc, s[4:5], v[2:3]
4797 ; GFX6-NEXT: s_addc_u32 s9, s3, s7
4798 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
4799 ; GFX6-NEXT: v_cndmask_b32_e64 v2, 0, 1, vcc
4800 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, s[8:9], v[0:1]
4801 ; GFX6-NEXT: v_cmp_lt_i64_e64 s[0:1], s[6:7], 0
4802 ; GFX6-NEXT: v_cndmask_b32_e64 v3, 0, 1, vcc
4803 ; GFX6-NEXT: v_cmp_eq_u64_e32 vcc, s[8:9], v[0:1]
4804 ; GFX6-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[0:1]
4805 ; GFX6-NEXT: v_cmp_eq_u64_e64 s[0:1], s[6:7], 0
4806 ; GFX6-NEXT: s_ashr_i32 s3, s9, 31
4807 ; GFX6-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[0:1]
4808 ; GFX6-NEXT: s_add_u32 s0, s3, 0
4809 ; GFX6-NEXT: s_cselect_b32 s1, 1, 0
4810 ; GFX6-NEXT: s_and_b32 s1, s1, 1
4811 ; GFX6-NEXT: s_cmp_lg_u32 s1, 0
4812 ; GFX6-NEXT: s_addc_u32 s1, s3, 0
4813 ; GFX6-NEXT: s_cselect_b32 s2, 1, 0
4814 ; GFX6-NEXT: s_and_b32 s2, s2, 1
4815 ; GFX6-NEXT: s_cmp_lg_u32 s2, 0
4816 ; GFX6-NEXT: s_addc_u32 s2, s3, 0
4817 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v3, v2, vcc
4818 ; GFX6-NEXT: s_cselect_b32 s6, 1, 0
4819 ; GFX6-NEXT: v_xor_b32_e32 v0, v1, v0
4820 ; GFX6-NEXT: s_and_b32 s6, s6, 1
4821 ; GFX6-NEXT: s_cmp_lg_u32 s6, 0
4822 ; GFX6-NEXT: v_and_b32_e32 v0, 1, v0
4823 ; GFX6-NEXT: s_addc_u32 s3, s3, 0x80000000
4824 ; GFX6-NEXT: v_mov_b32_e32 v1, s0
4825 ; GFX6-NEXT: v_mov_b32_e32 v2, s1
4826 ; GFX6-NEXT: v_mov_b32_e32 v3, s4
4827 ; GFX6-NEXT: v_mov_b32_e32 v4, s5
4828 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
4829 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v3, v1, vcc
4830 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v4, v2, vcc
4831 ; GFX6-NEXT: v_mov_b32_e32 v2, s2
4832 ; GFX6-NEXT: v_mov_b32_e32 v3, s3
4833 ; GFX6-NEXT: v_mov_b32_e32 v4, s8
4834 ; GFX6-NEXT: v_mov_b32_e32 v5, s9
4835 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v4, v2, vcc
4836 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v5, v3, vcc
4837 ; GFX6-NEXT: v_readfirstlane_b32 s0, v0
4838 ; GFX6-NEXT: v_readfirstlane_b32 s1, v1
4839 ; GFX6-NEXT: v_readfirstlane_b32 s2, v2
4840 ; GFX6-NEXT: v_readfirstlane_b32 s3, v3
4841 ; GFX6-NEXT: ; return to shader part epilog
4843 ; GFX8-LABEL: s_saddsat_i128:
4845 ; GFX8-NEXT: s_add_u32 s4, s0, s4
4846 ; GFX8-NEXT: s_cselect_b32 s8, 1, 0
4847 ; GFX8-NEXT: s_and_b32 s8, s8, 1
4848 ; GFX8-NEXT: s_cmp_lg_u32 s8, 0
4849 ; GFX8-NEXT: s_addc_u32 s5, s1, s5
4850 ; GFX8-NEXT: s_cselect_b32 s8, 1, 0
4851 ; GFX8-NEXT: s_and_b32 s8, s8, 1
4852 ; GFX8-NEXT: s_cmp_lg_u32 s8, 0
4853 ; GFX8-NEXT: s_addc_u32 s8, s2, s6
4854 ; GFX8-NEXT: s_cselect_b32 s9, 1, 0
4855 ; GFX8-NEXT: s_and_b32 s9, s9, 1
4856 ; GFX8-NEXT: v_mov_b32_e32 v3, s1
4857 ; GFX8-NEXT: s_cmp_lg_u32 s9, 0
4858 ; GFX8-NEXT: v_mov_b32_e32 v2, s0
4859 ; GFX8-NEXT: s_addc_u32 s9, s3, s7
4860 ; GFX8-NEXT: v_mov_b32_e32 v0, s2
4861 ; GFX8-NEXT: v_cmp_lt_u64_e32 vcc, s[4:5], v[2:3]
4862 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
4863 ; GFX8-NEXT: s_cmp_eq_u64 s[8:9], s[2:3]
4864 ; GFX8-NEXT: s_cselect_b32 s2, 1, 0
4865 ; GFX8-NEXT: v_cndmask_b32_e64 v2, 0, 1, vcc
4866 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, s[8:9], v[0:1]
4867 ; GFX8-NEXT: s_and_b32 s0, 1, s2
4868 ; GFX8-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
4869 ; GFX8-NEXT: v_cmp_ne_u32_e64 vcc, 0, s0
4870 ; GFX8-NEXT: s_cmp_eq_u64 s[6:7], 0
4871 ; GFX8-NEXT: v_cmp_lt_i64_e64 s[0:1], s[6:7], 0
4872 ; GFX8-NEXT: s_cselect_b32 s2, 1, 0
4873 ; GFX8-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[0:1]
4874 ; GFX8-NEXT: s_and_b32 s0, 1, s2
4875 ; GFX8-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, s0
4876 ; GFX8-NEXT: s_ashr_i32 s3, s9, 31
4877 ; GFX8-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[0:1]
4878 ; GFX8-NEXT: s_add_u32 s0, s3, 0
4879 ; GFX8-NEXT: s_cselect_b32 s1, 1, 0
4880 ; GFX8-NEXT: s_and_b32 s1, s1, 1
4881 ; GFX8-NEXT: s_cmp_lg_u32 s1, 0
4882 ; GFX8-NEXT: s_addc_u32 s1, s3, 0
4883 ; GFX8-NEXT: s_cselect_b32 s2, 1, 0
4884 ; GFX8-NEXT: s_and_b32 s2, s2, 1
4885 ; GFX8-NEXT: s_cmp_lg_u32 s2, 0
4886 ; GFX8-NEXT: s_addc_u32 s2, s3, 0
4887 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
4888 ; GFX8-NEXT: s_cselect_b32 s6, 1, 0
4889 ; GFX8-NEXT: v_xor_b32_e32 v0, v1, v0
4890 ; GFX8-NEXT: s_and_b32 s6, s6, 1
4891 ; GFX8-NEXT: s_cmp_lg_u32 s6, 0
4892 ; GFX8-NEXT: v_and_b32_e32 v0, 1, v0
4893 ; GFX8-NEXT: s_addc_u32 s3, s3, 0x80000000
4894 ; GFX8-NEXT: v_mov_b32_e32 v1, s0
4895 ; GFX8-NEXT: v_mov_b32_e32 v2, s1
4896 ; GFX8-NEXT: v_mov_b32_e32 v3, s4
4897 ; GFX8-NEXT: v_mov_b32_e32 v4, s5
4898 ; GFX8-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
4899 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v3, v1, vcc
4900 ; GFX8-NEXT: v_cndmask_b32_e32 v1, v4, v2, vcc
4901 ; GFX8-NEXT: v_mov_b32_e32 v2, s2
4902 ; GFX8-NEXT: v_mov_b32_e32 v3, s3
4903 ; GFX8-NEXT: v_mov_b32_e32 v4, s8
4904 ; GFX8-NEXT: v_mov_b32_e32 v5, s9
4905 ; GFX8-NEXT: v_cndmask_b32_e32 v2, v4, v2, vcc
4906 ; GFX8-NEXT: v_cndmask_b32_e32 v3, v5, v3, vcc
4907 ; GFX8-NEXT: v_readfirstlane_b32 s0, v0
4908 ; GFX8-NEXT: v_readfirstlane_b32 s1, v1
4909 ; GFX8-NEXT: v_readfirstlane_b32 s2, v2
4910 ; GFX8-NEXT: v_readfirstlane_b32 s3, v3
4911 ; GFX8-NEXT: ; return to shader part epilog
4913 ; GFX9-LABEL: s_saddsat_i128:
4915 ; GFX9-NEXT: s_add_u32 s4, s0, s4
4916 ; GFX9-NEXT: s_cselect_b32 s8, 1, 0
4917 ; GFX9-NEXT: s_and_b32 s8, s8, 1
4918 ; GFX9-NEXT: s_cmp_lg_u32 s8, 0
4919 ; GFX9-NEXT: s_addc_u32 s5, s1, s5
4920 ; GFX9-NEXT: s_cselect_b32 s8, 1, 0
4921 ; GFX9-NEXT: s_and_b32 s8, s8, 1
4922 ; GFX9-NEXT: s_cmp_lg_u32 s8, 0
4923 ; GFX9-NEXT: s_addc_u32 s8, s2, s6
4924 ; GFX9-NEXT: s_cselect_b32 s9, 1, 0
4925 ; GFX9-NEXT: s_and_b32 s9, s9, 1
4926 ; GFX9-NEXT: v_mov_b32_e32 v3, s1
4927 ; GFX9-NEXT: s_cmp_lg_u32 s9, 0
4928 ; GFX9-NEXT: v_mov_b32_e32 v2, s0
4929 ; GFX9-NEXT: s_addc_u32 s9, s3, s7
4930 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
4931 ; GFX9-NEXT: v_cmp_lt_u64_e32 vcc, s[4:5], v[2:3]
4932 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
4933 ; GFX9-NEXT: s_cmp_eq_u64 s[8:9], s[2:3]
4934 ; GFX9-NEXT: s_cselect_b32 s2, 1, 0
4935 ; GFX9-NEXT: v_cndmask_b32_e64 v2, 0, 1, vcc
4936 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, s[8:9], v[0:1]
4937 ; GFX9-NEXT: s_and_b32 s0, 1, s2
4938 ; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
4939 ; GFX9-NEXT: v_cmp_ne_u32_e64 vcc, 0, s0
4940 ; GFX9-NEXT: s_cmp_eq_u64 s[6:7], 0
4941 ; GFX9-NEXT: v_cmp_lt_i64_e64 s[0:1], s[6:7], 0
4942 ; GFX9-NEXT: s_cselect_b32 s2, 1, 0
4943 ; GFX9-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[0:1]
4944 ; GFX9-NEXT: s_and_b32 s0, 1, s2
4945 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, s0
4946 ; GFX9-NEXT: s_ashr_i32 s3, s9, 31
4947 ; GFX9-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[0:1]
4948 ; GFX9-NEXT: s_add_u32 s0, s3, 0
4949 ; GFX9-NEXT: s_cselect_b32 s1, 1, 0
4950 ; GFX9-NEXT: s_and_b32 s1, s1, 1
4951 ; GFX9-NEXT: s_cmp_lg_u32 s1, 0
4952 ; GFX9-NEXT: s_addc_u32 s1, s3, 0
4953 ; GFX9-NEXT: s_cselect_b32 s2, 1, 0
4954 ; GFX9-NEXT: s_and_b32 s2, s2, 1
4955 ; GFX9-NEXT: s_cmp_lg_u32 s2, 0
4956 ; GFX9-NEXT: s_addc_u32 s2, s3, 0
4957 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
4958 ; GFX9-NEXT: s_cselect_b32 s6, 1, 0
4959 ; GFX9-NEXT: v_xor_b32_e32 v0, v1, v0
4960 ; GFX9-NEXT: s_and_b32 s6, s6, 1
4961 ; GFX9-NEXT: s_cmp_lg_u32 s6, 0
4962 ; GFX9-NEXT: v_and_b32_e32 v0, 1, v0
4963 ; GFX9-NEXT: s_addc_u32 s3, s3, 0x80000000
4964 ; GFX9-NEXT: v_mov_b32_e32 v1, s0
4965 ; GFX9-NEXT: v_mov_b32_e32 v2, s1
4966 ; GFX9-NEXT: v_mov_b32_e32 v3, s4
4967 ; GFX9-NEXT: v_mov_b32_e32 v4, s5
4968 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
4969 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v3, v1, vcc
4970 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v4, v2, vcc
4971 ; GFX9-NEXT: v_mov_b32_e32 v2, s2
4972 ; GFX9-NEXT: v_mov_b32_e32 v3, s3
4973 ; GFX9-NEXT: v_mov_b32_e32 v4, s8
4974 ; GFX9-NEXT: v_mov_b32_e32 v5, s9
4975 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v4, v2, vcc
4976 ; GFX9-NEXT: v_cndmask_b32_e32 v3, v5, v3, vcc
4977 ; GFX9-NEXT: v_readfirstlane_b32 s0, v0
4978 ; GFX9-NEXT: v_readfirstlane_b32 s1, v1
4979 ; GFX9-NEXT: v_readfirstlane_b32 s2, v2
4980 ; GFX9-NEXT: v_readfirstlane_b32 s3, v3
4981 ; GFX9-NEXT: ; return to shader part epilog
4983 ; GFX10-LABEL: s_saddsat_i128:
4985 ; GFX10-NEXT: s_add_u32 s4, s0, s4
4986 ; GFX10-NEXT: s_cselect_b32 s8, 1, 0
4987 ; GFX10-NEXT: s_and_b32 s8, s8, 1
4988 ; GFX10-NEXT: s_cmp_lg_u32 s8, 0
4989 ; GFX10-NEXT: s_addc_u32 s5, s1, s5
4990 ; GFX10-NEXT: s_cselect_b32 s8, 1, 0
4991 ; GFX10-NEXT: v_cmp_lt_u64_e64 s0, s[4:5], s[0:1]
4992 ; GFX10-NEXT: s_and_b32 s8, s8, 1
4993 ; GFX10-NEXT: v_mov_b32_e32 v2, s5
4994 ; GFX10-NEXT: s_cmp_lg_u32 s8, 0
4995 ; GFX10-NEXT: s_addc_u32 s8, s2, s6
4996 ; GFX10-NEXT: s_cselect_b32 s9, 1, 0
4997 ; GFX10-NEXT: v_cndmask_b32_e64 v0, 0, 1, s0
4998 ; GFX10-NEXT: s_and_b32 s9, s9, 1
4999 ; GFX10-NEXT: v_mov_b32_e32 v3, s8
5000 ; GFX10-NEXT: s_cmp_lg_u32 s9, 0
5001 ; GFX10-NEXT: s_addc_u32 s9, s3, s7
5002 ; GFX10-NEXT: s_cmp_eq_u64 s[8:9], s[2:3]
5003 ; GFX10-NEXT: v_cmp_lt_i64_e64 s1, s[8:9], s[2:3]
5004 ; GFX10-NEXT: s_cselect_b32 s0, 1, 0
5005 ; GFX10-NEXT: v_mov_b32_e32 v4, s9
5006 ; GFX10-NEXT: s_and_b32 s0, 1, s0
5007 ; GFX10-NEXT: s_cmp_eq_u64 s[6:7], 0
5008 ; GFX10-NEXT: v_cmp_ne_u32_e64 vcc_lo, 0, s0
5009 ; GFX10-NEXT: v_cmp_lt_i64_e64 s0, s[6:7], 0
5010 ; GFX10-NEXT: v_cndmask_b32_e64 v1, 0, 1, s1
5011 ; GFX10-NEXT: s_cselect_b32 s1, 1, 0
5012 ; GFX10-NEXT: s_ashr_i32 s3, s9, 31
5013 ; GFX10-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc_lo
5014 ; GFX10-NEXT: v_cndmask_b32_e64 v1, 0, 1, s0
5015 ; GFX10-NEXT: s_and_b32 s0, 1, s1
5016 ; GFX10-NEXT: v_cmp_ne_u32_e64 s0, 0, s0
5017 ; GFX10-NEXT: v_cndmask_b32_e64 v1, v1, 0, s0
5018 ; GFX10-NEXT: s_add_u32 s0, s3, 0
5019 ; GFX10-NEXT: s_cselect_b32 s1, 1, 0
5020 ; GFX10-NEXT: s_and_b32 s1, s1, 1
5021 ; GFX10-NEXT: v_xor_b32_e32 v0, v1, v0
5022 ; GFX10-NEXT: s_cmp_lg_u32 s1, 0
5023 ; GFX10-NEXT: v_mov_b32_e32 v1, s4
5024 ; GFX10-NEXT: s_addc_u32 s1, s3, 0
5025 ; GFX10-NEXT: s_cselect_b32 s2, 1, 0
5026 ; GFX10-NEXT: v_and_b32_e32 v0, 1, v0
5027 ; GFX10-NEXT: s_and_b32 s2, s2, 1
5028 ; GFX10-NEXT: s_cmp_lg_u32 s2, 0
5029 ; GFX10-NEXT: s_addc_u32 s2, s3, 0
5030 ; GFX10-NEXT: s_cselect_b32 s4, 1, 0
5031 ; GFX10-NEXT: v_cmp_ne_u32_e32 vcc_lo, 0, v0
5032 ; GFX10-NEXT: s_and_b32 s4, s4, 1
5033 ; GFX10-NEXT: s_cmp_lg_u32 s4, 0
5034 ; GFX10-NEXT: s_addc_u32 s3, s3, 0x80000000
5035 ; GFX10-NEXT: v_cndmask_b32_e64 v0, v1, s0, vcc_lo
5036 ; GFX10-NEXT: v_cndmask_b32_e64 v1, v2, s1, vcc_lo
5037 ; GFX10-NEXT: v_cndmask_b32_e64 v2, v3, s2, vcc_lo
5038 ; GFX10-NEXT: v_cndmask_b32_e64 v3, v4, s3, vcc_lo
5039 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
5040 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
5041 ; GFX10-NEXT: v_readfirstlane_b32 s2, v2
5042 ; GFX10-NEXT: v_readfirstlane_b32 s3, v3
5043 ; GFX10-NEXT: ; return to shader part epilog
5044 %result = call i128 @llvm.sadd.sat.i128(i128 %lhs, i128 %rhs)
5048 define amdgpu_ps <4 x float> @saddsat_i128_sv(i128 inreg %lhs, i128 %rhs) {
5049 ; GFX6-LABEL: saddsat_i128_sv:
5051 ; GFX6-NEXT: v_mov_b32_e32 v4, s1
5052 ; GFX6-NEXT: v_add_i32_e32 v0, vcc, s0, v0
5053 ; GFX6-NEXT: v_addc_u32_e32 v1, vcc, v4, v1, vcc
5054 ; GFX6-NEXT: v_mov_b32_e32 v4, s2
5055 ; GFX6-NEXT: v_mov_b32_e32 v5, s3
5056 ; GFX6-NEXT: v_addc_u32_e32 v4, vcc, v4, v2, vcc
5057 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, v5, v3, vcc
5058 ; GFX6-NEXT: v_cmp_gt_u64_e32 vcc, s[0:1], v[0:1]
5059 ; GFX6-NEXT: v_bfrev_b32_e32 v8, 1
5060 ; GFX6-NEXT: v_cndmask_b32_e64 v6, 0, 1, vcc
5061 ; GFX6-NEXT: v_cmp_gt_i64_e32 vcc, s[2:3], v[4:5]
5062 ; GFX6-NEXT: v_cndmask_b32_e64 v7, 0, 1, vcc
5063 ; GFX6-NEXT: v_cmp_eq_u64_e32 vcc, s[2:3], v[4:5]
5064 ; GFX6-NEXT: v_cndmask_b32_e32 v6, v7, v6, vcc
5065 ; GFX6-NEXT: v_cmp_gt_i64_e32 vcc, 0, v[2:3]
5066 ; GFX6-NEXT: v_cndmask_b32_e64 v7, 0, 1, vcc
5067 ; GFX6-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[2:3]
5068 ; GFX6-NEXT: v_ashrrev_i32_e32 v3, 31, v5
5069 ; GFX6-NEXT: v_cndmask_b32_e64 v2, v7, 0, vcc
5070 ; GFX6-NEXT: v_xor_b32_e32 v2, v2, v6
5071 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, 0, v3
5072 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, 0, v3, vcc
5073 ; GFX6-NEXT: v_addc_u32_e32 v9, vcc, 0, v3, vcc
5074 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, v3, v8, vcc
5075 ; GFX6-NEXT: v_and_b32_e32 v2, 1, v2
5076 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v2
5077 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v0, v6, vcc
5078 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v1, v7, vcc
5079 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v4, v9, vcc
5080 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v5, v3, vcc
5081 ; GFX6-NEXT: ; return to shader part epilog
5083 ; GFX8-LABEL: saddsat_i128_sv:
5085 ; GFX8-NEXT: v_mov_b32_e32 v4, s1
5086 ; GFX8-NEXT: v_add_u32_e32 v0, vcc, s0, v0
5087 ; GFX8-NEXT: v_addc_u32_e32 v1, vcc, v4, v1, vcc
5088 ; GFX8-NEXT: v_mov_b32_e32 v4, s2
5089 ; GFX8-NEXT: v_mov_b32_e32 v5, s3
5090 ; GFX8-NEXT: v_addc_u32_e32 v4, vcc, v4, v2, vcc
5091 ; GFX8-NEXT: v_addc_u32_e32 v5, vcc, v5, v3, vcc
5092 ; GFX8-NEXT: v_cmp_gt_u64_e32 vcc, s[0:1], v[0:1]
5093 ; GFX8-NEXT: v_bfrev_b32_e32 v8, 1
5094 ; GFX8-NEXT: v_cndmask_b32_e64 v6, 0, 1, vcc
5095 ; GFX8-NEXT: v_cmp_gt_i64_e32 vcc, s[2:3], v[4:5]
5096 ; GFX8-NEXT: v_cndmask_b32_e64 v7, 0, 1, vcc
5097 ; GFX8-NEXT: v_cmp_eq_u64_e32 vcc, s[2:3], v[4:5]
5098 ; GFX8-NEXT: v_cndmask_b32_e32 v6, v7, v6, vcc
5099 ; GFX8-NEXT: v_cmp_gt_i64_e32 vcc, 0, v[2:3]
5100 ; GFX8-NEXT: v_cndmask_b32_e64 v7, 0, 1, vcc
5101 ; GFX8-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[2:3]
5102 ; GFX8-NEXT: v_ashrrev_i32_e32 v3, 31, v5
5103 ; GFX8-NEXT: v_cndmask_b32_e64 v2, v7, 0, vcc
5104 ; GFX8-NEXT: v_xor_b32_e32 v2, v2, v6
5105 ; GFX8-NEXT: v_add_u32_e32 v6, vcc, 0, v3
5106 ; GFX8-NEXT: v_addc_u32_e32 v7, vcc, 0, v3, vcc
5107 ; GFX8-NEXT: v_addc_u32_e32 v9, vcc, 0, v3, vcc
5108 ; GFX8-NEXT: v_addc_u32_e32 v3, vcc, v3, v8, vcc
5109 ; GFX8-NEXT: v_and_b32_e32 v2, 1, v2
5110 ; GFX8-NEXT: v_cmp_ne_u32_e32 vcc, 0, v2
5111 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v0, v6, vcc
5112 ; GFX8-NEXT: v_cndmask_b32_e32 v1, v1, v7, vcc
5113 ; GFX8-NEXT: v_cndmask_b32_e32 v2, v4, v9, vcc
5114 ; GFX8-NEXT: v_cndmask_b32_e32 v3, v5, v3, vcc
5115 ; GFX8-NEXT: ; return to shader part epilog
5117 ; GFX9-LABEL: saddsat_i128_sv:
5119 ; GFX9-NEXT: v_mov_b32_e32 v4, s1
5120 ; GFX9-NEXT: v_add_co_u32_e32 v0, vcc, s0, v0
5121 ; GFX9-NEXT: v_addc_co_u32_e32 v1, vcc, v4, v1, vcc
5122 ; GFX9-NEXT: v_mov_b32_e32 v4, s2
5123 ; GFX9-NEXT: v_mov_b32_e32 v5, s3
5124 ; GFX9-NEXT: v_addc_co_u32_e32 v4, vcc, v4, v2, vcc
5125 ; GFX9-NEXT: v_addc_co_u32_e32 v5, vcc, v5, v3, vcc
5126 ; GFX9-NEXT: v_cmp_gt_u64_e32 vcc, s[0:1], v[0:1]
5127 ; GFX9-NEXT: v_bfrev_b32_e32 v8, 1
5128 ; GFX9-NEXT: v_cndmask_b32_e64 v6, 0, 1, vcc
5129 ; GFX9-NEXT: v_cmp_gt_i64_e32 vcc, s[2:3], v[4:5]
5130 ; GFX9-NEXT: v_cndmask_b32_e64 v7, 0, 1, vcc
5131 ; GFX9-NEXT: v_cmp_eq_u64_e32 vcc, s[2:3], v[4:5]
5132 ; GFX9-NEXT: v_cndmask_b32_e32 v6, v7, v6, vcc
5133 ; GFX9-NEXT: v_cmp_gt_i64_e32 vcc, 0, v[2:3]
5134 ; GFX9-NEXT: v_cndmask_b32_e64 v7, 0, 1, vcc
5135 ; GFX9-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[2:3]
5136 ; GFX9-NEXT: v_ashrrev_i32_e32 v3, 31, v5
5137 ; GFX9-NEXT: v_cndmask_b32_e64 v2, v7, 0, vcc
5138 ; GFX9-NEXT: v_xor_b32_e32 v2, v2, v6
5139 ; GFX9-NEXT: v_add_co_u32_e32 v6, vcc, 0, v3
5140 ; GFX9-NEXT: v_addc_co_u32_e32 v7, vcc, 0, v3, vcc
5141 ; GFX9-NEXT: v_addc_co_u32_e32 v9, vcc, 0, v3, vcc
5142 ; GFX9-NEXT: v_addc_co_u32_e32 v3, vcc, v3, v8, vcc
5143 ; GFX9-NEXT: v_and_b32_e32 v2, 1, v2
5144 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v2
5145 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v6, vcc
5146 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v1, v7, vcc
5147 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v4, v9, vcc
5148 ; GFX9-NEXT: v_cndmask_b32_e32 v3, v5, v3, vcc
5149 ; GFX9-NEXT: ; return to shader part epilog
5151 ; GFX10-LABEL: saddsat_i128_sv:
5153 ; GFX10-NEXT: v_add_co_u32 v0, vcc_lo, s0, v0
5154 ; GFX10-NEXT: v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
5155 ; GFX10-NEXT: v_add_co_ci_u32_e32 v4, vcc_lo, s2, v2, vcc_lo
5156 ; GFX10-NEXT: v_add_co_ci_u32_e32 v5, vcc_lo, s3, v3, vcc_lo
5157 ; GFX10-NEXT: v_cmp_gt_u64_e32 vcc_lo, s[0:1], v[0:1]
5158 ; GFX10-NEXT: v_cndmask_b32_e64 v6, 0, 1, vcc_lo
5159 ; GFX10-NEXT: v_cmp_gt_i64_e32 vcc_lo, s[2:3], v[4:5]
5160 ; GFX10-NEXT: v_cndmask_b32_e64 v7, 0, 1, vcc_lo
5161 ; GFX10-NEXT: v_cmp_gt_i64_e32 vcc_lo, 0, v[2:3]
5162 ; GFX10-NEXT: v_cndmask_b32_e64 v8, 0, 1, vcc_lo
5163 ; GFX10-NEXT: v_cmp_eq_u64_e32 vcc_lo, s[2:3], v[4:5]
5164 ; GFX10-NEXT: v_cndmask_b32_e32 v6, v7, v6, vcc_lo
5165 ; GFX10-NEXT: v_cmp_eq_u64_e32 vcc_lo, 0, v[2:3]
5166 ; GFX10-NEXT: v_ashrrev_i32_e32 v3, 31, v5
5167 ; GFX10-NEXT: v_cndmask_b32_e64 v2, v8, 0, vcc_lo
5168 ; GFX10-NEXT: v_xor_b32_e32 v2, v2, v6
5169 ; GFX10-NEXT: v_add_co_u32 v6, vcc_lo, v3, 0
5170 ; GFX10-NEXT: v_add_co_ci_u32_e32 v7, vcc_lo, 0, v3, vcc_lo
5171 ; GFX10-NEXT: v_and_b32_e32 v2, 1, v2
5172 ; GFX10-NEXT: v_cmp_ne_u32_e64 s0, 0, v2
5173 ; GFX10-NEXT: v_add_co_ci_u32_e32 v2, vcc_lo, 0, v3, vcc_lo
5174 ; GFX10-NEXT: v_add_co_ci_u32_e32 v3, vcc_lo, 0x80000000, v3, vcc_lo
5175 ; GFX10-NEXT: v_cndmask_b32_e64 v0, v0, v6, s0
5176 ; GFX10-NEXT: v_cndmask_b32_e64 v1, v1, v7, s0
5177 ; GFX10-NEXT: v_cndmask_b32_e64 v2, v4, v2, s0
5178 ; GFX10-NEXT: v_cndmask_b32_e64 v3, v5, v3, s0
5179 ; GFX10-NEXT: ; return to shader part epilog
5180 %result = call i128 @llvm.sadd.sat.i128(i128 %lhs, i128 %rhs)
5181 %cast = bitcast i128 %result to <4 x float>
5182 ret <4 x float> %cast
5185 define amdgpu_ps <4 x float> @saddsat_i128_vs(i128 %lhs, i128 inreg %rhs) {
5186 ; GFX6-LABEL: saddsat_i128_vs:
5188 ; GFX6-NEXT: v_mov_b32_e32 v5, s1
5189 ; GFX6-NEXT: v_add_i32_e32 v4, vcc, s0, v0
5190 ; GFX6-NEXT: v_addc_u32_e32 v5, vcc, v1, v5, vcc
5191 ; GFX6-NEXT: v_mov_b32_e32 v6, s2
5192 ; GFX6-NEXT: v_mov_b32_e32 v7, s3
5193 ; GFX6-NEXT: v_addc_u32_e32 v6, vcc, v2, v6, vcc
5194 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, v3, v7, vcc
5195 ; GFX6-NEXT: v_cmp_lt_u64_e32 vcc, v[4:5], v[0:1]
5196 ; GFX6-NEXT: v_cmp_lt_i64_e64 s[0:1], s[2:3], 0
5197 ; GFX6-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
5198 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, v[6:7], v[2:3]
5199 ; GFX6-NEXT: v_bfrev_b32_e32 v8, 1
5200 ; GFX6-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc
5201 ; GFX6-NEXT: v_cmp_eq_u64_e32 vcc, v[6:7], v[2:3]
5202 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
5203 ; GFX6-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[0:1]
5204 ; GFX6-NEXT: v_cmp_eq_u64_e64 s[0:1], s[2:3], 0
5205 ; GFX6-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[0:1]
5206 ; GFX6-NEXT: v_xor_b32_e32 v0, v1, v0
5207 ; GFX6-NEXT: v_ashrrev_i32_e32 v1, 31, v7
5208 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 0, v1
5209 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
5210 ; GFX6-NEXT: v_addc_u32_e32 v9, vcc, 0, v1, vcc
5211 ; GFX6-NEXT: v_addc_u32_e32 v8, vcc, v1, v8, vcc
5212 ; GFX6-NEXT: v_and_b32_e32 v0, 1, v0
5213 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5214 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v4, v2, vcc
5215 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v5, v3, vcc
5216 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v6, v9, vcc
5217 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v7, v8, vcc
5218 ; GFX6-NEXT: ; return to shader part epilog
5220 ; GFX8-LABEL: saddsat_i128_vs:
5222 ; GFX8-NEXT: v_mov_b32_e32 v5, s1
5223 ; GFX8-NEXT: v_add_u32_e32 v4, vcc, s0, v0
5224 ; GFX8-NEXT: v_addc_u32_e32 v5, vcc, v1, v5, vcc
5225 ; GFX8-NEXT: v_mov_b32_e32 v6, s2
5226 ; GFX8-NEXT: v_mov_b32_e32 v7, s3
5227 ; GFX8-NEXT: v_addc_u32_e32 v6, vcc, v2, v6, vcc
5228 ; GFX8-NEXT: v_addc_u32_e32 v7, vcc, v3, v7, vcc
5229 ; GFX8-NEXT: v_cmp_lt_u64_e32 vcc, v[4:5], v[0:1]
5230 ; GFX8-NEXT: s_cmp_eq_u64 s[2:3], 0
5231 ; GFX8-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
5232 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, v[6:7], v[2:3]
5233 ; GFX8-NEXT: v_cmp_lt_i64_e64 s[0:1], s[2:3], 0
5234 ; GFX8-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc
5235 ; GFX8-NEXT: v_cmp_eq_u64_e32 vcc, v[6:7], v[2:3]
5236 ; GFX8-NEXT: s_cselect_b32 s4, 1, 0
5237 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
5238 ; GFX8-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[0:1]
5239 ; GFX8-NEXT: s_and_b32 s0, 1, s4
5240 ; GFX8-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, s0
5241 ; GFX8-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[0:1]
5242 ; GFX8-NEXT: v_xor_b32_e32 v0, v1, v0
5243 ; GFX8-NEXT: v_ashrrev_i32_e32 v1, 31, v7
5244 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, 0, v1
5245 ; GFX8-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
5246 ; GFX8-NEXT: v_bfrev_b32_e32 v8, 1
5247 ; GFX8-NEXT: v_addc_u32_e32 v9, vcc, 0, v1, vcc
5248 ; GFX8-NEXT: v_addc_u32_e32 v8, vcc, v1, v8, vcc
5249 ; GFX8-NEXT: v_and_b32_e32 v0, 1, v0
5250 ; GFX8-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5251 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v4, v2, vcc
5252 ; GFX8-NEXT: v_cndmask_b32_e32 v1, v5, v3, vcc
5253 ; GFX8-NEXT: v_cndmask_b32_e32 v2, v6, v9, vcc
5254 ; GFX8-NEXT: v_cndmask_b32_e32 v3, v7, v8, vcc
5255 ; GFX8-NEXT: ; return to shader part epilog
5257 ; GFX9-LABEL: saddsat_i128_vs:
5259 ; GFX9-NEXT: v_mov_b32_e32 v5, s1
5260 ; GFX9-NEXT: v_add_co_u32_e32 v4, vcc, s0, v0
5261 ; GFX9-NEXT: v_addc_co_u32_e32 v5, vcc, v1, v5, vcc
5262 ; GFX9-NEXT: v_mov_b32_e32 v6, s2
5263 ; GFX9-NEXT: v_mov_b32_e32 v7, s3
5264 ; GFX9-NEXT: v_addc_co_u32_e32 v6, vcc, v2, v6, vcc
5265 ; GFX9-NEXT: v_addc_co_u32_e32 v7, vcc, v3, v7, vcc
5266 ; GFX9-NEXT: v_cmp_lt_u64_e32 vcc, v[4:5], v[0:1]
5267 ; GFX9-NEXT: s_cmp_eq_u64 s[2:3], 0
5268 ; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
5269 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, v[6:7], v[2:3]
5270 ; GFX9-NEXT: v_cmp_lt_i64_e64 s[0:1], s[2:3], 0
5271 ; GFX9-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc
5272 ; GFX9-NEXT: v_cmp_eq_u64_e32 vcc, v[6:7], v[2:3]
5273 ; GFX9-NEXT: s_cselect_b32 s4, 1, 0
5274 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
5275 ; GFX9-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[0:1]
5276 ; GFX9-NEXT: s_and_b32 s0, 1, s4
5277 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, s0
5278 ; GFX9-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[0:1]
5279 ; GFX9-NEXT: v_xor_b32_e32 v0, v1, v0
5280 ; GFX9-NEXT: v_ashrrev_i32_e32 v1, 31, v7
5281 ; GFX9-NEXT: v_add_co_u32_e32 v2, vcc, 0, v1
5282 ; GFX9-NEXT: v_addc_co_u32_e32 v3, vcc, 0, v1, vcc
5283 ; GFX9-NEXT: v_bfrev_b32_e32 v8, 1
5284 ; GFX9-NEXT: v_addc_co_u32_e32 v9, vcc, 0, v1, vcc
5285 ; GFX9-NEXT: v_addc_co_u32_e32 v8, vcc, v1, v8, vcc
5286 ; GFX9-NEXT: v_and_b32_e32 v0, 1, v0
5287 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5288 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v4, v2, vcc
5289 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v5, v3, vcc
5290 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v6, v9, vcc
5291 ; GFX9-NEXT: v_cndmask_b32_e32 v3, v7, v8, vcc
5292 ; GFX9-NEXT: ; return to shader part epilog
5294 ; GFX10-LABEL: saddsat_i128_vs:
5296 ; GFX10-NEXT: v_add_co_u32 v4, vcc_lo, v0, s0
5297 ; GFX10-NEXT: v_add_co_ci_u32_e32 v5, vcc_lo, s1, v1, vcc_lo
5298 ; GFX10-NEXT: v_add_co_ci_u32_e32 v6, vcc_lo, s2, v2, vcc_lo
5299 ; GFX10-NEXT: v_add_co_ci_u32_e32 v7, vcc_lo, s3, v3, vcc_lo
5300 ; GFX10-NEXT: v_cmp_lt_u64_e32 vcc_lo, v[4:5], v[0:1]
5301 ; GFX10-NEXT: s_cmp_eq_u64 s[2:3], 0
5302 ; GFX10-NEXT: v_cmp_lt_i64_e64 s1, s[2:3], 0
5303 ; GFX10-NEXT: s_cselect_b32 s0, 1, 0
5304 ; GFX10-NEXT: s_and_b32 s0, 1, s0
5305 ; GFX10-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc_lo
5306 ; GFX10-NEXT: v_cmp_lt_i64_e32 vcc_lo, v[6:7], v[2:3]
5307 ; GFX10-NEXT: v_cndmask_b32_e64 v8, 0, 1, s1
5308 ; GFX10-NEXT: v_cmp_ne_u32_e64 s0, 0, s0
5309 ; GFX10-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc_lo
5310 ; GFX10-NEXT: v_cmp_eq_u64_e32 vcc_lo, v[6:7], v[2:3]
5311 ; GFX10-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc_lo
5312 ; GFX10-NEXT: v_cndmask_b32_e64 v1, v8, 0, s0
5313 ; GFX10-NEXT: v_xor_b32_e32 v0, v1, v0
5314 ; GFX10-NEXT: v_ashrrev_i32_e32 v1, 31, v7
5315 ; GFX10-NEXT: v_and_b32_e32 v0, 1, v0
5316 ; GFX10-NEXT: v_add_co_u32 v2, vcc_lo, v1, 0
5317 ; GFX10-NEXT: v_add_co_ci_u32_e32 v3, vcc_lo, 0, v1, vcc_lo
5318 ; GFX10-NEXT: v_add_co_ci_u32_e32 v8, vcc_lo, 0, v1, vcc_lo
5319 ; GFX10-NEXT: v_cmp_ne_u32_e64 s0, 0, v0
5320 ; GFX10-NEXT: v_add_co_ci_u32_e32 v9, vcc_lo, 0x80000000, v1, vcc_lo
5321 ; GFX10-NEXT: v_cndmask_b32_e64 v0, v4, v2, s0
5322 ; GFX10-NEXT: v_cndmask_b32_e64 v1, v5, v3, s0
5323 ; GFX10-NEXT: v_cndmask_b32_e64 v2, v6, v8, s0
5324 ; GFX10-NEXT: v_cndmask_b32_e64 v3, v7, v9, s0
5325 ; GFX10-NEXT: ; return to shader part epilog
5326 %result = call i128 @llvm.sadd.sat.i128(i128 %lhs, i128 %rhs)
5327 %cast = bitcast i128 %result to <4 x float>
5328 ret <4 x float> %cast
5331 define <2 x i128> @v_saddsat_v2i128(<2 x i128> %lhs, <2 x i128> %rhs) {
5332 ; GFX6-LABEL: v_saddsat_v2i128:
5334 ; GFX6-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
5335 ; GFX6-NEXT: v_add_i32_e32 v8, vcc, v0, v8
5336 ; GFX6-NEXT: v_addc_u32_e32 v9, vcc, v1, v9, vcc
5337 ; GFX6-NEXT: v_addc_u32_e32 v16, vcc, v2, v10, vcc
5338 ; GFX6-NEXT: v_addc_u32_e32 v17, vcc, v3, v11, vcc
5339 ; GFX6-NEXT: v_cmp_lt_u64_e32 vcc, v[8:9], v[0:1]
5340 ; GFX6-NEXT: v_bfrev_b32_e32 v18, 1
5341 ; GFX6-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
5342 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, v[16:17], v[2:3]
5343 ; GFX6-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc
5344 ; GFX6-NEXT: v_cmp_eq_u64_e32 vcc, v[16:17], v[2:3]
5345 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
5346 ; GFX6-NEXT: v_cmp_gt_i64_e32 vcc, 0, v[10:11]
5347 ; GFX6-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc
5348 ; GFX6-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[10:11]
5349 ; GFX6-NEXT: v_cndmask_b32_e64 v1, v1, 0, vcc
5350 ; GFX6-NEXT: v_xor_b32_e32 v0, v1, v0
5351 ; GFX6-NEXT: v_ashrrev_i32_e32 v1, 31, v17
5352 ; GFX6-NEXT: v_add_i32_e32 v2, vcc, 0, v1
5353 ; GFX6-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
5354 ; GFX6-NEXT: v_addc_u32_e32 v10, vcc, 0, v1, vcc
5355 ; GFX6-NEXT: v_addc_u32_e32 v11, vcc, v1, v18, vcc
5356 ; GFX6-NEXT: v_and_b32_e32 v0, 1, v0
5357 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5358 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v8, v2, vcc
5359 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v9, v3, vcc
5360 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v16, v10, vcc
5361 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v17, v11, vcc
5362 ; GFX6-NEXT: v_add_i32_e32 v8, vcc, v4, v12
5363 ; GFX6-NEXT: v_addc_u32_e32 v9, vcc, v5, v13, vcc
5364 ; GFX6-NEXT: v_addc_u32_e32 v10, vcc, v6, v14, vcc
5365 ; GFX6-NEXT: v_addc_u32_e32 v11, vcc, v7, v15, vcc
5366 ; GFX6-NEXT: v_cmp_lt_u64_e32 vcc, v[8:9], v[4:5]
5367 ; GFX6-NEXT: v_cndmask_b32_e64 v4, 0, 1, vcc
5368 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, v[10:11], v[6:7]
5369 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, 1, vcc
5370 ; GFX6-NEXT: v_cmp_eq_u64_e32 vcc, v[10:11], v[6:7]
5371 ; GFX6-NEXT: v_cndmask_b32_e32 v4, v5, v4, vcc
5372 ; GFX6-NEXT: v_cmp_gt_i64_e32 vcc, 0, v[14:15]
5373 ; GFX6-NEXT: v_cndmask_b32_e64 v5, 0, 1, vcc
5374 ; GFX6-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[14:15]
5375 ; GFX6-NEXT: v_cndmask_b32_e64 v5, v5, 0, vcc
5376 ; GFX6-NEXT: v_xor_b32_e32 v4, v5, v4
5377 ; GFX6-NEXT: v_ashrrev_i32_e32 v5, 31, v11
5378 ; GFX6-NEXT: v_add_i32_e32 v6, vcc, 0, v5
5379 ; GFX6-NEXT: v_addc_u32_e32 v7, vcc, 0, v5, vcc
5380 ; GFX6-NEXT: v_addc_u32_e32 v12, vcc, 0, v5, vcc
5381 ; GFX6-NEXT: v_addc_u32_e32 v13, vcc, v5, v18, vcc
5382 ; GFX6-NEXT: v_and_b32_e32 v4, 1, v4
5383 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
5384 ; GFX6-NEXT: v_cndmask_b32_e32 v4, v8, v6, vcc
5385 ; GFX6-NEXT: v_cndmask_b32_e32 v5, v9, v7, vcc
5386 ; GFX6-NEXT: v_cndmask_b32_e32 v6, v10, v12, vcc
5387 ; GFX6-NEXT: v_cndmask_b32_e32 v7, v11, v13, vcc
5388 ; GFX6-NEXT: s_setpc_b64 s[30:31]
5390 ; GFX8-LABEL: v_saddsat_v2i128:
5392 ; GFX8-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
5393 ; GFX8-NEXT: v_add_u32_e32 v8, vcc, v0, v8
5394 ; GFX8-NEXT: v_addc_u32_e32 v9, vcc, v1, v9, vcc
5395 ; GFX8-NEXT: v_addc_u32_e32 v16, vcc, v2, v10, vcc
5396 ; GFX8-NEXT: v_addc_u32_e32 v17, vcc, v3, v11, vcc
5397 ; GFX8-NEXT: v_cmp_lt_u64_e32 vcc, v[8:9], v[0:1]
5398 ; GFX8-NEXT: v_bfrev_b32_e32 v18, 1
5399 ; GFX8-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
5400 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, v[16:17], v[2:3]
5401 ; GFX8-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc
5402 ; GFX8-NEXT: v_cmp_eq_u64_e32 vcc, v[16:17], v[2:3]
5403 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
5404 ; GFX8-NEXT: v_cmp_gt_i64_e32 vcc, 0, v[10:11]
5405 ; GFX8-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc
5406 ; GFX8-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[10:11]
5407 ; GFX8-NEXT: v_cndmask_b32_e64 v1, v1, 0, vcc
5408 ; GFX8-NEXT: v_xor_b32_e32 v0, v1, v0
5409 ; GFX8-NEXT: v_ashrrev_i32_e32 v1, 31, v17
5410 ; GFX8-NEXT: v_add_u32_e32 v2, vcc, 0, v1
5411 ; GFX8-NEXT: v_addc_u32_e32 v3, vcc, 0, v1, vcc
5412 ; GFX8-NEXT: v_addc_u32_e32 v10, vcc, 0, v1, vcc
5413 ; GFX8-NEXT: v_addc_u32_e32 v11, vcc, v1, v18, vcc
5414 ; GFX8-NEXT: v_and_b32_e32 v0, 1, v0
5415 ; GFX8-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5416 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v8, v2, vcc
5417 ; GFX8-NEXT: v_cndmask_b32_e32 v1, v9, v3, vcc
5418 ; GFX8-NEXT: v_cndmask_b32_e32 v2, v16, v10, vcc
5419 ; GFX8-NEXT: v_cndmask_b32_e32 v3, v17, v11, vcc
5420 ; GFX8-NEXT: v_add_u32_e32 v8, vcc, v4, v12
5421 ; GFX8-NEXT: v_addc_u32_e32 v9, vcc, v5, v13, vcc
5422 ; GFX8-NEXT: v_addc_u32_e32 v10, vcc, v6, v14, vcc
5423 ; GFX8-NEXT: v_addc_u32_e32 v11, vcc, v7, v15, vcc
5424 ; GFX8-NEXT: v_cmp_lt_u64_e32 vcc, v[8:9], v[4:5]
5425 ; GFX8-NEXT: v_cndmask_b32_e64 v4, 0, 1, vcc
5426 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, v[10:11], v[6:7]
5427 ; GFX8-NEXT: v_cndmask_b32_e64 v5, 0, 1, vcc
5428 ; GFX8-NEXT: v_cmp_eq_u64_e32 vcc, v[10:11], v[6:7]
5429 ; GFX8-NEXT: v_cndmask_b32_e32 v4, v5, v4, vcc
5430 ; GFX8-NEXT: v_cmp_gt_i64_e32 vcc, 0, v[14:15]
5431 ; GFX8-NEXT: v_cndmask_b32_e64 v5, 0, 1, vcc
5432 ; GFX8-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[14:15]
5433 ; GFX8-NEXT: v_cndmask_b32_e64 v5, v5, 0, vcc
5434 ; GFX8-NEXT: v_xor_b32_e32 v4, v5, v4
5435 ; GFX8-NEXT: v_ashrrev_i32_e32 v5, 31, v11
5436 ; GFX8-NEXT: v_add_u32_e32 v6, vcc, 0, v5
5437 ; GFX8-NEXT: v_addc_u32_e32 v7, vcc, 0, v5, vcc
5438 ; GFX8-NEXT: v_addc_u32_e32 v12, vcc, 0, v5, vcc
5439 ; GFX8-NEXT: v_addc_u32_e32 v13, vcc, v5, v18, vcc
5440 ; GFX8-NEXT: v_and_b32_e32 v4, 1, v4
5441 ; GFX8-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
5442 ; GFX8-NEXT: v_cndmask_b32_e32 v4, v8, v6, vcc
5443 ; GFX8-NEXT: v_cndmask_b32_e32 v5, v9, v7, vcc
5444 ; GFX8-NEXT: v_cndmask_b32_e32 v6, v10, v12, vcc
5445 ; GFX8-NEXT: v_cndmask_b32_e32 v7, v11, v13, vcc
5446 ; GFX8-NEXT: s_setpc_b64 s[30:31]
5448 ; GFX9-LABEL: v_saddsat_v2i128:
5450 ; GFX9-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
5451 ; GFX9-NEXT: v_add_co_u32_e32 v8, vcc, v0, v8
5452 ; GFX9-NEXT: v_addc_co_u32_e32 v9, vcc, v1, v9, vcc
5453 ; GFX9-NEXT: v_addc_co_u32_e32 v16, vcc, v2, v10, vcc
5454 ; GFX9-NEXT: v_addc_co_u32_e32 v17, vcc, v3, v11, vcc
5455 ; GFX9-NEXT: v_cmp_lt_u64_e32 vcc, v[8:9], v[0:1]
5456 ; GFX9-NEXT: v_bfrev_b32_e32 v18, 1
5457 ; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
5458 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, v[16:17], v[2:3]
5459 ; GFX9-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc
5460 ; GFX9-NEXT: v_cmp_eq_u64_e32 vcc, v[16:17], v[2:3]
5461 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc
5462 ; GFX9-NEXT: v_cmp_gt_i64_e32 vcc, 0, v[10:11]
5463 ; GFX9-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc
5464 ; GFX9-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[10:11]
5465 ; GFX9-NEXT: v_cndmask_b32_e64 v1, v1, 0, vcc
5466 ; GFX9-NEXT: v_xor_b32_e32 v0, v1, v0
5467 ; GFX9-NEXT: v_ashrrev_i32_e32 v1, 31, v17
5468 ; GFX9-NEXT: v_add_co_u32_e32 v2, vcc, 0, v1
5469 ; GFX9-NEXT: v_addc_co_u32_e32 v3, vcc, 0, v1, vcc
5470 ; GFX9-NEXT: v_addc_co_u32_e32 v10, vcc, 0, v1, vcc
5471 ; GFX9-NEXT: v_addc_co_u32_e32 v11, vcc, v1, v18, vcc
5472 ; GFX9-NEXT: v_and_b32_e32 v0, 1, v0
5473 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5474 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v8, v2, vcc
5475 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v9, v3, vcc
5476 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v16, v10, vcc
5477 ; GFX9-NEXT: v_cndmask_b32_e32 v3, v17, v11, vcc
5478 ; GFX9-NEXT: v_add_co_u32_e32 v8, vcc, v4, v12
5479 ; GFX9-NEXT: v_addc_co_u32_e32 v9, vcc, v5, v13, vcc
5480 ; GFX9-NEXT: v_addc_co_u32_e32 v10, vcc, v6, v14, vcc
5481 ; GFX9-NEXT: v_addc_co_u32_e32 v11, vcc, v7, v15, vcc
5482 ; GFX9-NEXT: v_cmp_lt_u64_e32 vcc, v[8:9], v[4:5]
5483 ; GFX9-NEXT: v_cndmask_b32_e64 v4, 0, 1, vcc
5484 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, v[10:11], v[6:7]
5485 ; GFX9-NEXT: v_cndmask_b32_e64 v5, 0, 1, vcc
5486 ; GFX9-NEXT: v_cmp_eq_u64_e32 vcc, v[10:11], v[6:7]
5487 ; GFX9-NEXT: v_cndmask_b32_e32 v4, v5, v4, vcc
5488 ; GFX9-NEXT: v_cmp_gt_i64_e32 vcc, 0, v[14:15]
5489 ; GFX9-NEXT: v_cndmask_b32_e64 v5, 0, 1, vcc
5490 ; GFX9-NEXT: v_cmp_eq_u64_e32 vcc, 0, v[14:15]
5491 ; GFX9-NEXT: v_cndmask_b32_e64 v5, v5, 0, vcc
5492 ; GFX9-NEXT: v_xor_b32_e32 v4, v5, v4
5493 ; GFX9-NEXT: v_ashrrev_i32_e32 v5, 31, v11
5494 ; GFX9-NEXT: v_add_co_u32_e32 v6, vcc, 0, v5
5495 ; GFX9-NEXT: v_addc_co_u32_e32 v7, vcc, 0, v5, vcc
5496 ; GFX9-NEXT: v_addc_co_u32_e32 v12, vcc, 0, v5, vcc
5497 ; GFX9-NEXT: v_addc_co_u32_e32 v13, vcc, v5, v18, vcc
5498 ; GFX9-NEXT: v_and_b32_e32 v4, 1, v4
5499 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v4
5500 ; GFX9-NEXT: v_cndmask_b32_e32 v4, v8, v6, vcc
5501 ; GFX9-NEXT: v_cndmask_b32_e32 v5, v9, v7, vcc
5502 ; GFX9-NEXT: v_cndmask_b32_e32 v6, v10, v12, vcc
5503 ; GFX9-NEXT: v_cndmask_b32_e32 v7, v11, v13, vcc
5504 ; GFX9-NEXT: s_setpc_b64 s[30:31]
5506 ; GFX10-LABEL: v_saddsat_v2i128:
5508 ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
5509 ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0
5510 ; GFX10-NEXT: v_add_co_u32 v8, vcc_lo, v0, v8
5511 ; GFX10-NEXT: v_add_co_ci_u32_e32 v9, vcc_lo, v1, v9, vcc_lo
5512 ; GFX10-NEXT: v_add_co_ci_u32_e32 v16, vcc_lo, v2, v10, vcc_lo
5513 ; GFX10-NEXT: v_add_co_ci_u32_e32 v17, vcc_lo, v3, v11, vcc_lo
5514 ; GFX10-NEXT: v_cmp_lt_u64_e32 vcc_lo, v[8:9], v[0:1]
5515 ; GFX10-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc_lo
5516 ; GFX10-NEXT: v_cmp_lt_i64_e32 vcc_lo, v[16:17], v[2:3]
5517 ; GFX10-NEXT: v_cndmask_b32_e64 v1, 0, 1, vcc_lo
5518 ; GFX10-NEXT: v_cmp_gt_i64_e32 vcc_lo, 0, v[10:11]
5519 ; GFX10-NEXT: v_cndmask_b32_e64 v18, 0, 1, vcc_lo
5520 ; GFX10-NEXT: v_cmp_eq_u64_e32 vcc_lo, v[16:17], v[2:3]
5521 ; GFX10-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc_lo
5522 ; GFX10-NEXT: v_cmp_eq_u64_e32 vcc_lo, 0, v[10:11]
5523 ; GFX10-NEXT: v_cndmask_b32_e64 v1, v18, 0, vcc_lo
5524 ; GFX10-NEXT: v_add_co_u32 v10, vcc_lo, v4, v12
5525 ; GFX10-NEXT: v_add_co_ci_u32_e32 v11, vcc_lo, v5, v13, vcc_lo
5526 ; GFX10-NEXT: v_add_co_ci_u32_e32 v12, vcc_lo, v6, v14, vcc_lo
5527 ; GFX10-NEXT: v_add_co_ci_u32_e32 v13, vcc_lo, v7, v15, vcc_lo
5528 ; GFX10-NEXT: v_cmp_lt_u64_e64 s4, v[10:11], v[4:5]
5529 ; GFX10-NEXT: v_xor_b32_e32 v0, v1, v0
5530 ; GFX10-NEXT: v_ashrrev_i32_e32 v1, 31, v17
5531 ; GFX10-NEXT: v_cmp_eq_u64_e64 s5, v[12:13], v[6:7]
5532 ; GFX10-NEXT: v_cndmask_b32_e64 v4, 0, 1, s4
5533 ; GFX10-NEXT: v_cmp_lt_i64_e64 s4, v[12:13], v[6:7]
5534 ; GFX10-NEXT: v_and_b32_e32 v0, 1, v0
5535 ; GFX10-NEXT: v_add_co_u32 v2, vcc_lo, v1, 0
5536 ; GFX10-NEXT: v_add_co_ci_u32_e32 v3, vcc_lo, 0, v1, vcc_lo
5537 ; GFX10-NEXT: v_cndmask_b32_e64 v5, 0, 1, s4
5538 ; GFX10-NEXT: v_cmp_gt_i64_e64 s4, 0, v[14:15]
5539 ; GFX10-NEXT: v_ashrrev_i32_e32 v7, 31, v13
5540 ; GFX10-NEXT: v_cndmask_b32_e64 v18, 0, 1, s4
5541 ; GFX10-NEXT: v_cmp_ne_u32_e64 s4, 0, v0
5542 ; GFX10-NEXT: v_cndmask_b32_e64 v0, v5, v4, s5
5543 ; GFX10-NEXT: v_cmp_eq_u64_e64 s5, 0, v[14:15]
5544 ; GFX10-NEXT: v_add_co_ci_u32_e32 v5, vcc_lo, 0, v1, vcc_lo
5545 ; GFX10-NEXT: v_add_co_ci_u32_e32 v6, vcc_lo, 0x80000000, v1, vcc_lo
5546 ; GFX10-NEXT: v_cndmask_b32_e64 v1, v9, v3, s4
5547 ; GFX10-NEXT: v_cndmask_b32_e64 v4, v18, 0, s5
5548 ; GFX10-NEXT: v_xor_b32_e32 v4, v4, v0
5549 ; GFX10-NEXT: v_cndmask_b32_e64 v0, v8, v2, s4
5550 ; GFX10-NEXT: v_cndmask_b32_e64 v2, v16, v5, s4
5551 ; GFX10-NEXT: v_and_b32_e32 v3, 1, v4
5552 ; GFX10-NEXT: v_add_co_u32 v4, vcc_lo, v7, 0
5553 ; GFX10-NEXT: v_add_co_ci_u32_e32 v5, vcc_lo, 0, v7, vcc_lo
5554 ; GFX10-NEXT: v_add_co_ci_u32_e32 v8, vcc_lo, 0, v7, vcc_lo
5555 ; GFX10-NEXT: v_cmp_ne_u32_e64 s5, 0, v3
5556 ; GFX10-NEXT: v_add_co_ci_u32_e32 v7, vcc_lo, 0x80000000, v7, vcc_lo
5557 ; GFX10-NEXT: v_cndmask_b32_e64 v3, v17, v6, s4
5558 ; GFX10-NEXT: v_cndmask_b32_e64 v4, v10, v4, s5
5559 ; GFX10-NEXT: v_cndmask_b32_e64 v5, v11, v5, s5
5560 ; GFX10-NEXT: v_cndmask_b32_e64 v6, v12, v8, s5
5561 ; GFX10-NEXT: v_cndmask_b32_e64 v7, v13, v7, s5
5562 ; GFX10-NEXT: s_setpc_b64 s[30:31]
5563 %result = call <2 x i128> @llvm.sadd.sat.v2i128(<2 x i128> %lhs, <2 x i128> %rhs)
5564 ret <2 x i128> %result
5567 define amdgpu_ps <2 x i128> @s_saddsat_v2i128(<2 x i128> inreg %lhs, <2 x i128> inreg %rhs) {
5568 ; GFX6-LABEL: s_saddsat_v2i128:
5570 ; GFX6-NEXT: s_add_u32 s8, s0, s8
5571 ; GFX6-NEXT: s_cselect_b32 s16, 1, 0
5572 ; GFX6-NEXT: s_and_b32 s16, s16, 1
5573 ; GFX6-NEXT: s_cmp_lg_u32 s16, 0
5574 ; GFX6-NEXT: s_addc_u32 s9, s1, s9
5575 ; GFX6-NEXT: s_cselect_b32 s16, 1, 0
5576 ; GFX6-NEXT: s_and_b32 s16, s16, 1
5577 ; GFX6-NEXT: s_cmp_lg_u32 s16, 0
5578 ; GFX6-NEXT: s_addc_u32 s16, s2, s10
5579 ; GFX6-NEXT: s_cselect_b32 s17, 1, 0
5580 ; GFX6-NEXT: v_mov_b32_e32 v3, s1
5581 ; GFX6-NEXT: s_and_b32 s17, s17, 1
5582 ; GFX6-NEXT: v_mov_b32_e32 v2, s0
5583 ; GFX6-NEXT: s_cmp_lg_u32 s17, 0
5584 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
5585 ; GFX6-NEXT: v_cmp_lt_u64_e32 vcc, s[8:9], v[2:3]
5586 ; GFX6-NEXT: s_addc_u32 s17, s3, s11
5587 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
5588 ; GFX6-NEXT: v_cndmask_b32_e64 v2, 0, 1, vcc
5589 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, s[16:17], v[0:1]
5590 ; GFX6-NEXT: v_cmp_lt_i64_e64 s[0:1], s[10:11], 0
5591 ; GFX6-NEXT: v_cndmask_b32_e64 v3, 0, 1, vcc
5592 ; GFX6-NEXT: v_cmp_eq_u64_e32 vcc, s[16:17], v[0:1]
5593 ; GFX6-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[0:1]
5594 ; GFX6-NEXT: v_cmp_eq_u64_e64 s[0:1], s[10:11], 0
5595 ; GFX6-NEXT: s_ashr_i32 s3, s17, 31
5596 ; GFX6-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[0:1]
5597 ; GFX6-NEXT: s_add_u32 s0, s3, 0
5598 ; GFX6-NEXT: s_cselect_b32 s1, 1, 0
5599 ; GFX6-NEXT: s_and_b32 s1, s1, 1
5600 ; GFX6-NEXT: s_cmp_lg_u32 s1, 0
5601 ; GFX6-NEXT: s_addc_u32 s1, s3, 0
5602 ; GFX6-NEXT: s_cselect_b32 s2, 1, 0
5603 ; GFX6-NEXT: s_and_b32 s2, s2, 1
5604 ; GFX6-NEXT: s_cmp_lg_u32 s2, 0
5605 ; GFX6-NEXT: s_addc_u32 s2, s3, 0
5606 ; GFX6-NEXT: s_cselect_b32 s11, 1, 0
5607 ; GFX6-NEXT: s_and_b32 s11, s11, 1
5608 ; GFX6-NEXT: s_brev_b32 s10, 1
5609 ; GFX6-NEXT: s_cmp_lg_u32 s11, 0
5610 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v3, v2, vcc
5611 ; GFX6-NEXT: s_addc_u32 s3, s3, s10
5612 ; GFX6-NEXT: v_xor_b32_e32 v0, v1, v0
5613 ; GFX6-NEXT: v_mov_b32_e32 v1, s0
5614 ; GFX6-NEXT: s_add_u32 s0, s4, s12
5615 ; GFX6-NEXT: v_mov_b32_e32 v2, s1
5616 ; GFX6-NEXT: s_cselect_b32 s1, 1, 0
5617 ; GFX6-NEXT: s_and_b32 s1, s1, 1
5618 ; GFX6-NEXT: s_cmp_lg_u32 s1, 0
5619 ; GFX6-NEXT: v_and_b32_e32 v0, 1, v0
5620 ; GFX6-NEXT: s_addc_u32 s1, s5, s13
5621 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5622 ; GFX6-NEXT: v_mov_b32_e32 v0, s2
5623 ; GFX6-NEXT: s_cselect_b32 s2, 1, 0
5624 ; GFX6-NEXT: s_and_b32 s2, s2, 1
5625 ; GFX6-NEXT: v_mov_b32_e32 v3, s8
5626 ; GFX6-NEXT: v_mov_b32_e32 v4, s9
5627 ; GFX6-NEXT: s_cmp_lg_u32 s2, 0
5628 ; GFX6-NEXT: v_cndmask_b32_e32 v5, v3, v1, vcc
5629 ; GFX6-NEXT: v_cndmask_b32_e32 v4, v4, v2, vcc
5630 ; GFX6-NEXT: v_mov_b32_e32 v1, s3
5631 ; GFX6-NEXT: v_mov_b32_e32 v2, s16
5632 ; GFX6-NEXT: v_mov_b32_e32 v3, s17
5633 ; GFX6-NEXT: s_addc_u32 s2, s6, s14
5634 ; GFX6-NEXT: v_cndmask_b32_e32 v6, v2, v0, vcc
5635 ; GFX6-NEXT: v_cndmask_b32_e32 v7, v3, v1, vcc
5636 ; GFX6-NEXT: s_cselect_b32 s3, 1, 0
5637 ; GFX6-NEXT: v_mov_b32_e32 v2, s4
5638 ; GFX6-NEXT: s_and_b32 s3, s3, 1
5639 ; GFX6-NEXT: v_mov_b32_e32 v3, s5
5640 ; GFX6-NEXT: s_cmp_lg_u32 s3, 0
5641 ; GFX6-NEXT: v_mov_b32_e32 v0, s6
5642 ; GFX6-NEXT: v_cmp_lt_u64_e32 vcc, s[0:1], v[2:3]
5643 ; GFX6-NEXT: s_addc_u32 s3, s7, s15
5644 ; GFX6-NEXT: v_mov_b32_e32 v1, s7
5645 ; GFX6-NEXT: v_cndmask_b32_e64 v2, 0, 1, vcc
5646 ; GFX6-NEXT: v_cmp_lt_i64_e32 vcc, s[2:3], v[0:1]
5647 ; GFX6-NEXT: v_cmp_lt_i64_e64 s[4:5], s[14:15], 0
5648 ; GFX6-NEXT: v_cndmask_b32_e64 v3, 0, 1, vcc
5649 ; GFX6-NEXT: v_cmp_eq_u64_e32 vcc, s[2:3], v[0:1]
5650 ; GFX6-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[4:5]
5651 ; GFX6-NEXT: v_cmp_eq_u64_e64 s[4:5], s[14:15], 0
5652 ; GFX6-NEXT: s_ashr_i32 s7, s3, 31
5653 ; GFX6-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[4:5]
5654 ; GFX6-NEXT: s_add_u32 s4, s7, 0
5655 ; GFX6-NEXT: s_cselect_b32 s5, 1, 0
5656 ; GFX6-NEXT: s_and_b32 s5, s5, 1
5657 ; GFX6-NEXT: s_cmp_lg_u32 s5, 0
5658 ; GFX6-NEXT: s_addc_u32 s5, s7, 0
5659 ; GFX6-NEXT: s_cselect_b32 s6, 1, 0
5660 ; GFX6-NEXT: s_and_b32 s6, s6, 1
5661 ; GFX6-NEXT: s_cmp_lg_u32 s6, 0
5662 ; GFX6-NEXT: s_addc_u32 s6, s7, 0
5663 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v3, v2, vcc
5664 ; GFX6-NEXT: s_cselect_b32 s8, 1, 0
5665 ; GFX6-NEXT: v_xor_b32_e32 v0, v1, v0
5666 ; GFX6-NEXT: s_and_b32 s8, s8, 1
5667 ; GFX6-NEXT: s_cmp_lg_u32 s8, 0
5668 ; GFX6-NEXT: v_and_b32_e32 v0, 1, v0
5669 ; GFX6-NEXT: s_addc_u32 s7, s7, s10
5670 ; GFX6-NEXT: v_mov_b32_e32 v1, s4
5671 ; GFX6-NEXT: v_mov_b32_e32 v2, s5
5672 ; GFX6-NEXT: v_mov_b32_e32 v3, s0
5673 ; GFX6-NEXT: v_mov_b32_e32 v8, s1
5674 ; GFX6-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5675 ; GFX6-NEXT: v_cndmask_b32_e32 v0, v3, v1, vcc
5676 ; GFX6-NEXT: v_cndmask_b32_e32 v1, v8, v2, vcc
5677 ; GFX6-NEXT: v_mov_b32_e32 v2, s6
5678 ; GFX6-NEXT: v_mov_b32_e32 v3, s7
5679 ; GFX6-NEXT: v_mov_b32_e32 v8, s2
5680 ; GFX6-NEXT: v_mov_b32_e32 v9, s3
5681 ; GFX6-NEXT: v_cndmask_b32_e32 v2, v8, v2, vcc
5682 ; GFX6-NEXT: v_cndmask_b32_e32 v3, v9, v3, vcc
5683 ; GFX6-NEXT: v_readfirstlane_b32 s0, v5
5684 ; GFX6-NEXT: v_readfirstlane_b32 s1, v4
5685 ; GFX6-NEXT: v_readfirstlane_b32 s2, v6
5686 ; GFX6-NEXT: v_readfirstlane_b32 s3, v7
5687 ; GFX6-NEXT: v_readfirstlane_b32 s4, v0
5688 ; GFX6-NEXT: v_readfirstlane_b32 s5, v1
5689 ; GFX6-NEXT: v_readfirstlane_b32 s6, v2
5690 ; GFX6-NEXT: v_readfirstlane_b32 s7, v3
5691 ; GFX6-NEXT: ; return to shader part epilog
5693 ; GFX8-LABEL: s_saddsat_v2i128:
5695 ; GFX8-NEXT: s_add_u32 s8, s0, s8
5696 ; GFX8-NEXT: s_cselect_b32 s16, 1, 0
5697 ; GFX8-NEXT: s_and_b32 s16, s16, 1
5698 ; GFX8-NEXT: s_cmp_lg_u32 s16, 0
5699 ; GFX8-NEXT: s_addc_u32 s9, s1, s9
5700 ; GFX8-NEXT: s_cselect_b32 s16, 1, 0
5701 ; GFX8-NEXT: s_and_b32 s16, s16, 1
5702 ; GFX8-NEXT: s_cmp_lg_u32 s16, 0
5703 ; GFX8-NEXT: s_addc_u32 s16, s2, s10
5704 ; GFX8-NEXT: s_cselect_b32 s17, 1, 0
5705 ; GFX8-NEXT: s_and_b32 s17, s17, 1
5706 ; GFX8-NEXT: v_mov_b32_e32 v3, s1
5707 ; GFX8-NEXT: s_cmp_lg_u32 s17, 0
5708 ; GFX8-NEXT: v_mov_b32_e32 v2, s0
5709 ; GFX8-NEXT: s_addc_u32 s17, s3, s11
5710 ; GFX8-NEXT: v_mov_b32_e32 v0, s2
5711 ; GFX8-NEXT: v_cmp_lt_u64_e32 vcc, s[8:9], v[2:3]
5712 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
5713 ; GFX8-NEXT: s_cmp_eq_u64 s[16:17], s[2:3]
5714 ; GFX8-NEXT: s_cselect_b32 s2, 1, 0
5715 ; GFX8-NEXT: v_cndmask_b32_e64 v2, 0, 1, vcc
5716 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, s[16:17], v[0:1]
5717 ; GFX8-NEXT: s_and_b32 s0, 1, s2
5718 ; GFX8-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
5719 ; GFX8-NEXT: v_cmp_ne_u32_e64 vcc, 0, s0
5720 ; GFX8-NEXT: s_cmp_eq_u64 s[10:11], 0
5721 ; GFX8-NEXT: v_cmp_lt_i64_e64 s[0:1], s[10:11], 0
5722 ; GFX8-NEXT: s_cselect_b32 s2, 1, 0
5723 ; GFX8-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[0:1]
5724 ; GFX8-NEXT: s_and_b32 s0, 1, s2
5725 ; GFX8-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, s0
5726 ; GFX8-NEXT: s_ashr_i32 s3, s17, 31
5727 ; GFX8-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[0:1]
5728 ; GFX8-NEXT: s_add_u32 s0, s3, 0
5729 ; GFX8-NEXT: s_cselect_b32 s1, 1, 0
5730 ; GFX8-NEXT: s_and_b32 s1, s1, 1
5731 ; GFX8-NEXT: s_cmp_lg_u32 s1, 0
5732 ; GFX8-NEXT: s_addc_u32 s1, s3, 0
5733 ; GFX8-NEXT: s_cselect_b32 s2, 1, 0
5734 ; GFX8-NEXT: s_and_b32 s2, s2, 1
5735 ; GFX8-NEXT: s_cmp_lg_u32 s2, 0
5736 ; GFX8-NEXT: s_addc_u32 s2, s3, 0
5737 ; GFX8-NEXT: s_cselect_b32 s11, 1, 0
5738 ; GFX8-NEXT: s_and_b32 s11, s11, 1
5739 ; GFX8-NEXT: s_brev_b32 s10, 1
5740 ; GFX8-NEXT: s_cmp_lg_u32 s11, 0
5741 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
5742 ; GFX8-NEXT: s_addc_u32 s3, s3, s10
5743 ; GFX8-NEXT: v_xor_b32_e32 v0, v1, v0
5744 ; GFX8-NEXT: v_mov_b32_e32 v1, s0
5745 ; GFX8-NEXT: s_add_u32 s0, s4, s12
5746 ; GFX8-NEXT: v_mov_b32_e32 v2, s1
5747 ; GFX8-NEXT: s_cselect_b32 s1, 1, 0
5748 ; GFX8-NEXT: s_and_b32 s1, s1, 1
5749 ; GFX8-NEXT: s_cmp_lg_u32 s1, 0
5750 ; GFX8-NEXT: v_and_b32_e32 v0, 1, v0
5751 ; GFX8-NEXT: s_addc_u32 s1, s5, s13
5752 ; GFX8-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5753 ; GFX8-NEXT: v_mov_b32_e32 v0, s2
5754 ; GFX8-NEXT: s_cselect_b32 s2, 1, 0
5755 ; GFX8-NEXT: s_and_b32 s2, s2, 1
5756 ; GFX8-NEXT: s_cmp_lg_u32 s2, 0
5757 ; GFX8-NEXT: v_mov_b32_e32 v3, s8
5758 ; GFX8-NEXT: v_mov_b32_e32 v4, s9
5759 ; GFX8-NEXT: s_addc_u32 s2, s6, s14
5760 ; GFX8-NEXT: v_cndmask_b32_e32 v5, v3, v1, vcc
5761 ; GFX8-NEXT: v_cndmask_b32_e32 v4, v4, v2, vcc
5762 ; GFX8-NEXT: v_mov_b32_e32 v1, s3
5763 ; GFX8-NEXT: v_mov_b32_e32 v2, s16
5764 ; GFX8-NEXT: v_mov_b32_e32 v3, s17
5765 ; GFX8-NEXT: s_cselect_b32 s3, 1, 0
5766 ; GFX8-NEXT: v_cndmask_b32_e32 v6, v2, v0, vcc
5767 ; GFX8-NEXT: v_cndmask_b32_e32 v7, v3, v1, vcc
5768 ; GFX8-NEXT: s_and_b32 s3, s3, 1
5769 ; GFX8-NEXT: v_mov_b32_e32 v2, s4
5770 ; GFX8-NEXT: s_cmp_lg_u32 s3, 0
5771 ; GFX8-NEXT: v_mov_b32_e32 v3, s5
5772 ; GFX8-NEXT: s_addc_u32 s3, s7, s15
5773 ; GFX8-NEXT: v_mov_b32_e32 v0, s6
5774 ; GFX8-NEXT: v_cmp_lt_u64_e32 vcc, s[0:1], v[2:3]
5775 ; GFX8-NEXT: v_mov_b32_e32 v1, s7
5776 ; GFX8-NEXT: s_cmp_eq_u64 s[2:3], s[6:7]
5777 ; GFX8-NEXT: s_cselect_b32 s6, 1, 0
5778 ; GFX8-NEXT: v_cndmask_b32_e64 v2, 0, 1, vcc
5779 ; GFX8-NEXT: v_cmp_lt_i64_e32 vcc, s[2:3], v[0:1]
5780 ; GFX8-NEXT: s_and_b32 s4, 1, s6
5781 ; GFX8-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
5782 ; GFX8-NEXT: v_cmp_ne_u32_e64 vcc, 0, s4
5783 ; GFX8-NEXT: s_cmp_eq_u64 s[14:15], 0
5784 ; GFX8-NEXT: v_cmp_lt_i64_e64 s[4:5], s[14:15], 0
5785 ; GFX8-NEXT: s_cselect_b32 s6, 1, 0
5786 ; GFX8-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[4:5]
5787 ; GFX8-NEXT: s_and_b32 s4, 1, s6
5788 ; GFX8-NEXT: v_cmp_ne_u32_e64 s[4:5], 0, s4
5789 ; GFX8-NEXT: s_ashr_i32 s7, s3, 31
5790 ; GFX8-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[4:5]
5791 ; GFX8-NEXT: s_add_u32 s4, s7, 0
5792 ; GFX8-NEXT: s_cselect_b32 s5, 1, 0
5793 ; GFX8-NEXT: s_and_b32 s5, s5, 1
5794 ; GFX8-NEXT: s_cmp_lg_u32 s5, 0
5795 ; GFX8-NEXT: s_addc_u32 s5, s7, 0
5796 ; GFX8-NEXT: s_cselect_b32 s6, 1, 0
5797 ; GFX8-NEXT: s_and_b32 s6, s6, 1
5798 ; GFX8-NEXT: s_cmp_lg_u32 s6, 0
5799 ; GFX8-NEXT: s_addc_u32 s6, s7, 0
5800 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
5801 ; GFX8-NEXT: s_cselect_b32 s8, 1, 0
5802 ; GFX8-NEXT: v_xor_b32_e32 v0, v1, v0
5803 ; GFX8-NEXT: s_and_b32 s8, s8, 1
5804 ; GFX8-NEXT: s_cmp_lg_u32 s8, 0
5805 ; GFX8-NEXT: v_and_b32_e32 v0, 1, v0
5806 ; GFX8-NEXT: s_addc_u32 s7, s7, s10
5807 ; GFX8-NEXT: v_mov_b32_e32 v1, s4
5808 ; GFX8-NEXT: v_mov_b32_e32 v2, s5
5809 ; GFX8-NEXT: v_mov_b32_e32 v3, s0
5810 ; GFX8-NEXT: v_mov_b32_e32 v8, s1
5811 ; GFX8-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5812 ; GFX8-NEXT: v_cndmask_b32_e32 v0, v3, v1, vcc
5813 ; GFX8-NEXT: v_cndmask_b32_e32 v1, v8, v2, vcc
5814 ; GFX8-NEXT: v_mov_b32_e32 v2, s6
5815 ; GFX8-NEXT: v_mov_b32_e32 v3, s7
5816 ; GFX8-NEXT: v_mov_b32_e32 v8, s2
5817 ; GFX8-NEXT: v_mov_b32_e32 v9, s3
5818 ; GFX8-NEXT: v_cndmask_b32_e32 v2, v8, v2, vcc
5819 ; GFX8-NEXT: v_cndmask_b32_e32 v3, v9, v3, vcc
5820 ; GFX8-NEXT: v_readfirstlane_b32 s0, v5
5821 ; GFX8-NEXT: v_readfirstlane_b32 s1, v4
5822 ; GFX8-NEXT: v_readfirstlane_b32 s2, v6
5823 ; GFX8-NEXT: v_readfirstlane_b32 s3, v7
5824 ; GFX8-NEXT: v_readfirstlane_b32 s4, v0
5825 ; GFX8-NEXT: v_readfirstlane_b32 s5, v1
5826 ; GFX8-NEXT: v_readfirstlane_b32 s6, v2
5827 ; GFX8-NEXT: v_readfirstlane_b32 s7, v3
5828 ; GFX8-NEXT: ; return to shader part epilog
5830 ; GFX9-LABEL: s_saddsat_v2i128:
5832 ; GFX9-NEXT: s_add_u32 s8, s0, s8
5833 ; GFX9-NEXT: s_cselect_b32 s16, 1, 0
5834 ; GFX9-NEXT: s_and_b32 s16, s16, 1
5835 ; GFX9-NEXT: s_cmp_lg_u32 s16, 0
5836 ; GFX9-NEXT: s_addc_u32 s9, s1, s9
5837 ; GFX9-NEXT: s_cselect_b32 s16, 1, 0
5838 ; GFX9-NEXT: s_and_b32 s16, s16, 1
5839 ; GFX9-NEXT: s_cmp_lg_u32 s16, 0
5840 ; GFX9-NEXT: s_addc_u32 s16, s2, s10
5841 ; GFX9-NEXT: s_cselect_b32 s17, 1, 0
5842 ; GFX9-NEXT: s_and_b32 s17, s17, 1
5843 ; GFX9-NEXT: v_mov_b32_e32 v3, s1
5844 ; GFX9-NEXT: s_cmp_lg_u32 s17, 0
5845 ; GFX9-NEXT: v_mov_b32_e32 v2, s0
5846 ; GFX9-NEXT: s_addc_u32 s17, s3, s11
5847 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
5848 ; GFX9-NEXT: v_cmp_lt_u64_e32 vcc, s[8:9], v[2:3]
5849 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
5850 ; GFX9-NEXT: s_cmp_eq_u64 s[16:17], s[2:3]
5851 ; GFX9-NEXT: s_cselect_b32 s2, 1, 0
5852 ; GFX9-NEXT: v_cndmask_b32_e64 v2, 0, 1, vcc
5853 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, s[16:17], v[0:1]
5854 ; GFX9-NEXT: s_and_b32 s0, 1, s2
5855 ; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
5856 ; GFX9-NEXT: v_cmp_ne_u32_e64 vcc, 0, s0
5857 ; GFX9-NEXT: s_cmp_eq_u64 s[10:11], 0
5858 ; GFX9-NEXT: v_cmp_lt_i64_e64 s[0:1], s[10:11], 0
5859 ; GFX9-NEXT: s_cselect_b32 s2, 1, 0
5860 ; GFX9-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[0:1]
5861 ; GFX9-NEXT: s_and_b32 s0, 1, s2
5862 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[0:1], 0, s0
5863 ; GFX9-NEXT: s_ashr_i32 s3, s17, 31
5864 ; GFX9-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[0:1]
5865 ; GFX9-NEXT: s_add_u32 s0, s3, 0
5866 ; GFX9-NEXT: s_cselect_b32 s1, 1, 0
5867 ; GFX9-NEXT: s_and_b32 s1, s1, 1
5868 ; GFX9-NEXT: s_cmp_lg_u32 s1, 0
5869 ; GFX9-NEXT: s_addc_u32 s1, s3, 0
5870 ; GFX9-NEXT: s_cselect_b32 s2, 1, 0
5871 ; GFX9-NEXT: s_and_b32 s2, s2, 1
5872 ; GFX9-NEXT: s_cmp_lg_u32 s2, 0
5873 ; GFX9-NEXT: s_addc_u32 s2, s3, 0
5874 ; GFX9-NEXT: s_cselect_b32 s11, 1, 0
5875 ; GFX9-NEXT: s_and_b32 s11, s11, 1
5876 ; GFX9-NEXT: s_brev_b32 s10, 1
5877 ; GFX9-NEXT: s_cmp_lg_u32 s11, 0
5878 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
5879 ; GFX9-NEXT: s_addc_u32 s3, s3, s10
5880 ; GFX9-NEXT: v_xor_b32_e32 v0, v1, v0
5881 ; GFX9-NEXT: v_mov_b32_e32 v1, s0
5882 ; GFX9-NEXT: s_add_u32 s0, s4, s12
5883 ; GFX9-NEXT: v_mov_b32_e32 v2, s1
5884 ; GFX9-NEXT: s_cselect_b32 s1, 1, 0
5885 ; GFX9-NEXT: s_and_b32 s1, s1, 1
5886 ; GFX9-NEXT: s_cmp_lg_u32 s1, 0
5887 ; GFX9-NEXT: v_and_b32_e32 v0, 1, v0
5888 ; GFX9-NEXT: s_addc_u32 s1, s5, s13
5889 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5890 ; GFX9-NEXT: v_mov_b32_e32 v0, s2
5891 ; GFX9-NEXT: s_cselect_b32 s2, 1, 0
5892 ; GFX9-NEXT: s_and_b32 s2, s2, 1
5893 ; GFX9-NEXT: s_cmp_lg_u32 s2, 0
5894 ; GFX9-NEXT: v_mov_b32_e32 v3, s8
5895 ; GFX9-NEXT: v_mov_b32_e32 v4, s9
5896 ; GFX9-NEXT: s_addc_u32 s2, s6, s14
5897 ; GFX9-NEXT: v_cndmask_b32_e32 v5, v3, v1, vcc
5898 ; GFX9-NEXT: v_cndmask_b32_e32 v4, v4, v2, vcc
5899 ; GFX9-NEXT: v_mov_b32_e32 v1, s3
5900 ; GFX9-NEXT: v_mov_b32_e32 v2, s16
5901 ; GFX9-NEXT: v_mov_b32_e32 v3, s17
5902 ; GFX9-NEXT: s_cselect_b32 s3, 1, 0
5903 ; GFX9-NEXT: v_cndmask_b32_e32 v6, v2, v0, vcc
5904 ; GFX9-NEXT: v_cndmask_b32_e32 v7, v3, v1, vcc
5905 ; GFX9-NEXT: s_and_b32 s3, s3, 1
5906 ; GFX9-NEXT: v_mov_b32_e32 v2, s4
5907 ; GFX9-NEXT: s_cmp_lg_u32 s3, 0
5908 ; GFX9-NEXT: v_mov_b32_e32 v3, s5
5909 ; GFX9-NEXT: s_addc_u32 s3, s7, s15
5910 ; GFX9-NEXT: v_mov_b32_e32 v0, s6
5911 ; GFX9-NEXT: v_cmp_lt_u64_e32 vcc, s[0:1], v[2:3]
5912 ; GFX9-NEXT: v_mov_b32_e32 v1, s7
5913 ; GFX9-NEXT: s_cmp_eq_u64 s[2:3], s[6:7]
5914 ; GFX9-NEXT: s_cselect_b32 s6, 1, 0
5915 ; GFX9-NEXT: v_cndmask_b32_e64 v2, 0, 1, vcc
5916 ; GFX9-NEXT: v_cmp_lt_i64_e32 vcc, s[2:3], v[0:1]
5917 ; GFX9-NEXT: s_and_b32 s4, 1, s6
5918 ; GFX9-NEXT: v_cndmask_b32_e64 v0, 0, 1, vcc
5919 ; GFX9-NEXT: v_cmp_ne_u32_e64 vcc, 0, s4
5920 ; GFX9-NEXT: s_cmp_eq_u64 s[14:15], 0
5921 ; GFX9-NEXT: v_cmp_lt_i64_e64 s[4:5], s[14:15], 0
5922 ; GFX9-NEXT: s_cselect_b32 s6, 1, 0
5923 ; GFX9-NEXT: v_cndmask_b32_e64 v1, 0, 1, s[4:5]
5924 ; GFX9-NEXT: s_and_b32 s4, 1, s6
5925 ; GFX9-NEXT: v_cmp_ne_u32_e64 s[4:5], 0, s4
5926 ; GFX9-NEXT: s_ashr_i32 s7, s3, 31
5927 ; GFX9-NEXT: v_cndmask_b32_e64 v1, v1, 0, s[4:5]
5928 ; GFX9-NEXT: s_add_u32 s4, s7, 0
5929 ; GFX9-NEXT: s_cselect_b32 s5, 1, 0
5930 ; GFX9-NEXT: s_and_b32 s5, s5, 1
5931 ; GFX9-NEXT: s_cmp_lg_u32 s5, 0
5932 ; GFX9-NEXT: s_addc_u32 s5, s7, 0
5933 ; GFX9-NEXT: s_cselect_b32 s6, 1, 0
5934 ; GFX9-NEXT: s_and_b32 s6, s6, 1
5935 ; GFX9-NEXT: s_cmp_lg_u32 s6, 0
5936 ; GFX9-NEXT: s_addc_u32 s6, s7, 0
5937 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v0, v2, vcc
5938 ; GFX9-NEXT: s_cselect_b32 s8, 1, 0
5939 ; GFX9-NEXT: v_xor_b32_e32 v0, v1, v0
5940 ; GFX9-NEXT: s_and_b32 s8, s8, 1
5941 ; GFX9-NEXT: s_cmp_lg_u32 s8, 0
5942 ; GFX9-NEXT: v_and_b32_e32 v0, 1, v0
5943 ; GFX9-NEXT: s_addc_u32 s7, s7, s10
5944 ; GFX9-NEXT: v_mov_b32_e32 v1, s4
5945 ; GFX9-NEXT: v_mov_b32_e32 v2, s5
5946 ; GFX9-NEXT: v_mov_b32_e32 v3, s0
5947 ; GFX9-NEXT: v_mov_b32_e32 v8, s1
5948 ; GFX9-NEXT: v_cmp_ne_u32_e32 vcc, 0, v0
5949 ; GFX9-NEXT: v_cndmask_b32_e32 v0, v3, v1, vcc
5950 ; GFX9-NEXT: v_cndmask_b32_e32 v1, v8, v2, vcc
5951 ; GFX9-NEXT: v_mov_b32_e32 v2, s6
5952 ; GFX9-NEXT: v_mov_b32_e32 v3, s7
5953 ; GFX9-NEXT: v_mov_b32_e32 v8, s2
5954 ; GFX9-NEXT: v_mov_b32_e32 v9, s3
5955 ; GFX9-NEXT: v_cndmask_b32_e32 v2, v8, v2, vcc
5956 ; GFX9-NEXT: v_cndmask_b32_e32 v3, v9, v3, vcc
5957 ; GFX9-NEXT: v_readfirstlane_b32 s0, v5
5958 ; GFX9-NEXT: v_readfirstlane_b32 s1, v4
5959 ; GFX9-NEXT: v_readfirstlane_b32 s2, v6
5960 ; GFX9-NEXT: v_readfirstlane_b32 s3, v7
5961 ; GFX9-NEXT: v_readfirstlane_b32 s4, v0
5962 ; GFX9-NEXT: v_readfirstlane_b32 s5, v1
5963 ; GFX9-NEXT: v_readfirstlane_b32 s6, v2
5964 ; GFX9-NEXT: v_readfirstlane_b32 s7, v3
5965 ; GFX9-NEXT: ; return to shader part epilog
5967 ; GFX10-LABEL: s_saddsat_v2i128:
5969 ; GFX10-NEXT: s_add_u32 s8, s0, s8
5970 ; GFX10-NEXT: s_cselect_b32 s16, 1, 0
5971 ; GFX10-NEXT: s_and_b32 s16, s16, 1
5972 ; GFX10-NEXT: s_cmp_lg_u32 s16, 0
5973 ; GFX10-NEXT: s_addc_u32 s9, s1, s9
5974 ; GFX10-NEXT: s_cselect_b32 s16, 1, 0
5975 ; GFX10-NEXT: v_cmp_lt_u64_e64 s0, s[8:9], s[0:1]
5976 ; GFX10-NEXT: s_and_b32 s16, s16, 1
5977 ; GFX10-NEXT: v_cmp_lt_i64_e64 s1, s[10:11], 0
5978 ; GFX10-NEXT: s_cmp_lg_u32 s16, 0
5979 ; GFX10-NEXT: v_mov_b32_e32 v2, s9
5980 ; GFX10-NEXT: s_addc_u32 s16, s2, s10
5981 ; GFX10-NEXT: s_cselect_b32 s17, 1, 0
5982 ; GFX10-NEXT: v_cndmask_b32_e64 v0, 0, 1, s0
5983 ; GFX10-NEXT: s_and_b32 s17, s17, 1
5984 ; GFX10-NEXT: s_cmp_lg_u32 s17, 0
5985 ; GFX10-NEXT: s_addc_u32 s17, s3, s11
5986 ; GFX10-NEXT: v_cmp_lt_i64_e64 s0, s[16:17], s[2:3]
5987 ; GFX10-NEXT: s_cmp_eq_u64 s[16:17], s[2:3]
5988 ; GFX10-NEXT: v_mov_b32_e32 v3, s17
5989 ; GFX10-NEXT: s_cselect_b32 s18, 1, 0
5990 ; GFX10-NEXT: v_cndmask_b32_e64 v1, 0, 1, s0
5991 ; GFX10-NEXT: s_and_b32 s0, 1, s18
5992 ; GFX10-NEXT: s_cmp_eq_u64 s[10:11], 0
5993 ; GFX10-NEXT: v_cmp_ne_u32_e64 vcc_lo, 0, s0
5994 ; GFX10-NEXT: s_cselect_b32 s0, 1, 0
5995 ; GFX10-NEXT: s_ashr_i32 s3, s17, 31
5996 ; GFX10-NEXT: s_and_b32 s0, 1, s0
5997 ; GFX10-NEXT: s_brev_b32 s10, 1
5998 ; GFX10-NEXT: v_cndmask_b32_e32 v0, v1, v0, vcc_lo
5999 ; GFX10-NEXT: v_cndmask_b32_e64 v1, 0, 1, s1
6000 ; GFX10-NEXT: v_cmp_ne_u32_e64 s0, 0, s0
6001 ; GFX10-NEXT: v_cndmask_b32_e64 v1, v1, 0, s0
6002 ; GFX10-NEXT: s_add_u32 s0, s3, 0
6003 ; GFX10-NEXT: s_cselect_b32 s1, 1, 0
6004 ; GFX10-NEXT: s_and_b32 s1, s1, 1
6005 ; GFX10-NEXT: v_xor_b32_e32 v0, v1, v0
6006 ; GFX10-NEXT: s_cmp_lg_u32 s1, 0
6007 ; GFX10-NEXT: v_mov_b32_e32 v1, s8
6008 ; GFX10-NEXT: s_addc_u32 s1, s3, 0
6009 ; GFX10-NEXT: s_cselect_b32 s2, 1, 0
6010 ; GFX10-NEXT: v_and_b32_e32 v0, 1, v0
6011 ; GFX10-NEXT: s_and_b32 s2, s2, 1
6012 ; GFX10-NEXT: s_cmp_lg_u32 s2, 0
6013 ; GFX10-NEXT: s_addc_u32 s2, s3, 0
6014 ; GFX10-NEXT: s_cselect_b32 s11, 1, 0
6015 ; GFX10-NEXT: v_cmp_ne_u32_e32 vcc_lo, 0, v0
6016 ; GFX10-NEXT: s_and_b32 s11, s11, 1
6017 ; GFX10-NEXT: s_cmp_lg_u32 s11, 0
6018 ; GFX10-NEXT: s_addc_u32 s3, s3, s10
6019 ; GFX10-NEXT: v_cndmask_b32_e64 v0, v1, s0, vcc_lo
6020 ; GFX10-NEXT: s_add_u32 s0, s4, s12
6021 ; GFX10-NEXT: s_cselect_b32 s8, 1, 0
6022 ; GFX10-NEXT: v_cndmask_b32_e64 v1, v2, s1, vcc_lo
6023 ; GFX10-NEXT: s_and_b32 s8, s8, 1
6024 ; GFX10-NEXT: v_mov_b32_e32 v2, s16
6025 ; GFX10-NEXT: s_cmp_lg_u32 s8, 0
6026 ; GFX10-NEXT: v_cndmask_b32_e64 v3, v3, s3, vcc_lo
6027 ; GFX10-NEXT: s_addc_u32 s1, s5, s13
6028 ; GFX10-NEXT: s_cselect_b32 s8, 1, 0
6029 ; GFX10-NEXT: v_cmp_lt_u64_e64 s4, s[0:1], s[4:5]
6030 ; GFX10-NEXT: s_and_b32 s8, s8, 1
6031 ; GFX10-NEXT: v_cndmask_b32_e64 v2, v2, s2, vcc_lo
6032 ; GFX10-NEXT: s_cmp_lg_u32 s8, 0
6033 ; GFX10-NEXT: v_cmp_lt_i64_e64 s3, s[14:15], 0
6034 ; GFX10-NEXT: s_addc_u32 s8, s6, s14
6035 ; GFX10-NEXT: s_cselect_b32 s9, 1, 0
6036 ; GFX10-NEXT: v_cndmask_b32_e64 v4, 0, 1, s4
6037 ; GFX10-NEXT: s_and_b32 s9, s9, 1
6038 ; GFX10-NEXT: v_mov_b32_e32 v6, s1
6039 ; GFX10-NEXT: s_cmp_lg_u32 s9, 0
6040 ; GFX10-NEXT: v_mov_b32_e32 v7, s8
6041 ; GFX10-NEXT: s_addc_u32 s9, s7, s15
6042 ; GFX10-NEXT: s_cmp_eq_u64 s[8:9], s[6:7]
6043 ; GFX10-NEXT: v_cmp_lt_i64_e64 s4, s[8:9], s[6:7]
6044 ; GFX10-NEXT: s_cselect_b32 s2, 1, 0
6045 ; GFX10-NEXT: v_mov_b32_e32 v8, s9
6046 ; GFX10-NEXT: s_and_b32 s2, 1, s2
6047 ; GFX10-NEXT: s_cmp_eq_u64 s[14:15], 0
6048 ; GFX10-NEXT: v_cmp_ne_u32_e64 vcc_lo, 0, s2
6049 ; GFX10-NEXT: v_cndmask_b32_e64 v5, 0, 1, s4
6050 ; GFX10-NEXT: s_cselect_b32 s2, 1, 0
6051 ; GFX10-NEXT: s_ashr_i32 s5, s9, 31
6052 ; GFX10-NEXT: v_cndmask_b32_e32 v4, v5, v4, vcc_lo
6053 ; GFX10-NEXT: v_cndmask_b32_e64 v5, 0, 1, s3
6054 ; GFX10-NEXT: s_and_b32 s3, 1, s2
6055 ; GFX10-NEXT: s_add_u32 s2, s5, 0
6056 ; GFX10-NEXT: v_cmp_ne_u32_e64 s3, 0, s3
6057 ; GFX10-NEXT: s_cselect_b32 s4, 1, 0
6058 ; GFX10-NEXT: s_and_b32 s4, s4, 1
6059 ; GFX10-NEXT: v_cndmask_b32_e64 v5, v5, 0, s3
6060 ; GFX10-NEXT: s_cmp_lg_u32 s4, 0
6061 ; GFX10-NEXT: s_addc_u32 s3, s5, 0
6062 ; GFX10-NEXT: s_cselect_b32 s4, 1, 0
6063 ; GFX10-NEXT: v_xor_b32_e32 v4, v5, v4
6064 ; GFX10-NEXT: s_and_b32 s4, s4, 1
6065 ; GFX10-NEXT: v_mov_b32_e32 v5, s0
6066 ; GFX10-NEXT: s_cmp_lg_u32 s4, 0
6067 ; GFX10-NEXT: v_readfirstlane_b32 s0, v0
6068 ; GFX10-NEXT: v_and_b32_e32 v4, 1, v4
6069 ; GFX10-NEXT: s_addc_u32 s4, s5, 0
6070 ; GFX10-NEXT: s_cselect_b32 s6, 1, 0
6071 ; GFX10-NEXT: s_and_b32 s6, s6, 1
6072 ; GFX10-NEXT: v_cmp_ne_u32_e32 vcc_lo, 0, v4
6073 ; GFX10-NEXT: s_cmp_lg_u32 s6, 0
6074 ; GFX10-NEXT: s_addc_u32 s1, s5, s10
6075 ; GFX10-NEXT: v_cndmask_b32_e64 v4, v5, s2, vcc_lo
6076 ; GFX10-NEXT: v_cndmask_b32_e64 v5, v6, s3, vcc_lo
6077 ; GFX10-NEXT: v_cndmask_b32_e64 v6, v7, s4, vcc_lo
6078 ; GFX10-NEXT: v_cndmask_b32_e64 v7, v8, s1, vcc_lo
6079 ; GFX10-NEXT: v_readfirstlane_b32 s1, v1
6080 ; GFX10-NEXT: v_readfirstlane_b32 s2, v2
6081 ; GFX10-NEXT: v_readfirstlane_b32 s3, v3
6082 ; GFX10-NEXT: v_readfirstlane_b32 s4, v4
6083 ; GFX10-NEXT: v_readfirstlane_b32 s5, v5
6084 ; GFX10-NEXT: v_readfirstlane_b32 s6, v6
6085 ; GFX10-NEXT: v_readfirstlane_b32 s7, v7
6086 ; GFX10-NEXT: ; return to shader part epilog
6087 %result = call <2 x i128> @llvm.sadd.sat.v2i128(<2 x i128> %lhs, <2 x i128> %rhs)
6088 ret <2 x i128> %result
6091 declare i7 @llvm.sadd.sat.i7(i7, i7) #0
6092 declare i8 @llvm.sadd.sat.i8(i8, i8) #0
6093 declare <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8>, <2 x i8>) #0
6094 declare <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8>, <4 x i8>) #0
6096 declare i16 @llvm.sadd.sat.i16(i16, i16) #0
6097 declare <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16>, <2 x i16>) #0
6098 declare <3 x i16> @llvm.sadd.sat.v3i16(<3 x i16>, <3 x i16>) #0
6099 declare <4 x i16> @llvm.sadd.sat.v4i16(<4 x i16>, <4 x i16>) #0
6100 declare <5 x i16> @llvm.sadd.sat.v5i16(<5 x i16>, <5 x i16>) #0
6101 declare <6 x i16> @llvm.sadd.sat.v6i16(<6 x i16>, <6 x i16>) #0
6102 declare <8 x i16> @llvm.sadd.sat.v8i16(<8 x i16>, <8 x i16>) #0
6104 declare i24 @llvm.sadd.sat.i24(i24, i24) #0
6106 declare i32 @llvm.sadd.sat.i32(i32, i32) #0
6107 declare <2 x i32> @llvm.sadd.sat.v2i32(<2 x i32>, <2 x i32>) #0
6108 declare <3 x i32> @llvm.sadd.sat.v3i32(<3 x i32>, <3 x i32>) #0
6109 declare <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32>, <4 x i32>) #0
6110 declare <5 x i32> @llvm.sadd.sat.v5i32(<5 x i32>, <5 x i32>) #0
6111 declare <16 x i32> @llvm.sadd.sat.v16i32(<16 x i32>, <16 x i32>) #0
6113 declare i48 @llvm.sadd.sat.i48(i48, i48) #0
6115 declare i64 @llvm.sadd.sat.i64(i64, i64) #0
6116 declare <2 x i64> @llvm.sadd.sat.v2i64(<2 x i64>, <2 x i64>) #0
6118 declare i128 @llvm.sadd.sat.i128(i128, i128) #0
6119 declare <2 x i128> @llvm.sadd.sat.v2i128(<2 x i128>, <2 x i128>) #0
6121 attributes #0 = { nounwind readnone speculatable willreturn }