1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse2 | FileCheck %s --check-prefixes=ANY,SSE,SSE2
3 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+sse4.1 | FileCheck %s --check-prefixes=ANY,SSE,SSE41
5 ; There are at least 3 potential patterns corresponding to an unsigned saturated add: min, cmp with sum, cmp with not.
6 ; Test each of those patterns with i8/i16/i32/i64.
7 ; Test each of those with a constant operand and a variable operand.
8 ; Test each of those with a 128-bit vector type.
10 define i8 @unsigned_sat_constant_i8_using_min(i8 %x) {
11 ; ANY-LABEL: unsigned_sat_constant_i8_using_min:
13 ; ANY-NEXT: cmpb $-43, %dil
14 ; ANY-NEXT: movl $213, %eax
15 ; ANY-NEXT: cmovbl %edi, %eax
16 ; ANY-NEXT: addb $42, %al
17 ; ANY-NEXT: # kill: def $al killed $al killed $eax
19 %c = icmp ult i8 %x, -43
20 %s = select i1 %c, i8 %x, i8 -43
25 define i8 @unsigned_sat_constant_i8_using_cmp_sum(i8 %x) {
26 ; ANY-LABEL: unsigned_sat_constant_i8_using_cmp_sum:
28 ; ANY-NEXT: addb $42, %dil
29 ; ANY-NEXT: movzbl %dil, %ecx
30 ; ANY-NEXT: movl $255, %eax
31 ; ANY-NEXT: cmovael %ecx, %eax
32 ; ANY-NEXT: # kill: def $al killed $al killed $eax
35 %c = icmp ugt i8 %x, %a
36 %r = select i1 %c, i8 -1, i8 %a
40 define i8 @unsigned_sat_constant_i8_using_cmp_notval(i8 %x) {
41 ; ANY-LABEL: unsigned_sat_constant_i8_using_cmp_notval:
43 ; ANY-NEXT: addb $42, %dil
44 ; ANY-NEXT: movzbl %dil, %ecx
45 ; ANY-NEXT: movl $255, %eax
46 ; ANY-NEXT: cmovael %ecx, %eax
47 ; ANY-NEXT: # kill: def $al killed $al killed $eax
50 %c = icmp ugt i8 %x, -43
51 %r = select i1 %c, i8 -1, i8 %a
55 define i16 @unsigned_sat_constant_i16_using_min(i16 %x) {
56 ; ANY-LABEL: unsigned_sat_constant_i16_using_min:
58 ; ANY-NEXT: cmpw $-43, %di
59 ; ANY-NEXT: movl $65493, %eax # imm = 0xFFD5
60 ; ANY-NEXT: cmovbl %edi, %eax
61 ; ANY-NEXT: addl $42, %eax
62 ; ANY-NEXT: # kill: def $ax killed $ax killed $eax
64 %c = icmp ult i16 %x, -43
65 %s = select i1 %c, i16 %x, i16 -43
70 define i16 @unsigned_sat_constant_i16_using_cmp_sum(i16 %x) {
71 ; ANY-LABEL: unsigned_sat_constant_i16_using_cmp_sum:
73 ; ANY-NEXT: addw $42, %di
74 ; ANY-NEXT: movl $65535, %eax # imm = 0xFFFF
75 ; ANY-NEXT: cmovael %edi, %eax
76 ; ANY-NEXT: # kill: def $ax killed $ax killed $eax
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 ; ANY-LABEL: unsigned_sat_constant_i16_using_cmp_notval:
87 ; ANY-NEXT: addw $42, %di
88 ; ANY-NEXT: movl $65535, %eax # imm = 0xFFFF
89 ; ANY-NEXT: cmovael %edi, %eax
90 ; ANY-NEXT: # kill: def $ax killed $ax killed $eax
93 %c = icmp ugt i16 %x, -43
94 %r = select i1 %c, i16 -1, i16 %a
98 define i32 @unsigned_sat_constant_i32_using_min(i32 %x) {
99 ; ANY-LABEL: unsigned_sat_constant_i32_using_min:
101 ; ANY-NEXT: cmpl $-43, %edi
102 ; ANY-NEXT: movl $-43, %eax
103 ; ANY-NEXT: cmovbl %edi, %eax
104 ; ANY-NEXT: addl $42, %eax
106 %c = icmp ult i32 %x, -43
107 %s = select i1 %c, i32 %x, i32 -43
112 define i32 @unsigned_sat_constant_i32_using_cmp_sum(i32 %x) {
113 ; ANY-LABEL: unsigned_sat_constant_i32_using_cmp_sum:
115 ; ANY-NEXT: addl $42, %edi
116 ; ANY-NEXT: movl $-1, %eax
117 ; ANY-NEXT: cmovael %edi, %eax
120 %c = icmp ugt i32 %x, %a
121 %r = select i1 %c, i32 -1, i32 %a
125 define i32 @unsigned_sat_constant_i32_using_cmp_notval(i32 %x) {
126 ; ANY-LABEL: unsigned_sat_constant_i32_using_cmp_notval:
128 ; ANY-NEXT: addl $42, %edi
129 ; ANY-NEXT: movl $-1, %eax
130 ; ANY-NEXT: cmovael %edi, %eax
133 %c = icmp ugt i32 %x, -43
134 %r = select i1 %c, i32 -1, i32 %a
138 define i64 @unsigned_sat_constant_i64_using_min(i64 %x) {
139 ; ANY-LABEL: unsigned_sat_constant_i64_using_min:
141 ; ANY-NEXT: cmpq $-43, %rdi
142 ; ANY-NEXT: movq $-43, %rax
143 ; ANY-NEXT: cmovbq %rdi, %rax
144 ; ANY-NEXT: addq $42, %rax
146 %c = icmp ult i64 %x, -43
147 %s = select i1 %c, i64 %x, i64 -43
152 define i64 @unsigned_sat_constant_i64_using_cmp_sum(i64 %x) {
153 ; ANY-LABEL: unsigned_sat_constant_i64_using_cmp_sum:
155 ; ANY-NEXT: addq $42, %rdi
156 ; ANY-NEXT: movq $-1, %rax
157 ; ANY-NEXT: cmovaeq %rdi, %rax
160 %c = icmp ugt i64 %x, %a
161 %r = select i1 %c, i64 -1, i64 %a
165 define i64 @unsigned_sat_constant_i64_using_cmp_notval(i64 %x) {
166 ; ANY-LABEL: unsigned_sat_constant_i64_using_cmp_notval:
168 ; ANY-NEXT: addq $42, %rdi
169 ; ANY-NEXT: movq $-1, %rax
170 ; ANY-NEXT: cmovaeq %rdi, %rax
173 %c = icmp ugt i64 %x, -43
174 %r = select i1 %c, i64 -1, i64 %a
178 define i8 @unsigned_sat_variable_i8_using_min(i8 %x, i8 %y) {
179 ; ANY-LABEL: unsigned_sat_variable_i8_using_min:
181 ; ANY-NEXT: movl %esi, %eax
183 ; ANY-NEXT: cmpb %al, %dil
184 ; ANY-NEXT: movzbl %al, %eax
185 ; ANY-NEXT: cmovbl %edi, %eax
186 ; ANY-NEXT: addb %sil, %al
187 ; ANY-NEXT: # kill: def $al killed $al killed $eax
189 %noty = xor i8 %y, -1
190 %c = icmp ult i8 %x, %noty
191 %s = select i1 %c, i8 %x, i8 %noty
196 define i8 @unsigned_sat_variable_i8_using_cmp_sum(i8 %x, i8 %y) {
197 ; ANY-LABEL: unsigned_sat_variable_i8_using_cmp_sum:
199 ; ANY-NEXT: addb %sil, %dil
200 ; ANY-NEXT: movzbl %dil, %ecx
201 ; ANY-NEXT: movl $255, %eax
202 ; ANY-NEXT: cmovael %ecx, %eax
203 ; ANY-NEXT: # kill: def $al killed $al killed $eax
206 %c = icmp ugt i8 %x, %a
207 %r = select i1 %c, i8 -1, i8 %a
211 define i8 @unsigned_sat_variable_i8_using_cmp_notval(i8 %x, i8 %y) {
212 ; ANY-LABEL: unsigned_sat_variable_i8_using_cmp_notval:
214 ; ANY-NEXT: # kill: def $esi killed $esi def $rsi
215 ; ANY-NEXT: # kill: def $edi killed $edi def $rdi
216 ; ANY-NEXT: leal (%rdi,%rsi), %eax
217 ; ANY-NEXT: notb %sil
218 ; ANY-NEXT: cmpb %sil, %dil
219 ; ANY-NEXT: movzbl %al, %ecx
220 ; ANY-NEXT: movl $255, %eax
221 ; ANY-NEXT: cmovbel %ecx, %eax
222 ; ANY-NEXT: # kill: def $al killed $al killed $eax
224 %noty = xor i8 %y, -1
226 %c = icmp ugt i8 %x, %noty
227 %r = select i1 %c, i8 -1, i8 %a
231 define i16 @unsigned_sat_variable_i16_using_min(i16 %x, i16 %y) {
232 ; ANY-LABEL: unsigned_sat_variable_i16_using_min:
234 ; ANY-NEXT: # kill: def $esi killed $esi def $rsi
235 ; ANY-NEXT: movl %esi, %eax
236 ; ANY-NEXT: notl %eax
237 ; ANY-NEXT: cmpw %ax, %di
238 ; ANY-NEXT: cmovbl %edi, %eax
239 ; ANY-NEXT: addl %esi, %eax
240 ; ANY-NEXT: # kill: def $ax killed $ax killed $eax
242 %noty = xor i16 %y, -1
243 %c = icmp ult i16 %x, %noty
244 %s = select i1 %c, i16 %x, i16 %noty
249 define i16 @unsigned_sat_variable_i16_using_cmp_sum(i16 %x, i16 %y) {
250 ; ANY-LABEL: unsigned_sat_variable_i16_using_cmp_sum:
252 ; ANY-NEXT: addw %si, %di
253 ; ANY-NEXT: movl $65535, %eax # imm = 0xFFFF
254 ; ANY-NEXT: cmovael %edi, %eax
255 ; ANY-NEXT: # kill: def $ax killed $ax killed $eax
258 %c = icmp ugt i16 %x, %a
259 %r = select i1 %c, i16 -1, i16 %a
263 define i16 @unsigned_sat_variable_i16_using_cmp_notval(i16 %x, i16 %y) {
264 ; ANY-LABEL: unsigned_sat_variable_i16_using_cmp_notval:
266 ; ANY-NEXT: # kill: def $esi killed $esi def $rsi
267 ; ANY-NEXT: # kill: def $edi killed $edi def $rdi
268 ; ANY-NEXT: leal (%rdi,%rsi), %ecx
269 ; ANY-NEXT: notl %esi
270 ; ANY-NEXT: cmpw %si, %di
271 ; ANY-NEXT: movl $65535, %eax # imm = 0xFFFF
272 ; ANY-NEXT: cmovbel %ecx, %eax
273 ; ANY-NEXT: # kill: def $ax killed $ax killed $eax
275 %noty = xor i16 %y, -1
277 %c = icmp ugt i16 %x, %noty
278 %r = select i1 %c, i16 -1, i16 %a
282 define i32 @unsigned_sat_variable_i32_using_min(i32 %x, i32 %y) {
283 ; ANY-LABEL: unsigned_sat_variable_i32_using_min:
285 ; ANY-NEXT: # kill: def $esi killed $esi def $rsi
286 ; ANY-NEXT: movl %esi, %eax
287 ; ANY-NEXT: notl %eax
288 ; ANY-NEXT: cmpl %eax, %edi
289 ; ANY-NEXT: cmovbl %edi, %eax
290 ; ANY-NEXT: addl %esi, %eax
292 %noty = xor i32 %y, -1
293 %c = icmp ult i32 %x, %noty
294 %s = select i1 %c, i32 %x, i32 %noty
299 define i32 @unsigned_sat_variable_i32_using_cmp_sum(i32 %x, i32 %y) {
300 ; ANY-LABEL: unsigned_sat_variable_i32_using_cmp_sum:
302 ; ANY-NEXT: addl %esi, %edi
303 ; ANY-NEXT: movl $-1, %eax
304 ; ANY-NEXT: cmovael %edi, %eax
307 %c = icmp ugt i32 %x, %a
308 %r = select i1 %c, i32 -1, i32 %a
312 define i32 @unsigned_sat_variable_i32_using_cmp_notval(i32 %x, i32 %y) {
313 ; ANY-LABEL: unsigned_sat_variable_i32_using_cmp_notval:
315 ; ANY-NEXT: # kill: def $esi killed $esi def $rsi
316 ; ANY-NEXT: # kill: def $edi killed $edi def $rdi
317 ; ANY-NEXT: leal (%rdi,%rsi), %ecx
318 ; ANY-NEXT: notl %esi
319 ; ANY-NEXT: cmpl %esi, %edi
320 ; ANY-NEXT: movl $-1, %eax
321 ; ANY-NEXT: cmovbel %ecx, %eax
323 %noty = xor i32 %y, -1
325 %c = icmp ugt i32 %x, %noty
326 %r = select i1 %c, i32 -1, i32 %a
330 define i64 @unsigned_sat_variable_i64_using_min(i64 %x, i64 %y) {
331 ; ANY-LABEL: unsigned_sat_variable_i64_using_min:
333 ; ANY-NEXT: movq %rsi, %rax
334 ; ANY-NEXT: notq %rax
335 ; ANY-NEXT: cmpq %rax, %rdi
336 ; ANY-NEXT: cmovbq %rdi, %rax
337 ; ANY-NEXT: addq %rsi, %rax
339 %noty = xor i64 %y, -1
340 %c = icmp ult i64 %x, %noty
341 %s = select i1 %c, i64 %x, i64 %noty
346 define i64 @unsigned_sat_variable_i64_using_cmp_sum(i64 %x, i64 %y) {
347 ; ANY-LABEL: unsigned_sat_variable_i64_using_cmp_sum:
349 ; ANY-NEXT: addq %rsi, %rdi
350 ; ANY-NEXT: movq $-1, %rax
351 ; ANY-NEXT: cmovaeq %rdi, %rax
354 %c = icmp ugt i64 %x, %a
355 %r = select i1 %c, i64 -1, i64 %a
359 define i64 @unsigned_sat_variable_i64_using_cmp_notval(i64 %x, i64 %y) {
360 ; ANY-LABEL: unsigned_sat_variable_i64_using_cmp_notval:
362 ; ANY-NEXT: leaq (%rdi,%rsi), %rcx
363 ; ANY-NEXT: notq %rsi
364 ; ANY-NEXT: cmpq %rsi, %rdi
365 ; ANY-NEXT: movq $-1, %rax
366 ; ANY-NEXT: cmovbeq %rcx, %rax
368 %noty = xor i64 %y, -1
370 %c = icmp ugt i64 %x, %noty
371 %r = select i1 %c, i64 -1, i64 %a
375 define <16 x i8> @unsigned_sat_constant_v16i8_using_min(<16 x i8> %x) {
376 ; ANY-LABEL: unsigned_sat_constant_v16i8_using_min:
378 ; ANY-NEXT: pminub {{.*}}(%rip), %xmm0
379 ; ANY-NEXT: paddb {{.*}}(%rip), %xmm0
381 %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>
382 %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>
383 %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>
387 define <16 x i8> @unsigned_sat_constant_v16i8_using_cmp_sum(<16 x i8> %x) {
388 ; ANY-LABEL: unsigned_sat_constant_v16i8_using_cmp_sum:
390 ; ANY-NEXT: paddusb {{.*}}(%rip), %xmm0
392 %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>
393 %c = icmp ugt <16 x i8> %x, %a
394 %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
398 define <16 x i8> @unsigned_sat_constant_v16i8_using_cmp_notval(<16 x i8> %x) {
399 ; ANY-LABEL: unsigned_sat_constant_v16i8_using_cmp_notval:
401 ; ANY-NEXT: paddusb {{.*}}(%rip), %xmm0
403 %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>
404 %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>
405 %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
409 define <8 x i16> @unsigned_sat_constant_v8i16_using_min(<8 x i16> %x) {
410 ; SSE2-LABEL: unsigned_sat_constant_v8i16_using_min:
412 ; SSE2-NEXT: movdqa {{.*#+}} xmm1 = [32768,32768,32768,32768,32768,32768,32768,32768]
413 ; SSE2-NEXT: pxor %xmm1, %xmm0
414 ; SSE2-NEXT: pminsw {{.*}}(%rip), %xmm0
415 ; SSE2-NEXT: pxor %xmm1, %xmm0
416 ; SSE2-NEXT: paddw {{.*}}(%rip), %xmm0
419 ; SSE41-LABEL: unsigned_sat_constant_v8i16_using_min:
421 ; SSE41-NEXT: pminuw {{.*}}(%rip), %xmm0
422 ; SSE41-NEXT: paddw {{.*}}(%rip), %xmm0
424 %c = icmp ult <8 x i16> %x, <i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43>
425 %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>
426 %r = add <8 x i16> %s, <i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42>
430 define <8 x i16> @unsigned_sat_constant_v8i16_using_cmp_sum(<8 x i16> %x) {
431 ; ANY-LABEL: unsigned_sat_constant_v8i16_using_cmp_sum:
433 ; ANY-NEXT: paddusw {{.*}}(%rip), %xmm0
435 %a = add <8 x i16> %x, <i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42>
436 %c = icmp ugt <8 x i16> %x, %a
437 %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
441 define <8 x i16> @unsigned_sat_constant_v8i16_using_cmp_notval(<8 x i16> %x) {
442 ; ANY-LABEL: unsigned_sat_constant_v8i16_using_cmp_notval:
444 ; ANY-NEXT: paddusw {{.*}}(%rip), %xmm0
446 %a = add <8 x i16> %x, <i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42, i16 42>
447 %c = icmp ugt <8 x i16> %x, <i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43, i16 -43>
448 %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
452 define <4 x i32> @unsigned_sat_constant_v4i32_using_min(<4 x i32> %x) {
453 ; SSE2-LABEL: unsigned_sat_constant_v4i32_using_min:
455 ; SSE2-NEXT: movdqa {{.*#+}} xmm1 = [2147483648,2147483648,2147483648,2147483648]
456 ; SSE2-NEXT: pxor %xmm0, %xmm1
457 ; SSE2-NEXT: movdqa {{.*#+}} xmm2 = [2147483605,2147483605,2147483605,2147483605]
458 ; SSE2-NEXT: pcmpgtd %xmm1, %xmm2
459 ; SSE2-NEXT: pand %xmm2, %xmm0
460 ; SSE2-NEXT: pandn {{.*}}(%rip), %xmm2
461 ; SSE2-NEXT: por %xmm2, %xmm0
462 ; SSE2-NEXT: paddd {{.*}}(%rip), %xmm0
465 ; SSE41-LABEL: unsigned_sat_constant_v4i32_using_min:
467 ; SSE41-NEXT: pminud {{.*}}(%rip), %xmm0
468 ; SSE41-NEXT: paddd {{.*}}(%rip), %xmm0
470 %c = icmp ult <4 x i32> %x, <i32 -43, i32 -43, i32 -43, i32 -43>
471 %s = select <4 x i1> %c, <4 x i32> %x, <4 x i32> <i32 -43, i32 -43, i32 -43, i32 -43>
472 %r = add <4 x i32> %s, <i32 42, i32 42, i32 42, i32 42>
476 define <4 x i32> @unsigned_sat_constant_v4i32_using_cmp_sum(<4 x i32> %x) {
477 ; SSE2-LABEL: unsigned_sat_constant_v4i32_using_cmp_sum:
479 ; SSE2-NEXT: movdqa {{.*#+}} xmm1 = [42,42,42,42]
480 ; SSE2-NEXT: paddd %xmm0, %xmm1
481 ; SSE2-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648]
482 ; SSE2-NEXT: pxor %xmm2, %xmm0
483 ; SSE2-NEXT: pxor %xmm1, %xmm2
484 ; SSE2-NEXT: pcmpgtd %xmm2, %xmm0
485 ; SSE2-NEXT: por %xmm1, %xmm0
488 ; SSE41-LABEL: unsigned_sat_constant_v4i32_using_cmp_sum:
490 ; SSE41-NEXT: movdqa {{.*#+}} xmm2 = [42,42,42,42]
491 ; SSE41-NEXT: paddd %xmm0, %xmm2
492 ; SSE41-NEXT: movdqa %xmm0, %xmm1
493 ; SSE41-NEXT: pminud %xmm2, %xmm1
494 ; SSE41-NEXT: pcmpeqd %xmm0, %xmm1
495 ; SSE41-NEXT: pcmpeqd %xmm0, %xmm0
496 ; SSE41-NEXT: pxor %xmm0, %xmm1
497 ; SSE41-NEXT: por %xmm2, %xmm1
498 ; SSE41-NEXT: movdqa %xmm1, %xmm0
500 %a = add <4 x i32> %x, <i32 42, i32 42, i32 42, i32 42>
501 %c = icmp ugt <4 x i32> %x, %a
502 %r = select <4 x i1> %c, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> %a
506 define <4 x i32> @unsigned_sat_constant_v4i32_using_cmp_notval(<4 x i32> %x) {
507 ; SSE2-LABEL: unsigned_sat_constant_v4i32_using_cmp_notval:
509 ; SSE2-NEXT: movdqa {{.*#+}} xmm1 = [42,42,42,42]
510 ; SSE2-NEXT: paddd %xmm0, %xmm1
511 ; SSE2-NEXT: pxor {{.*}}(%rip), %xmm0
512 ; SSE2-NEXT: pcmpgtd {{.*}}(%rip), %xmm0
513 ; SSE2-NEXT: por %xmm1, %xmm0
516 ; SSE41-LABEL: unsigned_sat_constant_v4i32_using_cmp_notval:
518 ; SSE41-NEXT: movdqa {{.*#+}} xmm1 = [42,42,42,42]
519 ; SSE41-NEXT: paddd %xmm0, %xmm1
520 ; SSE41-NEXT: movdqa {{.*#+}} xmm2 = [4294967254,4294967254,4294967254,4294967254]
521 ; SSE41-NEXT: pmaxud %xmm0, %xmm2
522 ; SSE41-NEXT: pcmpeqd %xmm2, %xmm0
523 ; SSE41-NEXT: por %xmm1, %xmm0
525 %a = add <4 x i32> %x, <i32 42, i32 42, i32 42, i32 42>
526 %c = icmp ugt <4 x i32> %x, <i32 -43, i32 -43, i32 -43, i32 -43>
527 %r = select <4 x i1> %c, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> %a
531 define <4 x i32> @unsigned_sat_constant_v4i32_using_cmp_notval_nonsplat(<4 x i32> %x) {
532 ; SSE2-LABEL: unsigned_sat_constant_v4i32_using_cmp_notval_nonsplat:
534 ; SSE2-NEXT: movdqa {{.*#+}} xmm1 = [43,44,45,46]
535 ; SSE2-NEXT: paddd %xmm0, %xmm1
536 ; SSE2-NEXT: pxor {{.*}}(%rip), %xmm0
537 ; SSE2-NEXT: pcmpgtd {{.*}}(%rip), %xmm0
538 ; SSE2-NEXT: por %xmm1, %xmm0
541 ; SSE41-LABEL: unsigned_sat_constant_v4i32_using_cmp_notval_nonsplat:
543 ; SSE41-NEXT: movdqa {{.*#+}} xmm1 = [43,44,45,46]
544 ; SSE41-NEXT: paddd %xmm0, %xmm1
545 ; SSE41-NEXT: movdqa {{.*#+}} xmm2 = [4294967253,4294967252,4294967251,4294967250]
546 ; SSE41-NEXT: pmaxud %xmm0, %xmm2
547 ; SSE41-NEXT: pcmpeqd %xmm2, %xmm0
548 ; SSE41-NEXT: por %xmm1, %xmm0
550 %a = add <4 x i32> %x, <i32 43, i32 44, i32 45, i32 46>
551 %c = icmp ugt <4 x i32> %x, <i32 -44, i32 -45, i32 -46, i32 -47>
552 %r = select <4 x i1> %c, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> %a
556 define <2 x i64> @unsigned_sat_constant_v2i64_using_min(<2 x i64> %x) {
557 ; SSE2-LABEL: unsigned_sat_constant_v2i64_using_min:
559 ; SSE2-NEXT: movdqa {{.*#+}} xmm1 = [9223372039002259456,9223372039002259456]
560 ; SSE2-NEXT: pxor %xmm0, %xmm1
561 ; SSE2-NEXT: movdqa {{.*#+}} xmm2 = [9223372034707292117,9223372034707292117]
562 ; SSE2-NEXT: movdqa %xmm2, %xmm3
563 ; SSE2-NEXT: pcmpgtd %xmm1, %xmm3
564 ; SSE2-NEXT: pshufd {{.*#+}} xmm4 = xmm3[0,0,2,2]
565 ; SSE2-NEXT: pcmpeqd %xmm2, %xmm1
566 ; SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
567 ; SSE2-NEXT: pand %xmm4, %xmm1
568 ; SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm3[1,1,3,3]
569 ; SSE2-NEXT: por %xmm1, %xmm2
570 ; SSE2-NEXT: pand %xmm2, %xmm0
571 ; SSE2-NEXT: pandn {{.*}}(%rip), %xmm2
572 ; SSE2-NEXT: por %xmm2, %xmm0
573 ; SSE2-NEXT: paddq {{.*}}(%rip), %xmm0
576 ; SSE41-LABEL: unsigned_sat_constant_v2i64_using_min:
578 ; SSE41-NEXT: movdqa %xmm0, %xmm1
579 ; SSE41-NEXT: movapd {{.*#+}} xmm2 = [18446744073709551573,18446744073709551573]
580 ; SSE41-NEXT: movdqa {{.*#+}} xmm0 = [9223372039002259456,9223372039002259456]
581 ; SSE41-NEXT: pxor %xmm1, %xmm0
582 ; SSE41-NEXT: movdqa {{.*#+}} xmm3 = [9223372034707292117,9223372034707292117]
583 ; SSE41-NEXT: movdqa %xmm3, %xmm4
584 ; SSE41-NEXT: pcmpgtd %xmm0, %xmm4
585 ; SSE41-NEXT: pshufd {{.*#+}} xmm5 = xmm4[0,0,2,2]
586 ; SSE41-NEXT: pcmpeqd %xmm3, %xmm0
587 ; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
588 ; SSE41-NEXT: pand %xmm5, %xmm0
589 ; SSE41-NEXT: por %xmm4, %xmm0
590 ; SSE41-NEXT: blendvpd %xmm0, %xmm1, %xmm2
591 ; SSE41-NEXT: paddq {{.*}}(%rip), %xmm2
592 ; SSE41-NEXT: movdqa %xmm2, %xmm0
594 %c = icmp ult <2 x i64> %x, <i64 -43, i64 -43>
595 %s = select <2 x i1> %c, <2 x i64> %x, <2 x i64> <i64 -43, i64 -43>
596 %r = add <2 x i64> %s, <i64 42, i64 42>
600 define <2 x i64> @unsigned_sat_constant_v2i64_using_cmp_sum(<2 x i64> %x) {
601 ; ANY-LABEL: unsigned_sat_constant_v2i64_using_cmp_sum:
603 ; ANY-NEXT: movdqa {{.*#+}} xmm1 = [42,42]
604 ; ANY-NEXT: paddq %xmm0, %xmm1
605 ; ANY-NEXT: movdqa {{.*#+}} xmm2 = [9223372039002259456,9223372039002259456]
606 ; ANY-NEXT: pxor %xmm2, %xmm0
607 ; ANY-NEXT: pxor %xmm1, %xmm2
608 ; ANY-NEXT: movdqa %xmm0, %xmm3
609 ; ANY-NEXT: pcmpgtd %xmm2, %xmm3
610 ; ANY-NEXT: pshufd {{.*#+}} xmm4 = xmm3[0,0,2,2]
611 ; ANY-NEXT: pcmpeqd %xmm0, %xmm2
612 ; ANY-NEXT: pshufd {{.*#+}} xmm2 = xmm2[1,1,3,3]
613 ; ANY-NEXT: pand %xmm4, %xmm2
614 ; ANY-NEXT: pshufd {{.*#+}} xmm0 = xmm3[1,1,3,3]
615 ; ANY-NEXT: por %xmm1, %xmm0
616 ; ANY-NEXT: por %xmm2, %xmm0
618 %a = add <2 x i64> %x, <i64 42, i64 42>
619 %c = icmp ugt <2 x i64> %x, %a
620 %r = select <2 x i1> %c, <2 x i64> <i64 -1, i64 -1>, <2 x i64> %a
624 define <2 x i64> @unsigned_sat_constant_v2i64_using_cmp_notval(<2 x i64> %x) {
625 ; ANY-LABEL: unsigned_sat_constant_v2i64_using_cmp_notval:
627 ; ANY-NEXT: movdqa {{.*#+}} xmm1 = [42,42]
628 ; ANY-NEXT: paddq %xmm0, %xmm1
629 ; ANY-NEXT: pxor {{.*}}(%rip), %xmm0
630 ; ANY-NEXT: movdqa {{.*#+}} xmm2 = [9223372034707292117,9223372034707292117]
631 ; ANY-NEXT: movdqa %xmm0, %xmm3
632 ; ANY-NEXT: pcmpgtd %xmm2, %xmm3
633 ; ANY-NEXT: pshufd {{.*#+}} xmm4 = xmm3[0,0,2,2]
634 ; ANY-NEXT: pcmpeqd %xmm2, %xmm0
635 ; ANY-NEXT: pshufd {{.*#+}} xmm2 = xmm0[1,1,3,3]
636 ; ANY-NEXT: pand %xmm4, %xmm2
637 ; ANY-NEXT: pshufd {{.*#+}} xmm0 = xmm3[1,1,3,3]
638 ; ANY-NEXT: por %xmm1, %xmm0
639 ; ANY-NEXT: por %xmm2, %xmm0
641 %a = add <2 x i64> %x, <i64 42, i64 42>
642 %c = icmp ugt <2 x i64> %x, <i64 -43, i64 -43>
643 %r = select <2 x i1> %c, <2 x i64> <i64 -1, i64 -1>, <2 x i64> %a
647 define <16 x i8> @unsigned_sat_variable_v16i8_using_min(<16 x i8> %x, <16 x i8> %y) {
648 ; ANY-LABEL: unsigned_sat_variable_v16i8_using_min:
650 ; ANY-NEXT: pcmpeqd %xmm2, %xmm2
651 ; ANY-NEXT: pxor %xmm1, %xmm2
652 ; ANY-NEXT: pminub %xmm2, %xmm0
653 ; ANY-NEXT: paddb %xmm1, %xmm0
655 %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>
656 %c = icmp ult <16 x i8> %x, %noty
657 %s = select <16 x i1> %c, <16 x i8> %x, <16 x i8> %noty
658 %r = add <16 x i8> %s, %y
662 define <16 x i8> @unsigned_sat_variable_v16i8_using_cmp_sum(<16 x i8> %x, <16 x i8> %y) {
663 ; ANY-LABEL: unsigned_sat_variable_v16i8_using_cmp_sum:
665 ; ANY-NEXT: paddusb %xmm1, %xmm0
667 %a = add <16 x i8> %x, %y
668 %c = icmp ugt <16 x i8> %x, %a
669 %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
673 define <16 x i8> @unsigned_sat_variable_v16i8_using_cmp_notval(<16 x i8> %x, <16 x i8> %y) {
674 ; ANY-LABEL: unsigned_sat_variable_v16i8_using_cmp_notval:
676 ; ANY-NEXT: pcmpeqd %xmm2, %xmm2
677 ; ANY-NEXT: movdqa %xmm0, %xmm3
678 ; ANY-NEXT: paddb %xmm1, %xmm3
679 ; ANY-NEXT: pxor %xmm2, %xmm1
680 ; ANY-NEXT: pminub %xmm0, %xmm1
681 ; ANY-NEXT: pcmpeqb %xmm1, %xmm0
682 ; ANY-NEXT: pxor %xmm2, %xmm0
683 ; ANY-NEXT: por %xmm3, %xmm0
685 %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>
686 %a = add <16 x i8> %x, %y
687 %c = icmp ugt <16 x i8> %x, %noty
688 %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
692 define <8 x i16> @unsigned_sat_variable_v8i16_using_min(<8 x i16> %x, <8 x i16> %y) {
693 ; SSE2-LABEL: unsigned_sat_variable_v8i16_using_min:
695 ; SSE2-NEXT: movdqa {{.*#+}} xmm2 = [32768,32768,32768,32768,32768,32768,32768,32768]
696 ; SSE2-NEXT: pxor %xmm2, %xmm0
697 ; SSE2-NEXT: movdqa {{.*#+}} xmm3 = [32767,32767,32767,32767,32767,32767,32767,32767]
698 ; SSE2-NEXT: pxor %xmm1, %xmm3
699 ; SSE2-NEXT: pminsw %xmm3, %xmm0
700 ; SSE2-NEXT: pxor %xmm2, %xmm0
701 ; SSE2-NEXT: paddw %xmm1, %xmm0
704 ; SSE41-LABEL: unsigned_sat_variable_v8i16_using_min:
706 ; SSE41-NEXT: pcmpeqd %xmm2, %xmm2
707 ; SSE41-NEXT: pxor %xmm1, %xmm2
708 ; SSE41-NEXT: pminuw %xmm2, %xmm0
709 ; SSE41-NEXT: paddw %xmm1, %xmm0
711 %noty = xor <8 x i16> %y, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
712 %c = icmp ult <8 x i16> %x, %noty
713 %s = select <8 x i1> %c, <8 x i16> %x, <8 x i16> %noty
714 %r = add <8 x i16> %s, %y
718 define <8 x i16> @unsigned_sat_variable_v8i16_using_cmp_sum(<8 x i16> %x, <8 x i16> %y) {
719 ; ANY-LABEL: unsigned_sat_variable_v8i16_using_cmp_sum:
721 ; ANY-NEXT: paddusw %xmm1, %xmm0
723 %a = add <8 x i16> %x, %y
724 %c = icmp ugt <8 x i16> %x, %a
725 %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
729 define <8 x i16> @unsigned_sat_variable_v8i16_using_cmp_notval(<8 x i16> %x, <8 x i16> %y) {
730 ; SSE2-LABEL: unsigned_sat_variable_v8i16_using_cmp_notval:
732 ; SSE2-NEXT: movdqa %xmm0, %xmm2
733 ; SSE2-NEXT: paddw %xmm1, %xmm2
734 ; SSE2-NEXT: pxor {{.*}}(%rip), %xmm1
735 ; SSE2-NEXT: pxor {{.*}}(%rip), %xmm0
736 ; SSE2-NEXT: pcmpgtw %xmm1, %xmm0
737 ; SSE2-NEXT: por %xmm2, %xmm0
740 ; SSE41-LABEL: unsigned_sat_variable_v8i16_using_cmp_notval:
742 ; SSE41-NEXT: pcmpeqd %xmm2, %xmm2
743 ; SSE41-NEXT: movdqa %xmm0, %xmm3
744 ; SSE41-NEXT: paddw %xmm1, %xmm3
745 ; SSE41-NEXT: pxor %xmm2, %xmm1
746 ; SSE41-NEXT: pminuw %xmm0, %xmm1
747 ; SSE41-NEXT: pcmpeqw %xmm1, %xmm0
748 ; SSE41-NEXT: pxor %xmm2, %xmm0
749 ; SSE41-NEXT: por %xmm3, %xmm0
751 %noty = xor <8 x i16> %y, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
752 %a = add <8 x i16> %x, %y
753 %c = icmp ugt <8 x i16> %x, %noty
754 %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
758 define <4 x i32> @unsigned_sat_variable_v4i32_using_min(<4 x i32> %x, <4 x i32> %y) {
759 ; SSE2-LABEL: unsigned_sat_variable_v4i32_using_min:
761 ; SSE2-NEXT: pcmpeqd %xmm2, %xmm2
762 ; SSE2-NEXT: movdqa {{.*#+}} xmm3 = [2147483648,2147483648,2147483648,2147483648]
763 ; SSE2-NEXT: pxor %xmm0, %xmm3
764 ; SSE2-NEXT: movdqa {{.*#+}} xmm4 = [2147483647,2147483647,2147483647,2147483647]
765 ; SSE2-NEXT: pxor %xmm1, %xmm4
766 ; SSE2-NEXT: pcmpgtd %xmm3, %xmm4
767 ; SSE2-NEXT: pand %xmm4, %xmm0
768 ; SSE2-NEXT: pxor %xmm2, %xmm4
769 ; SSE2-NEXT: movdqa %xmm1, %xmm2
770 ; SSE2-NEXT: pandn %xmm4, %xmm2
771 ; SSE2-NEXT: por %xmm2, %xmm0
772 ; SSE2-NEXT: paddd %xmm1, %xmm0
775 ; SSE41-LABEL: unsigned_sat_variable_v4i32_using_min:
777 ; SSE41-NEXT: pcmpeqd %xmm2, %xmm2
778 ; SSE41-NEXT: pxor %xmm1, %xmm2
779 ; SSE41-NEXT: pminud %xmm2, %xmm0
780 ; SSE41-NEXT: paddd %xmm1, %xmm0
782 %noty = xor <4 x i32> %y, <i32 -1, i32 -1, i32 -1, i32 -1>
783 %c = icmp ult <4 x i32> %x, %noty
784 %s = select <4 x i1> %c, <4 x i32> %x, <4 x i32> %noty
785 %r = add <4 x i32> %s, %y
789 define <4 x i32> @unsigned_sat_variable_v4i32_using_cmp_sum(<4 x i32> %x, <4 x i32> %y) {
790 ; SSE2-LABEL: unsigned_sat_variable_v4i32_using_cmp_sum:
792 ; SSE2-NEXT: paddd %xmm0, %xmm1
793 ; SSE2-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648]
794 ; SSE2-NEXT: pxor %xmm2, %xmm0
795 ; SSE2-NEXT: pxor %xmm1, %xmm2
796 ; SSE2-NEXT: pcmpgtd %xmm2, %xmm0
797 ; SSE2-NEXT: por %xmm1, %xmm0
800 ; SSE41-LABEL: unsigned_sat_variable_v4i32_using_cmp_sum:
802 ; SSE41-NEXT: paddd %xmm0, %xmm1
803 ; SSE41-NEXT: movdqa %xmm0, %xmm2
804 ; SSE41-NEXT: pminud %xmm1, %xmm2
805 ; SSE41-NEXT: pcmpeqd %xmm0, %xmm2
806 ; SSE41-NEXT: pcmpeqd %xmm0, %xmm0
807 ; SSE41-NEXT: pxor %xmm0, %xmm2
808 ; SSE41-NEXT: por %xmm1, %xmm2
809 ; SSE41-NEXT: movdqa %xmm2, %xmm0
811 %a = add <4 x i32> %x, %y
812 %c = icmp ugt <4 x i32> %x, %a
813 %r = select <4 x i1> %c, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> %a
817 define <4 x i32> @unsigned_sat_variable_v4i32_using_cmp_notval(<4 x i32> %x, <4 x i32> %y) {
818 ; SSE2-LABEL: unsigned_sat_variable_v4i32_using_cmp_notval:
820 ; SSE2-NEXT: movdqa %xmm0, %xmm2
821 ; SSE2-NEXT: paddd %xmm1, %xmm2
822 ; SSE2-NEXT: pxor {{.*}}(%rip), %xmm1
823 ; SSE2-NEXT: pxor {{.*}}(%rip), %xmm0
824 ; SSE2-NEXT: pcmpgtd %xmm1, %xmm0
825 ; SSE2-NEXT: por %xmm2, %xmm0
828 ; SSE41-LABEL: unsigned_sat_variable_v4i32_using_cmp_notval:
830 ; SSE41-NEXT: pcmpeqd %xmm2, %xmm2
831 ; SSE41-NEXT: movdqa %xmm0, %xmm3
832 ; SSE41-NEXT: paddd %xmm1, %xmm3
833 ; SSE41-NEXT: pxor %xmm2, %xmm1
834 ; SSE41-NEXT: pminud %xmm0, %xmm1
835 ; SSE41-NEXT: pcmpeqd %xmm1, %xmm0
836 ; SSE41-NEXT: pxor %xmm2, %xmm0
837 ; SSE41-NEXT: por %xmm3, %xmm0
839 %noty = xor <4 x i32> %y, <i32 -1, i32 -1, i32 -1, i32 -1>
840 %a = add <4 x i32> %x, %y
841 %c = icmp ugt <4 x i32> %x, %noty
842 %r = select <4 x i1> %c, <4 x i32> <i32 -1, i32 -1, i32 -1, i32 -1>, <4 x i32> %a
846 define <2 x i64> @unsigned_sat_variable_v2i64_using_min(<2 x i64> %x, <2 x i64> %y) {
847 ; SSE2-LABEL: unsigned_sat_variable_v2i64_using_min:
849 ; SSE2-NEXT: pcmpeqd %xmm2, %xmm2
850 ; SSE2-NEXT: movdqa {{.*#+}} xmm3 = [9223372039002259456,9223372039002259456]
851 ; SSE2-NEXT: pxor %xmm0, %xmm3
852 ; SSE2-NEXT: movdqa {{.*#+}} xmm4 = [9223372034707292159,9223372034707292159]
853 ; SSE2-NEXT: pxor %xmm1, %xmm4
854 ; SSE2-NEXT: movdqa %xmm4, %xmm5
855 ; SSE2-NEXT: pcmpgtd %xmm3, %xmm5
856 ; SSE2-NEXT: pshufd {{.*#+}} xmm6 = xmm5[0,0,2,2]
857 ; SSE2-NEXT: pcmpeqd %xmm3, %xmm4
858 ; SSE2-NEXT: pshufd {{.*#+}} xmm3 = xmm4[1,1,3,3]
859 ; SSE2-NEXT: pand %xmm6, %xmm3
860 ; SSE2-NEXT: pshufd {{.*#+}} xmm4 = xmm5[1,1,3,3]
861 ; SSE2-NEXT: por %xmm3, %xmm4
862 ; SSE2-NEXT: pand %xmm4, %xmm0
863 ; SSE2-NEXT: pxor %xmm2, %xmm4
864 ; SSE2-NEXT: movdqa %xmm1, %xmm2
865 ; SSE2-NEXT: pandn %xmm4, %xmm2
866 ; SSE2-NEXT: por %xmm2, %xmm0
867 ; SSE2-NEXT: paddq %xmm1, %xmm0
870 ; SSE41-LABEL: unsigned_sat_variable_v2i64_using_min:
872 ; SSE41-NEXT: movdqa %xmm0, %xmm2
873 ; SSE41-NEXT: pcmpeqd %xmm3, %xmm3
874 ; SSE41-NEXT: pxor %xmm1, %xmm3
875 ; SSE41-NEXT: movdqa {{.*#+}} xmm0 = [9223372039002259456,9223372039002259456]
876 ; SSE41-NEXT: pxor %xmm2, %xmm0
877 ; SSE41-NEXT: movdqa {{.*#+}} xmm4 = [9223372034707292159,9223372034707292159]
878 ; SSE41-NEXT: pxor %xmm1, %xmm4
879 ; SSE41-NEXT: movdqa %xmm4, %xmm5
880 ; SSE41-NEXT: pcmpgtd %xmm0, %xmm5
881 ; SSE41-NEXT: pshufd {{.*#+}} xmm6 = xmm5[0,0,2,2]
882 ; SSE41-NEXT: pcmpeqd %xmm0, %xmm4
883 ; SSE41-NEXT: pshufd {{.*#+}} xmm0 = xmm4[1,1,3,3]
884 ; SSE41-NEXT: pand %xmm6, %xmm0
885 ; SSE41-NEXT: por %xmm5, %xmm0
886 ; SSE41-NEXT: blendvpd %xmm0, %xmm2, %xmm3
887 ; SSE41-NEXT: paddq %xmm1, %xmm3
888 ; SSE41-NEXT: movdqa %xmm3, %xmm0
890 %noty = xor <2 x i64> %y, <i64 -1, i64 -1>
891 %c = icmp ult <2 x i64> %x, %noty
892 %s = select <2 x i1> %c, <2 x i64> %x, <2 x i64> %noty
893 %r = add <2 x i64> %s, %y
897 define <2 x i64> @unsigned_sat_variable_v2i64_using_cmp_sum(<2 x i64> %x, <2 x i64> %y) {
898 ; ANY-LABEL: unsigned_sat_variable_v2i64_using_cmp_sum:
900 ; ANY-NEXT: paddq %xmm0, %xmm1
901 ; ANY-NEXT: movdqa {{.*#+}} xmm2 = [9223372039002259456,9223372039002259456]
902 ; ANY-NEXT: pxor %xmm2, %xmm0
903 ; ANY-NEXT: pxor %xmm1, %xmm2
904 ; ANY-NEXT: movdqa %xmm0, %xmm3
905 ; ANY-NEXT: pcmpgtd %xmm2, %xmm3
906 ; ANY-NEXT: pshufd {{.*#+}} xmm4 = xmm3[0,0,2,2]
907 ; ANY-NEXT: pcmpeqd %xmm0, %xmm2
908 ; ANY-NEXT: pshufd {{.*#+}} xmm2 = xmm2[1,1,3,3]
909 ; ANY-NEXT: pand %xmm4, %xmm2
910 ; ANY-NEXT: pshufd {{.*#+}} xmm0 = xmm3[1,1,3,3]
911 ; ANY-NEXT: por %xmm1, %xmm0
912 ; ANY-NEXT: por %xmm2, %xmm0
914 %a = add <2 x i64> %x, %y
915 %c = icmp ugt <2 x i64> %x, %a
916 %r = select <2 x i1> %c, <2 x i64> <i64 -1, i64 -1>, <2 x i64> %a
920 define <2 x i64> @unsigned_sat_variable_v2i64_using_cmp_notval(<2 x i64> %x, <2 x i64> %y) {
921 ; ANY-LABEL: unsigned_sat_variable_v2i64_using_cmp_notval:
923 ; ANY-NEXT: movdqa %xmm0, %xmm2
924 ; ANY-NEXT: paddq %xmm1, %xmm2
925 ; ANY-NEXT: pxor {{.*}}(%rip), %xmm1
926 ; ANY-NEXT: pxor {{.*}}(%rip), %xmm0
927 ; ANY-NEXT: movdqa %xmm0, %xmm3
928 ; ANY-NEXT: pcmpgtd %xmm1, %xmm3
929 ; ANY-NEXT: pshufd {{.*#+}} xmm4 = xmm3[0,0,2,2]
930 ; ANY-NEXT: pcmpeqd %xmm1, %xmm0
931 ; ANY-NEXT: pshufd {{.*#+}} xmm1 = xmm0[1,1,3,3]
932 ; ANY-NEXT: pand %xmm4, %xmm1
933 ; ANY-NEXT: pshufd {{.*#+}} xmm0 = xmm3[1,1,3,3]
934 ; ANY-NEXT: por %xmm2, %xmm0
935 ; ANY-NEXT: por %xmm1, %xmm0
937 %noty = xor <2 x i64> %y, <i64 -1, i64 -1>
938 %a = add <2 x i64> %x, %y
939 %c = icmp ugt <2 x i64> %x, %noty
940 %r = select <2 x i1> %c, <2 x i64> <i64 -1, i64 -1>, <2 x i64> %a