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: movb {{[0-9]+}}(%esp), %al
101 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
102 ; X86-NEXT: shlb $4, %cl
103 ; X86-NEXT: shlb $4, %al
104 ; X86-NEXT: xorl %edx, %edx
105 ; X86-NEXT: subb %cl, %al
106 ; X86-NEXT: movzbl %al, %eax
107 ; X86-NEXT: cmovbl %edx, %eax
108 ; X86-NEXT: shrb $4, %al
109 ; X86-NEXT: movzbl %al, %eax
114 ; X64-NEXT: shlb $4, %sil
115 ; X64-NEXT: shlb $4, %dil
116 ; X64-NEXT: xorl %eax, %eax
117 ; X64-NEXT: subb %sil, %dil
118 ; X64-NEXT: movzbl %dil, %ecx
119 ; X64-NEXT: cmovbl %eax, %ecx
120 ; X64-NEXT: shrb $4, %cl
121 ; X64-NEXT: movzbl %cl, %eax
123 %tmp = call i4 @llvm.usub.sat.i4(i4 %x, i4 %y)
127 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
130 ; X86-NEXT: pushl %ebx
131 ; X86-NEXT: pushl %edi
132 ; X86-NEXT: pushl %esi
133 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
134 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
135 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
136 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
137 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
138 ; X86-NEXT: xorl %ebx, %ebx
139 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edi
140 ; X86-NEXT: cmovbl %ebx, %edi
141 ; X86-NEXT: subl {{[0-9]+}}(%esp), %esi
142 ; X86-NEXT: cmovbl %ebx, %esi
143 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edx
144 ; X86-NEXT: cmovbl %ebx, %edx
145 ; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx
146 ; X86-NEXT: cmovbl %ebx, %ecx
147 ; X86-NEXT: movl %ecx, 12(%eax)
148 ; X86-NEXT: movl %edx, 8(%eax)
149 ; X86-NEXT: movl %esi, 4(%eax)
150 ; X86-NEXT: movl %edi, (%eax)
151 ; X86-NEXT: popl %esi
152 ; X86-NEXT: popl %edi
153 ; X86-NEXT: popl %ebx
158 ; X64-NEXT: movdqa {{.*#+}} xmm2 = [2147483648,2147483648,2147483648,2147483648]
159 ; X64-NEXT: movdqa %xmm1, %xmm3
160 ; X64-NEXT: pxor %xmm2, %xmm3
161 ; X64-NEXT: pxor %xmm0, %xmm2
162 ; X64-NEXT: pcmpgtd %xmm3, %xmm2
163 ; X64-NEXT: psubd %xmm1, %xmm0
164 ; X64-NEXT: pand %xmm2, %xmm0
166 %tmp = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %x, <4 x i32> %y)