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 i8 @llvm.usub.sat.i8(i8, i8)
7 declare i16 @llvm.usub.sat.i16(i16, i16)
8 declare i32 @llvm.usub.sat.i32(i32, i32)
9 declare i64 @llvm.usub.sat.i64(i64, i64)
10 declare <4 x i32> @llvm.usub.sat.v4i32(<4 x i32>, <4 x i32>)
12 define i32 @func(i32 %x, i32 %y) nounwind {
15 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
16 ; X86-NEXT: xorl %ecx, %ecx
17 ; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
18 ; X86-NEXT: cmovbl %ecx, %eax
23 ; X64-NEXT: xorl %eax, %eax
24 ; X64-NEXT: subl %esi, %edi
25 ; X64-NEXT: cmovael %edi, %eax
27 %tmp = call i32 @llvm.usub.sat.i32(i32 %x, i32 %y)
31 define i64 @func2(i64 %x, i64 %y) nounwind {
34 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
35 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
36 ; X86-NEXT: xorl %ecx, %ecx
37 ; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
38 ; X86-NEXT: sbbl {{[0-9]+}}(%esp), %edx
39 ; X86-NEXT: cmovbl %ecx, %edx
40 ; X86-NEXT: cmovbl %ecx, %eax
45 ; X64-NEXT: xorl %eax, %eax
46 ; X64-NEXT: subq %rsi, %rdi
47 ; X64-NEXT: cmovaeq %rdi, %rax
49 %tmp = call i64 @llvm.usub.sat.i64(i64 %x, i64 %y)
53 define zeroext i16 @func16(i16 zeroext %x, i16 zeroext %y) nounwind {
56 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
57 ; X86-NEXT: xorl %ecx, %ecx
58 ; X86-NEXT: subw {{[0-9]+}}(%esp), %ax
59 ; X86-NEXT: cmovbl %ecx, %eax
60 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
65 ; X64-NEXT: xorl %eax, %eax
66 ; X64-NEXT: subw %si, %di
67 ; X64-NEXT: cmovael %edi, %eax
68 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
70 %tmp = call i16 @llvm.usub.sat.i16(i16 %x, i16 %y)
74 define zeroext i8 @func8(i8 zeroext %x, i8 zeroext %y) nounwind {
77 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
78 ; X86-NEXT: xorl %ecx, %ecx
79 ; X86-NEXT: subb {{[0-9]+}}(%esp), %al
80 ; X86-NEXT: movzbl %al, %eax
81 ; X86-NEXT: cmovbl %ecx, %eax
82 ; X86-NEXT: # kill: def $al killed $al killed $eax
87 ; X64-NEXT: xorl %ecx, %ecx
88 ; X64-NEXT: subb %sil, %dil
89 ; X64-NEXT: movzbl %dil, %eax
90 ; X64-NEXT: cmovbl %ecx, %eax
91 ; X64-NEXT: # kill: def $al killed $al killed $eax
93 %tmp = call i8 @llvm.usub.sat.i8(i8 %x, i8 %y)
97 define zeroext i4 @func3(i4 zeroext %x, i4 zeroext %y) nounwind {
100 ; X86-NEXT: pushl %ebx
101 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
102 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
103 ; X86-NEXT: movzbl %cl, %edx
104 ; X86-NEXT: movzbl %al, %ebx
105 ; X86-NEXT: cmpb %al, %cl
106 ; X86-NEXT: cmoval %edx, %ebx
107 ; X86-NEXT: subb %al, %bl
108 ; X86-NEXT: movzbl %bl, %eax
109 ; X86-NEXT: andl $15, %eax
110 ; X86-NEXT: popl %ebx
115 ; X64-NEXT: cmpb %sil, %dil
116 ; X64-NEXT: movl %esi, %eax
117 ; X64-NEXT: cmoval %edi, %eax
118 ; X64-NEXT: subb %sil, %al
119 ; X64-NEXT: movzbl %al, %eax
120 ; X64-NEXT: andl $15, %eax
122 %tmp = call i4 @llvm.usub.sat.i4(i4 %x, i4 %y)
126 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
129 ; X86-NEXT: pushl %ebx
130 ; X86-NEXT: pushl %edi
131 ; X86-NEXT: pushl %esi
132 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
133 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
134 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
135 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
136 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
137 ; X86-NEXT: xorl %ebx, %ebx
138 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edi
139 ; X86-NEXT: cmovbl %ebx, %edi
140 ; X86-NEXT: subl {{[0-9]+}}(%esp), %esi
141 ; X86-NEXT: cmovbl %ebx, %esi
142 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edx
143 ; X86-NEXT: cmovbl %ebx, %edx
144 ; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx
145 ; X86-NEXT: cmovbl %ebx, %ecx
146 ; X86-NEXT: movl %ecx, 12(%eax)
147 ; X86-NEXT: movl %edx, 8(%eax)
148 ; X86-NEXT: movl %esi, 4(%eax)
149 ; X86-NEXT: movl %edi, (%eax)
150 ; X86-NEXT: popl %esi
151 ; X86-NEXT: popl %edi
152 ; X86-NEXT: popl %ebx
157 ; X64-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648]
158 ; X64-NEXT: movdqa %xmm1, %xmm3
159 ; X64-NEXT: pxor %xmm2, %xmm3
160 ; X64-NEXT: pxor %xmm0, %xmm2
161 ; X64-NEXT: pcmpgtd %xmm3, %xmm2
162 ; X64-NEXT: psubd %xmm1, %xmm0
163 ; X64-NEXT: pand %xmm2, %xmm0
165 %tmp = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %x, <4 x i32> %y)