1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=powerpc64le-- -verify-machineinstrs | FileCheck %s
4 ; There are at least 3 potential patterns corresponding to an unsigned saturated add: min, cmp with sum, cmp with not.
5 ; Test each of those patterns with i8/i16/i32/i64.
6 ; Test each of those with a constant operand and a variable operand.
7 ; Test each of those with a 128-bit vector type.
9 define i8 @unsigned_sat_constant_i8_using_min(i8 %x) {
10 ; CHECK-LABEL: unsigned_sat_constant_i8_using_min:
12 ; CHECK-NEXT: clrlwi 5, 3, 24
13 ; CHECK-NEXT: li 4, -43
14 ; CHECK-NEXT: cmplwi 5, 213
15 ; CHECK-NEXT: isel 3, 3, 4, 0
16 ; CHECK-NEXT: addi 3, 3, 42
18 %c = icmp ult i8 %x, -43
19 %s = select i1 %c, i8 %x, i8 -43
24 define i8 @unsigned_sat_constant_i8_using_cmp_sum(i8 %x) {
25 ; CHECK-LABEL: unsigned_sat_constant_i8_using_cmp_sum:
27 ; CHECK-NEXT: rlwinm 3, 3, 0, 24, 31
28 ; CHECK-NEXT: addi 3, 3, 42
29 ; CHECK-NEXT: andi. 4, 3, 256
30 ; CHECK-NEXT: li 4, -1
31 ; CHECK-NEXT: isel 3, 3, 4, 2
34 %c = icmp ugt i8 %x, %a
35 %r = select i1 %c, i8 -1, i8 %a
39 define i8 @unsigned_sat_constant_i8_using_cmp_notval(i8 %x) {
40 ; CHECK-LABEL: unsigned_sat_constant_i8_using_cmp_notval:
42 ; CHECK-NEXT: clrlwi 5, 3, 24
43 ; CHECK-NEXT: li 4, -1
44 ; CHECK-NEXT: addi 3, 3, 42
45 ; CHECK-NEXT: cmplwi 5, 213
46 ; CHECK-NEXT: isel 3, 4, 3, 1
49 %c = icmp ugt i8 %x, -43
50 %r = select i1 %c, i8 -1, i8 %a
54 define i16 @unsigned_sat_constant_i16_using_min(i16 %x) {
55 ; CHECK-LABEL: unsigned_sat_constant_i16_using_min:
57 ; CHECK-NEXT: clrlwi 5, 3, 16
58 ; CHECK-NEXT: li 4, -43
59 ; CHECK-NEXT: cmplwi 5, 65493
60 ; CHECK-NEXT: isel 3, 3, 4, 0
61 ; CHECK-NEXT: addi 3, 3, 42
63 %c = icmp ult i16 %x, -43
64 %s = select i1 %c, i16 %x, i16 -43
69 define i16 @unsigned_sat_constant_i16_using_cmp_sum(i16 %x) {
70 ; CHECK-LABEL: unsigned_sat_constant_i16_using_cmp_sum:
72 ; CHECK-NEXT: rlwinm 3, 3, 0, 16, 31
73 ; CHECK-NEXT: addi 3, 3, 42
74 ; CHECK-NEXT: andis. 4, 3, 1
75 ; CHECK-NEXT: li 4, -1
76 ; CHECK-NEXT: isel 3, 3, 4, 2
79 %c = icmp ugt i16 %x, %a
80 %r = select i1 %c, i16 -1, i16 %a
84 define i16 @unsigned_sat_constant_i16_using_cmp_notval(i16 %x) {
85 ; CHECK-LABEL: unsigned_sat_constant_i16_using_cmp_notval:
87 ; CHECK-NEXT: clrlwi 5, 3, 16
88 ; CHECK-NEXT: li 4, -1
89 ; CHECK-NEXT: addi 3, 3, 42
90 ; CHECK-NEXT: cmplwi 5, 65493
91 ; CHECK-NEXT: isel 3, 4, 3, 1
94 %c = icmp ugt i16 %x, -43
95 %r = select i1 %c, i16 -1, i16 %a
99 define i32 @unsigned_sat_constant_i32_using_min(i32 %x) {
100 ; CHECK-LABEL: unsigned_sat_constant_i32_using_min:
102 ; CHECK-NEXT: li 4, -43
103 ; CHECK-NEXT: cmplw 3, 4
104 ; CHECK-NEXT: isel 3, 3, 4, 0
105 ; CHECK-NEXT: addi 3, 3, 42
107 %c = icmp ult i32 %x, -43
108 %s = select i1 %c, i32 %x, i32 -43
113 define i32 @unsigned_sat_constant_i32_using_cmp_sum(i32 %x) {
114 ; CHECK-LABEL: unsigned_sat_constant_i32_using_cmp_sum:
116 ; CHECK-NEXT: addi 5, 3, 42
117 ; CHECK-NEXT: li 4, -1
118 ; CHECK-NEXT: cmplw 0, 5, 3
119 ; CHECK-NEXT: isel 3, 4, 5, 0
122 %c = icmp ugt i32 %x, %a
123 %r = select i1 %c, i32 -1, i32 %a
127 define i32 @unsigned_sat_constant_i32_using_cmp_notval(i32 %x) {
128 ; CHECK-LABEL: unsigned_sat_constant_i32_using_cmp_notval:
130 ; CHECK-NEXT: li 4, -43
131 ; CHECK-NEXT: addi 5, 3, 42
132 ; CHECK-NEXT: cmplw 0, 3, 4
133 ; CHECK-NEXT: li 3, -1
134 ; CHECK-NEXT: isel 3, 3, 5, 1
137 %c = icmp ugt i32 %x, -43
138 %r = select i1 %c, i32 -1, i32 %a
142 define i64 @unsigned_sat_constant_i64_using_min(i64 %x) {
143 ; CHECK-LABEL: unsigned_sat_constant_i64_using_min:
145 ; CHECK-NEXT: li 4, -43
146 ; CHECK-NEXT: cmpld 3, 4
147 ; CHECK-NEXT: isel 3, 3, 4, 0
148 ; CHECK-NEXT: addi 3, 3, 42
150 %c = icmp ult i64 %x, -43
151 %s = select i1 %c, i64 %x, i64 -43
156 define i64 @unsigned_sat_constant_i64_using_cmp_sum(i64 %x) {
157 ; CHECK-LABEL: unsigned_sat_constant_i64_using_cmp_sum:
159 ; CHECK-NEXT: addi 5, 3, 42
160 ; CHECK-NEXT: li 4, -1
161 ; CHECK-NEXT: cmpld 5, 3
162 ; CHECK-NEXT: isel 3, 4, 5, 0
165 %c = icmp ugt i64 %x, %a
166 %r = select i1 %c, i64 -1, i64 %a
170 define i64 @unsigned_sat_constant_i64_using_cmp_notval(i64 %x) {
171 ; CHECK-LABEL: unsigned_sat_constant_i64_using_cmp_notval:
173 ; CHECK-NEXT: li 4, -43
174 ; CHECK-NEXT: addi 5, 3, 42
175 ; CHECK-NEXT: cmpld 3, 4
176 ; CHECK-NEXT: li 3, -1
177 ; CHECK-NEXT: isel 3, 3, 5, 1
180 %c = icmp ugt i64 %x, -43
181 %r = select i1 %c, i64 -1, i64 %a
185 define i8 @unsigned_sat_variable_i8_using_min(i8 %x, i8 %y) {
186 ; CHECK-LABEL: unsigned_sat_variable_i8_using_min:
188 ; CHECK-NEXT: nor 5, 4, 4
189 ; CHECK-NEXT: clrlwi 6, 3, 24
190 ; CHECK-NEXT: clrlwi 7, 5, 24
191 ; CHECK-NEXT: cmplw 6, 7
192 ; CHECK-NEXT: isel 3, 3, 5, 0
193 ; CHECK-NEXT: add 3, 3, 4
195 %noty = xor i8 %y, -1
196 %c = icmp ult i8 %x, %noty
197 %s = select i1 %c, i8 %x, i8 %noty
202 define i8 @unsigned_sat_variable_i8_using_cmp_sum(i8 %x, i8 %y) {
203 ; CHECK-LABEL: unsigned_sat_variable_i8_using_cmp_sum:
205 ; CHECK-NEXT: rlwinm 4, 4, 0, 24, 31
206 ; CHECK-NEXT: rlwinm 3, 3, 0, 24, 31
207 ; CHECK-NEXT: add 3, 3, 4
208 ; CHECK-NEXT: andi. 4, 3, 256
209 ; CHECK-NEXT: li 4, -1
210 ; CHECK-NEXT: isel 3, 3, 4, 2
213 %c = icmp ugt i8 %x, %a
214 %r = select i1 %c, i8 -1, i8 %a
218 define i8 @unsigned_sat_variable_i8_using_cmp_notval(i8 %x, i8 %y) {
219 ; CHECK-LABEL: unsigned_sat_variable_i8_using_cmp_notval:
221 ; CHECK-NEXT: nor 6, 4, 4
222 ; CHECK-NEXT: clrlwi 7, 3, 24
223 ; CHECK-NEXT: li 5, -1
224 ; CHECK-NEXT: add 3, 3, 4
225 ; CHECK-NEXT: clrlwi 6, 6, 24
226 ; CHECK-NEXT: cmplw 7, 6
227 ; CHECK-NEXT: isel 3, 5, 3, 1
229 %noty = xor i8 %y, -1
231 %c = icmp ugt i8 %x, %noty
232 %r = select i1 %c, i8 -1, i8 %a
236 define i16 @unsigned_sat_variable_i16_using_min(i16 %x, i16 %y) {
237 ; CHECK-LABEL: unsigned_sat_variable_i16_using_min:
239 ; CHECK-NEXT: nor 5, 4, 4
240 ; CHECK-NEXT: clrlwi 6, 3, 16
241 ; CHECK-NEXT: clrlwi 7, 5, 16
242 ; CHECK-NEXT: cmplw 6, 7
243 ; CHECK-NEXT: isel 3, 3, 5, 0
244 ; CHECK-NEXT: add 3, 3, 4
246 %noty = xor i16 %y, -1
247 %c = icmp ult i16 %x, %noty
248 %s = select i1 %c, i16 %x, i16 %noty
253 define i16 @unsigned_sat_variable_i16_using_cmp_sum(i16 %x, i16 %y) {
254 ; CHECK-LABEL: unsigned_sat_variable_i16_using_cmp_sum:
256 ; CHECK-NEXT: rlwinm 4, 4, 0, 16, 31
257 ; CHECK-NEXT: rlwinm 3, 3, 0, 16, 31
258 ; CHECK-NEXT: add 3, 3, 4
259 ; CHECK-NEXT: andis. 4, 3, 1
260 ; CHECK-NEXT: li 4, -1
261 ; CHECK-NEXT: isel 3, 3, 4, 2
264 %c = icmp ugt i16 %x, %a
265 %r = select i1 %c, i16 -1, i16 %a
269 define i16 @unsigned_sat_variable_i16_using_cmp_notval(i16 %x, i16 %y) {
270 ; CHECK-LABEL: unsigned_sat_variable_i16_using_cmp_notval:
272 ; CHECK-NEXT: nor 6, 4, 4
273 ; CHECK-NEXT: clrlwi 7, 3, 16
274 ; CHECK-NEXT: li 5, -1
275 ; CHECK-NEXT: add 3, 3, 4
276 ; CHECK-NEXT: clrlwi 6, 6, 16
277 ; CHECK-NEXT: cmplw 7, 6
278 ; CHECK-NEXT: isel 3, 5, 3, 1
280 %noty = xor i16 %y, -1
282 %c = icmp ugt i16 %x, %noty
283 %r = select i1 %c, i16 -1, i16 %a
287 define i32 @unsigned_sat_variable_i32_using_min(i32 %x, i32 %y) {
288 ; CHECK-LABEL: unsigned_sat_variable_i32_using_min:
290 ; CHECK-NEXT: nor 5, 4, 4
291 ; CHECK-NEXT: cmplw 3, 5
292 ; CHECK-NEXT: isel 3, 3, 5, 0
293 ; CHECK-NEXT: add 3, 3, 4
295 %noty = xor i32 %y, -1
296 %c = icmp ult i32 %x, %noty
297 %s = select i1 %c, i32 %x, i32 %noty
302 define i32 @unsigned_sat_variable_i32_using_cmp_sum(i32 %x, i32 %y) {
303 ; CHECK-LABEL: unsigned_sat_variable_i32_using_cmp_sum:
305 ; CHECK-NEXT: add 4, 3, 4
306 ; CHECK-NEXT: li 5, -1
307 ; CHECK-NEXT: cmplw 0, 4, 3
308 ; CHECK-NEXT: isel 3, 5, 4, 0
311 %c = icmp ugt i32 %x, %a
312 %r = select i1 %c, i32 -1, i32 %a
316 define i32 @unsigned_sat_variable_i32_using_cmp_notval(i32 %x, i32 %y) {
317 ; CHECK-LABEL: unsigned_sat_variable_i32_using_cmp_notval:
319 ; CHECK-NEXT: nor 6, 4, 4
320 ; CHECK-NEXT: li 5, -1
321 ; CHECK-NEXT: cmplw 3, 6
322 ; CHECK-NEXT: add 3, 3, 4
323 ; CHECK-NEXT: isel 3, 5, 3, 1
325 %noty = xor i32 %y, -1
327 %c = icmp ugt i32 %x, %noty
328 %r = select i1 %c, i32 -1, i32 %a
332 define i64 @unsigned_sat_variable_i64_using_min(i64 %x, i64 %y) {
333 ; CHECK-LABEL: unsigned_sat_variable_i64_using_min:
335 ; CHECK-NEXT: not 5, 4
336 ; CHECK-NEXT: cmpld 3, 5
337 ; CHECK-NEXT: isel 3, 3, 5, 0
338 ; CHECK-NEXT: add 3, 3, 4
340 %noty = xor i64 %y, -1
341 %c = icmp ult i64 %x, %noty
342 %s = select i1 %c, i64 %x, i64 %noty
347 define i64 @unsigned_sat_variable_i64_using_cmp_sum(i64 %x, i64 %y) {
348 ; CHECK-LABEL: unsigned_sat_variable_i64_using_cmp_sum:
350 ; CHECK-NEXT: add 4, 3, 4
351 ; CHECK-NEXT: li 5, -1
352 ; CHECK-NEXT: cmpld 4, 3
353 ; CHECK-NEXT: isel 3, 5, 4, 0
356 %c = icmp ugt i64 %x, %a
357 %r = select i1 %c, i64 -1, i64 %a
361 define i64 @unsigned_sat_variable_i64_using_cmp_notval(i64 %x, i64 %y) {
362 ; CHECK-LABEL: unsigned_sat_variable_i64_using_cmp_notval:
364 ; CHECK-NEXT: not 6, 4
365 ; CHECK-NEXT: li 5, -1
366 ; CHECK-NEXT: cmpld 3, 6
367 ; CHECK-NEXT: add 3, 3, 4
368 ; CHECK-NEXT: isel 3, 5, 3, 1
370 %noty = xor i64 %y, -1
372 %c = icmp ugt i64 %x, %noty
373 %r = select i1 %c, i64 -1, i64 %a
377 define <16 x i8> @unsigned_sat_constant_v16i8_using_min(<16 x i8> %x) {
378 ; CHECK-LABEL: unsigned_sat_constant_v16i8_using_min:
380 ; CHECK-NEXT: addis 3, 2, .LCPI24_0@toc@ha
381 ; CHECK-NEXT: addi 3, 3, .LCPI24_0@toc@l
382 ; CHECK-NEXT: lvx 3, 0, 3
383 ; CHECK-NEXT: addis 3, 2, .LCPI24_1@toc@ha
384 ; CHECK-NEXT: addi 3, 3, .LCPI24_1@toc@l
385 ; CHECK-NEXT: vminub 2, 2, 3
386 ; CHECK-NEXT: lvx 3, 0, 3
387 ; CHECK-NEXT: vaddubm 2, 2, 3
389 %c = icmp ult <16 x i8> %x, <i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43>
390 %s = select <16 x i1> %c, <16 x i8> %x, <16 x i8> <i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43>
391 %r = add <16 x i8> %s, <i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42>
395 define <16 x i8> @unsigned_sat_constant_v16i8_using_cmp_sum(<16 x i8> %x) {
396 ; CHECK-LABEL: unsigned_sat_constant_v16i8_using_cmp_sum:
398 ; CHECK-NEXT: addis 3, 2, .LCPI25_0@toc@ha
399 ; CHECK-NEXT: xxleqv 0, 0, 0
400 ; CHECK-NEXT: addi 3, 3, .LCPI25_0@toc@l
401 ; CHECK-NEXT: lvx 3, 0, 3
402 ; CHECK-NEXT: vaddubm 3, 2, 3
403 ; CHECK-NEXT: vcmpgtub 2, 2, 3
404 ; CHECK-NEXT: xxsel 34, 35, 0, 34
406 %a = add <16 x i8> %x, <i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42>
407 %c = icmp ugt <16 x i8> %x, %a
408 %r = select <16 x i1> %c, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, <16 x i8> %a
412 define <16 x i8> @unsigned_sat_constant_v16i8_using_cmp_notval(<16 x i8> %x) {
413 ; CHECK-LABEL: unsigned_sat_constant_v16i8_using_cmp_notval:
415 ; CHECK-NEXT: addis 3, 2, .LCPI26_1@toc@ha
416 ; CHECK-NEXT: xxleqv 0, 0, 0
417 ; CHECK-NEXT: addi 3, 3, .LCPI26_1@toc@l
418 ; CHECK-NEXT: lvx 3, 0, 3
419 ; CHECK-NEXT: addis 3, 2, .LCPI26_0@toc@ha
420 ; CHECK-NEXT: addi 3, 3, .LCPI26_0@toc@l
421 ; CHECK-NEXT: vcmpgtub 3, 2, 3
422 ; CHECK-NEXT: lvx 4, 0, 3
423 ; CHECK-NEXT: vaddubm 2, 2, 4
424 ; CHECK-NEXT: xxsel 34, 34, 0, 35
426 %a = add <16 x i8> %x, <i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42, i8 42>
427 %c = icmp ugt <16 x i8> %x, <i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43, i8 -43>
428 %r = select <16 x i1> %c, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, <16 x i8> %a
432 define <8 x i16> @unsigned_sat_constant_v8i16_using_min(<8 x i16> %x) {
433 ; CHECK-LABEL: unsigned_sat_constant_v8i16_using_min:
435 ; CHECK-NEXT: addis 3, 2, .LCPI27_0@toc@ha
436 ; CHECK-NEXT: addi 3, 3, .LCPI27_0@toc@l
437 ; CHECK-NEXT: lvx 3, 0, 3
438 ; CHECK-NEXT: addis 3, 2, .LCPI27_1@toc@ha
439 ; CHECK-NEXT: addi 3, 3, .LCPI27_1@toc@l
440 ; CHECK-NEXT: vminuh 2, 2, 3
441 ; CHECK-NEXT: lvx 3, 0, 3
442 ; CHECK-NEXT: vadduhm 2, 2, 3
444 %c = icmp ult <8 x i16> %x, <i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43>
445 %s = select <8 x i1> %c, <8 x i16> %x, <8 x i16> <i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43>
446 %r = add <8 x i16> %s, <i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42>
450 define <8 x i16> @unsigned_sat_constant_v8i16_using_cmp_sum(<8 x i16> %x) {
451 ; CHECK-LABEL: unsigned_sat_constant_v8i16_using_cmp_sum:
453 ; CHECK-NEXT: addis 3, 2, .LCPI28_0@toc@ha
454 ; CHECK-NEXT: xxleqv 0, 0, 0
455 ; CHECK-NEXT: addi 3, 3, .LCPI28_0@toc@l
456 ; CHECK-NEXT: lvx 3, 0, 3
457 ; CHECK-NEXT: vadduhm 3, 2, 3
458 ; CHECK-NEXT: vcmpgtuh 2, 2, 3
459 ; CHECK-NEXT: xxsel 34, 35, 0, 34
461 %a = add <8 x i16> %x, <i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42>
462 %c = icmp ugt <8 x i16> %x, %a
463 %r = select <8 x i1> %c, <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>, <8 x i16> %a
467 define <8 x i16> @unsigned_sat_constant_v8i16_using_cmp_notval(<8 x i16> %x) {
468 ; CHECK-LABEL: unsigned_sat_constant_v8i16_using_cmp_notval:
470 ; CHECK-NEXT: addis 3, 2, .LCPI29_1@toc@ha
471 ; CHECK-NEXT: xxleqv 0, 0, 0
472 ; CHECK-NEXT: addi 3, 3, .LCPI29_1@toc@l
473 ; CHECK-NEXT: lvx 3, 0, 3
474 ; CHECK-NEXT: addis 3, 2, .LCPI29_0@toc@ha
475 ; CHECK-NEXT: addi 3, 3, .LCPI29_0@toc@l
476 ; CHECK-NEXT: vcmpgtuh 3, 2, 3
477 ; CHECK-NEXT: lvx 4, 0, 3
478 ; CHECK-NEXT: vadduhm 2, 2, 4
479 ; CHECK-NEXT: xxsel 34, 34, 0, 35
481 %a = add <8 x i16> %x, <i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42>
482 %c = icmp ugt <8 x i16> %x, <i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43>
483 %r = select <8 x i1> %c, <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>, <8 x i16> %a
487 define <4 x i32> @unsigned_sat_constant_v4i32_using_min(<4 x i32> %x) {
488 ; CHECK-LABEL: unsigned_sat_constant_v4i32_using_min:
490 ; CHECK-NEXT: addis 3, 2, .LCPI30_0@toc@ha
491 ; CHECK-NEXT: addi 3, 3, .LCPI30_0@toc@l
492 ; CHECK-NEXT: lvx 3, 0, 3
493 ; CHECK-NEXT: addis 3, 2, .LCPI30_1@toc@ha
494 ; CHECK-NEXT: addi 3, 3, .LCPI30_1@toc@l
495 ; CHECK-NEXT: vminuw 2, 2, 3
496 ; CHECK-NEXT: lvx 3, 0, 3
497 ; CHECK-NEXT: vadduwm 2, 2, 3
499 %c = icmp ult <4 x i32> %x, <i32 -43, i32 -43, i32 -43, i32 -43>
500 %s = select <4 x i1> %c, <4 x i32> %x, <4 x i32> <i32 -43, i32 -43, i32 -43, i32 -43>
501 %r = add <4 x i32> %s, <i32 42, i32 42, i32 42, i32 42>
505 define <4 x i32> @unsigned_sat_constant_v4i32_using_cmp_sum(<4 x i32> %x) {
506 ; CHECK-LABEL: unsigned_sat_constant_v4i32_using_cmp_sum:
508 ; CHECK-NEXT: addis 3, 2, .LCPI31_0@toc@ha
509 ; CHECK-NEXT: xxleqv 0, 0, 0
510 ; CHECK-NEXT: addi 3, 3, .LCPI31_0@toc@l
511 ; CHECK-NEXT: lvx 3, 0, 3
512 ; CHECK-NEXT: vadduwm 3, 2, 3
513 ; CHECK-NEXT: vcmpgtuw 2, 2, 3
514 ; CHECK-NEXT: xxsel 34, 35, 0, 34
516 %a = add <4 x i32> %x, <i32 42, i32 42, i32 42, i32 42>
517 %c = icmp ugt <4 x i32> %x, %a
518 %r = select <4 x i1> %c, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> %a
522 define <4 x i32> @unsigned_sat_constant_v4i32_using_cmp_notval(<4 x i32> %x) {
523 ; CHECK-LABEL: unsigned_sat_constant_v4i32_using_cmp_notval:
525 ; CHECK-NEXT: addis 3, 2, .LCPI32_1@toc@ha
526 ; CHECK-NEXT: xxleqv 0, 0, 0
527 ; CHECK-NEXT: addi 3, 3, .LCPI32_1@toc@l
528 ; CHECK-NEXT: lvx 3, 0, 3
529 ; CHECK-NEXT: addis 3, 2, .LCPI32_0@toc@ha
530 ; CHECK-NEXT: addi 3, 3, .LCPI32_0@toc@l
531 ; CHECK-NEXT: vcmpgtuw 3, 2, 3
532 ; CHECK-NEXT: lvx 4, 0, 3
533 ; CHECK-NEXT: vadduwm 2, 2, 4
534 ; CHECK-NEXT: xxsel 34, 34, 0, 35
536 %a = add <4 x i32> %x, <i32 42, i32 42, i32 42, i32 42>
537 %c = icmp ugt <4 x i32> %x, <i32 -43, i32 -43, i32 -43, i32 -43>
538 %r = select <4 x i1> %c, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> %a
542 define <2 x i64> @unsigned_sat_constant_v2i64_using_min(<2 x i64> %x) {
543 ; CHECK-LABEL: unsigned_sat_constant_v2i64_using_min:
545 ; CHECK-NEXT: addis 3, 2, .LCPI33_0@toc@ha
546 ; CHECK-NEXT: addi 3, 3, .LCPI33_0@toc@l
547 ; CHECK-NEXT: lxvd2x 0, 0, 3
548 ; CHECK-NEXT: addis 3, 2, .LCPI33_1@toc@ha
549 ; CHECK-NEXT: addi 3, 3, .LCPI33_1@toc@l
550 ; CHECK-NEXT: xxswapd 35, 0
551 ; CHECK-NEXT: lxvd2x 0, 0, 3
552 ; CHECK-NEXT: vminud 2, 2, 3
553 ; CHECK-NEXT: xxswapd 35, 0
554 ; CHECK-NEXT: vaddudm 2, 2, 3
556 %c = icmp ult <2 x i64> %x, <i64 -43, i64 -43>
557 %s = select <2 x i1> %c, <2 x i64> %x, <2 x i64> <i64 -43, i64 -43>
558 %r = add <2 x i64> %s, <i64 42, i64 42>
562 define <2 x i64> @unsigned_sat_constant_v2i64_using_cmp_sum(<2 x i64> %x) {
563 ; CHECK-LABEL: unsigned_sat_constant_v2i64_using_cmp_sum:
565 ; CHECK-NEXT: addis 3, 2, .LCPI34_0@toc@ha
566 ; CHECK-NEXT: addi 3, 3, .LCPI34_0@toc@l
567 ; CHECK-NEXT: lxvd2x 0, 0, 3
568 ; CHECK-NEXT: xxswapd 35, 0
569 ; CHECK-NEXT: xxleqv 0, 0, 0
570 ; CHECK-NEXT: vaddudm 3, 2, 3
571 ; CHECK-NEXT: vcmpgtud 2, 2, 3
572 ; CHECK-NEXT: xxsel 34, 35, 0, 34
574 %a = add <2 x i64> %x, <i64 42, i64 42>
575 %c = icmp ugt <2 x i64> %x, %a
576 %r = select <2 x i1> %c, <2 x i64> <i64 -1, i64 -1>, <2 x i64> %a
580 define <2 x i64> @unsigned_sat_constant_v2i64_using_cmp_notval(<2 x i64> %x) {
581 ; CHECK-LABEL: unsigned_sat_constant_v2i64_using_cmp_notval:
583 ; CHECK-NEXT: addis 3, 2, .LCPI35_1@toc@ha
584 ; CHECK-NEXT: addi 3, 3, .LCPI35_1@toc@l
585 ; CHECK-NEXT: lxvd2x 0, 0, 3
586 ; CHECK-NEXT: addis 3, 2, .LCPI35_0@toc@ha
587 ; CHECK-NEXT: addi 3, 3, .LCPI35_0@toc@l
588 ; CHECK-NEXT: lxvd2x 1, 0, 3
589 ; CHECK-NEXT: xxswapd 35, 0
590 ; CHECK-NEXT: xxleqv 0, 0, 0
591 ; CHECK-NEXT: xxswapd 36, 1
592 ; CHECK-NEXT: vcmpgtud 3, 2, 3
593 ; CHECK-NEXT: vaddudm 2, 2, 4
594 ; CHECK-NEXT: xxsel 34, 34, 0, 35
596 %a = add <2 x i64> %x, <i64 42, i64 42>
597 %c = icmp ugt <2 x i64> %x, <i64 -43, i64 -43>
598 %r = select <2 x i1> %c, <2 x i64> <i64 -1, i64 -1>, <2 x i64> %a
602 define <16 x i8> @unsigned_sat_variable_v16i8_using_min(<16 x i8> %x, <16 x i8> %y) {
603 ; CHECK-LABEL: unsigned_sat_variable_v16i8_using_min:
605 ; CHECK-NEXT: xxlnor 36, 35, 35
606 ; CHECK-NEXT: vminub 2, 2, 4
607 ; CHECK-NEXT: vaddubm 2, 2, 3
609 %noty = xor <16 x i8> %y, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
610 %c = icmp ult <16 x i8> %x, %noty
611 %s = select <16 x i1> %c, <16 x i8> %x, <16 x i8> %noty
612 %r = add <16 x i8> %s, %y
616 define <16 x i8> @unsigned_sat_variable_v16i8_using_cmp_sum(<16 x i8> %x, <16 x i8> %y) {
617 ; CHECK-LABEL: unsigned_sat_variable_v16i8_using_cmp_sum:
619 ; CHECK-NEXT: vaddubm 3, 2, 3
620 ; CHECK-NEXT: xxleqv 0, 0, 0
621 ; CHECK-NEXT: vcmpgtub 2, 2, 3
622 ; CHECK-NEXT: xxsel 34, 35, 0, 34
624 %a = add <16 x i8> %x, %y
625 %c = icmp ugt <16 x i8> %x, %a
626 %r = select <16 x i1> %c, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, <16 x i8> %a
630 define <16 x i8> @unsigned_sat_variable_v16i8_using_cmp_notval(<16 x i8> %x, <16 x i8> %y) {
631 ; CHECK-LABEL: unsigned_sat_variable_v16i8_using_cmp_notval:
633 ; CHECK-NEXT: xxlnor 36, 35, 35
634 ; CHECK-NEXT: xxleqv 0, 0, 0
635 ; CHECK-NEXT: vcmpgtub 4, 2, 4
636 ; CHECK-NEXT: vaddubm 2, 2, 3
637 ; CHECK-NEXT: xxsel 34, 34, 0, 36
639 %noty = xor <16 x i8> %y, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
640 %a = add <16 x i8> %x, %y
641 %c = icmp ugt <16 x i8> %x, %noty
642 %r = select <16 x i1> %c, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>, <16 x i8> %a
646 define <8 x i16> @unsigned_sat_variable_v8i16_using_min(<8 x i16> %x, <8 x i16> %y) {
647 ; CHECK-LABEL: unsigned_sat_variable_v8i16_using_min:
649 ; CHECK-NEXT: xxlnor 36, 35, 35
650 ; CHECK-NEXT: vminuh 2, 2, 4
651 ; CHECK-NEXT: vadduhm 2, 2, 3
653 %noty = xor <8 x i16> %y, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
654 %c = icmp ult <8 x i16> %x, %noty
655 %s = select <8 x i1> %c, <8 x i16> %x, <8 x i16> %noty
656 %r = add <8 x i16> %s, %y
660 define <8 x i16> @unsigned_sat_variable_v8i16_using_cmp_sum(<8 x i16> %x, <8 x i16> %y) {
661 ; CHECK-LABEL: unsigned_sat_variable_v8i16_using_cmp_sum:
663 ; CHECK-NEXT: vadduhm 3, 2, 3
664 ; CHECK-NEXT: xxleqv 0, 0, 0
665 ; CHECK-NEXT: vcmpgtuh 2, 2, 3
666 ; CHECK-NEXT: xxsel 34, 35, 0, 34
668 %a = add <8 x i16> %x, %y
669 %c = icmp ugt <8 x i16> %x, %a
670 %r = select <8 x i1> %c, <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>, <8 x i16> %a
674 define <8 x i16> @unsigned_sat_variable_v8i16_using_cmp_notval(<8 x i16> %x, <8 x i16> %y) {
675 ; CHECK-LABEL: unsigned_sat_variable_v8i16_using_cmp_notval:
677 ; CHECK-NEXT: xxlnor 36, 35, 35
678 ; CHECK-NEXT: xxleqv 0, 0, 0
679 ; CHECK-NEXT: vcmpgtuh 4, 2, 4
680 ; CHECK-NEXT: vadduhm 2, 2, 3
681 ; CHECK-NEXT: xxsel 34, 34, 0, 36
683 %noty = xor <8 x i16> %y, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
684 %a = add <8 x i16> %x, %y
685 %c = icmp ugt <8 x i16> %x, %noty
686 %r = select <8 x i1> %c, <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>, <8 x i16> %a
690 define <4 x i32> @unsigned_sat_variable_v4i32_using_min(<4 x i32> %x, <4 x i32> %y) {
691 ; CHECK-LABEL: unsigned_sat_variable_v4i32_using_min:
693 ; CHECK-NEXT: xxlnor 36, 35, 35
694 ; CHECK-NEXT: vminuw 2, 2, 4
695 ; CHECK-NEXT: vadduwm 2, 2, 3
697 %noty = xor <4 x i32> %y, <i32 -1, i32 -1, i32 -1, i32 -1>
698 %c = icmp ult <4 x i32> %x, %noty
699 %s = select <4 x i1> %c, <4 x i32> %x, <4 x i32> %noty
700 %r = add <4 x i32> %s, %y
704 define <4 x i32> @unsigned_sat_variable_v4i32_using_cmp_sum(<4 x i32> %x, <4 x i32> %y) {
705 ; CHECK-LABEL: unsigned_sat_variable_v4i32_using_cmp_sum:
707 ; CHECK-NEXT: vadduwm 3, 2, 3
708 ; CHECK-NEXT: xxleqv 0, 0, 0
709 ; CHECK-NEXT: vcmpgtuw 2, 2, 3
710 ; CHECK-NEXT: xxsel 34, 35, 0, 34
712 %a = add <4 x i32> %x, %y
713 %c = icmp ugt <4 x i32> %x, %a
714 %r = select <4 x i1> %c, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> %a
718 define <4 x i32> @unsigned_sat_variable_v4i32_using_cmp_notval(<4 x i32> %x, <4 x i32> %y) {
719 ; CHECK-LABEL: unsigned_sat_variable_v4i32_using_cmp_notval:
721 ; CHECK-NEXT: xxlnor 36, 35, 35
722 ; CHECK-NEXT: xxleqv 0, 0, 0
723 ; CHECK-NEXT: vcmpgtuw 4, 2, 4
724 ; CHECK-NEXT: vadduwm 2, 2, 3
725 ; CHECK-NEXT: xxsel 34, 34, 0, 36
727 %noty = xor <4 x i32> %y, <i32 -1, i32 -1, i32 -1, i32 -1>
728 %a = add <4 x i32> %x, %y
729 %c = icmp ugt <4 x i32> %x, %noty
730 %r = select <4 x i1> %c, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> %a
734 define <2 x i64> @unsigned_sat_variable_v2i64_using_min(<2 x i64> %x, <2 x i64> %y) {
735 ; CHECK-LABEL: unsigned_sat_variable_v2i64_using_min:
737 ; CHECK-NEXT: xxlnor 36, 35, 35
738 ; CHECK-NEXT: vminud 2, 2, 4
739 ; CHECK-NEXT: vaddudm 2, 2, 3
741 %noty = xor <2 x i64> %y, <i64 -1, i64 -1>
742 %c = icmp ult <2 x i64> %x, %noty
743 %s = select <2 x i1> %c, <2 x i64> %x, <2 x i64> %noty
744 %r = add <2 x i64> %s, %y
748 define <2 x i64> @unsigned_sat_variable_v2i64_using_cmp_sum(<2 x i64> %x, <2 x i64> %y) {
749 ; CHECK-LABEL: unsigned_sat_variable_v2i64_using_cmp_sum:
751 ; CHECK-NEXT: vaddudm 3, 2, 3
752 ; CHECK-NEXT: xxleqv 0, 0, 0
753 ; CHECK-NEXT: vcmpgtud 2, 2, 3
754 ; CHECK-NEXT: xxsel 34, 35, 0, 34
756 %a = add <2 x i64> %x, %y
757 %c = icmp ugt <2 x i64> %x, %a
758 %r = select <2 x i1> %c, <2 x i64> <i64 -1, i64 -1>, <2 x i64> %a
762 define <2 x i64> @unsigned_sat_variable_v2i64_using_cmp_notval(<2 x i64> %x, <2 x i64> %y) {
763 ; CHECK-LABEL: unsigned_sat_variable_v2i64_using_cmp_notval:
765 ; CHECK-NEXT: xxlnor 36, 35, 35
766 ; CHECK-NEXT: xxleqv 0, 0, 0
767 ; CHECK-NEXT: vcmpgtud 4, 2, 4
768 ; CHECK-NEXT: vaddudm 2, 2, 3
769 ; CHECK-NEXT: xxsel 34, 34, 0, 36
771 %noty = xor <2 x i64> %y, <i64 -1, i64 -1>
772 %a = add <2 x i64> %x, %y
773 %c = icmp ugt <2 x i64> %x, %noty
774 %r = select <2 x i1> %c, <2 x i64> <i64 -1, i64 -1>, <2 x i64> %a