1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686 -mattr=cmov | FileCheck %s --check-prefixes=CHECK,X86
3 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefixes=CHECK,X64
5 declare i4 @llvm.usub.sat.i4 (i4, i4)
6 declare i32 @llvm.usub.sat.i32 (i32, i32)
7 declare i64 @llvm.usub.sat.i64 (i64, i64)
8 declare <4 x i32> @llvm.usub.sat.v4i32(<4 x i32>, <4 x i32>)
10 define i32 @func(i32 %x, i32 %y) nounwind {
13 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
14 ; X86-NEXT: xorl %ecx, %ecx
15 ; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
16 ; X86-NEXT: cmovbl %ecx, %eax
21 ; X64-NEXT: xorl %eax, %eax
22 ; X64-NEXT: subl %esi, %edi
23 ; X64-NEXT: cmovael %edi, %eax
25 %tmp = call i32 @llvm.usub.sat.i32(i32 %x, i32 %y);
29 define i64 @func2(i64 %x, i64 %y) nounwind {
32 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
33 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
34 ; X86-NEXT: xorl %ecx, %ecx
35 ; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
36 ; X86-NEXT: sbbl {{[0-9]+}}(%esp), %edx
37 ; X86-NEXT: cmovbl %ecx, %edx
38 ; X86-NEXT: cmovbl %ecx, %eax
43 ; X64-NEXT: xorl %eax, %eax
44 ; X64-NEXT: subq %rsi, %rdi
45 ; X64-NEXT: cmovaeq %rdi, %rax
47 %tmp = call i64 @llvm.usub.sat.i64(i64 %x, i64 %y);
51 define i4 @func3(i4 %x, i4 %y) nounwind {
54 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
55 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
56 ; X86-NEXT: shlb $4, %cl
57 ; X86-NEXT: shlb $4, %al
58 ; X86-NEXT: subb %cl, %al
59 ; X86-NEXT: jae .LBB2_2
61 ; X86-NEXT: xorl %eax, %eax
63 ; X86-NEXT: shrb $4, %al
64 ; X86-NEXT: # kill: def $al killed $al killed $eax
69 ; X64-NEXT: movl %edi, %eax
70 ; X64-NEXT: shlb $4, %sil
71 ; X64-NEXT: shlb $4, %al
72 ; X64-NEXT: subb %sil, %al
73 ; X64-NEXT: jae .LBB2_2
75 ; X64-NEXT: xorl %eax, %eax
77 ; X64-NEXT: shrb $4, %al
78 ; X64-NEXT: # kill: def $al killed $al killed $eax
80 %tmp = call i4 @llvm.usub.sat.i4(i4 %x, i4 %y);
84 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
87 ; X86-NEXT: pushl %ebx
88 ; X86-NEXT: pushl %edi
89 ; X86-NEXT: pushl %esi
90 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
91 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
92 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
93 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
94 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
95 ; X86-NEXT: xorl %ebx, %ebx
96 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edi
97 ; X86-NEXT: cmovbl %ebx, %edi
98 ; X86-NEXT: subl {{[0-9]+}}(%esp), %esi
99 ; X86-NEXT: cmovbl %ebx, %esi
100 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edx
101 ; X86-NEXT: cmovbl %ebx, %edx
102 ; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx
103 ; X86-NEXT: cmovbl %ebx, %ecx
104 ; X86-NEXT: movl %ecx, 12(%eax)
105 ; X86-NEXT: movl %edx, 8(%eax)
106 ; X86-NEXT: movl %esi, 4(%eax)
107 ; X86-NEXT: movl %edi, (%eax)
108 ; X86-NEXT: popl %esi
109 ; X86-NEXT: popl %edi
110 ; X86-NEXT: popl %ebx
115 ; X64-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648]
116 ; X64-NEXT: movdqa %xmm1, %xmm3
117 ; X64-NEXT: pxor %xmm2, %xmm3
118 ; X64-NEXT: pxor %xmm0, %xmm2
119 ; X64-NEXT: pcmpgtd %xmm3, %xmm2
120 ; X64-NEXT: pand %xmm2, %xmm0
121 ; X64-NEXT: pandn %xmm1, %xmm2
122 ; X64-NEXT: por %xmm2, %xmm0
123 ; X64-NEXT: psubd %xmm1, %xmm0
125 %tmp = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %x, <4 x i32> %y);