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.ssub.sat.i4(i4, i4)
6 declare i8 @llvm.ssub.sat.i8(i8, i8)
7 declare i16 @llvm.ssub.sat.i16(i16, i16)
8 declare i32 @llvm.ssub.sat.i32(i32, i32)
9 declare i64 @llvm.ssub.sat.i64(i64, i64)
11 define i32 @func32(i32 %x, i32 %y, i32 %z) nounwind {
14 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
15 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
16 ; X86-NEXT: imull {{[0-9]+}}(%esp), %edx
17 ; X86-NEXT: xorl %ecx, %ecx
18 ; X86-NEXT: cmpl %edx, %eax
20 ; X86-NEXT: addl $2147483647, %ecx # imm = 0x7FFFFFFF
21 ; X86-NEXT: subl %edx, %eax
22 ; X86-NEXT: cmovol %ecx, %eax
27 ; X64-NEXT: imull %edx, %esi
28 ; X64-NEXT: xorl %eax, %eax
29 ; X64-NEXT: cmpl %esi, %edi
31 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
32 ; X64-NEXT: subl %esi, %edi
33 ; X64-NEXT: cmovnol %edi, %eax
36 %tmp = call i32 @llvm.ssub.sat.i32(i32 %x, i32 %a)
40 define i64 @func64(i64 %x, i64 %y, i64 %z) nounwind {
43 ; X86-NEXT: pushl %ebp
44 ; X86-NEXT: pushl %ebx
45 ; X86-NEXT: pushl %edi
46 ; X86-NEXT: pushl %esi
47 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
48 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
49 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
50 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edi
51 ; X86-NEXT: movl %ebx, %ebp
52 ; X86-NEXT: sbbl %esi, %ebp
53 ; X86-NEXT: movl %ebp, %eax
54 ; X86-NEXT: sarl $31, %eax
55 ; X86-NEXT: xorl %ecx, %ecx
56 ; X86-NEXT: testl %ebp, %ebp
58 ; X86-NEXT: movl %ecx, %edx
59 ; X86-NEXT: addl $2147483647, %edx # imm = 0x7FFFFFFF
60 ; X86-NEXT: testl %ebx, %ebx
62 ; X86-NEXT: cmpb %cl, %bl
64 ; X86-NEXT: testl %esi, %esi
66 ; X86-NEXT: cmpb %ch, %bl
68 ; X86-NEXT: testb %cl, %ch
69 ; X86-NEXT: cmovel %ebp, %edx
70 ; X86-NEXT: cmovel %edi, %eax
79 ; X64-NEXT: xorl %ecx, %ecx
80 ; X64-NEXT: cmpq %rdx, %rdi
82 ; X64-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
83 ; X64-NEXT: addq %rcx, %rax
84 ; X64-NEXT: subq %rdx, %rdi
85 ; X64-NEXT: cmovnoq %rdi, %rax
88 %tmp = call i64 @llvm.ssub.sat.i64(i64 %x, i64 %z)
92 define signext i16 @func16(i16 signext %x, i16 signext %y, i16 signext %z) nounwind {
95 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
96 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %edx
97 ; X86-NEXT: imulw {{[0-9]+}}(%esp), %dx
98 ; X86-NEXT: xorl %ecx, %ecx
99 ; X86-NEXT: cmpw %dx, %ax
100 ; X86-NEXT: setns %cl
101 ; X86-NEXT: addl $32767, %ecx # imm = 0x7FFF
102 ; X86-NEXT: subw %dx, %ax
103 ; X86-NEXT: cmovol %ecx, %eax
104 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
109 ; X64-NEXT: imull %edx, %esi
110 ; X64-NEXT: xorl %eax, %eax
111 ; X64-NEXT: cmpw %si, %di
112 ; X64-NEXT: setns %al
113 ; X64-NEXT: addl $32767, %eax # imm = 0x7FFF
114 ; X64-NEXT: subw %si, %di
115 ; X64-NEXT: cmovnol %edi, %eax
116 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
119 %tmp = call i16 @llvm.ssub.sat.i16(i16 %x, i16 %a)
123 define signext i8 @func8(i8 signext %x, i8 signext %y, i8 signext %z) nounwind {
126 ; X86-NEXT: movb {{[0-9]+}}(%esp), %dl
127 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
128 ; X86-NEXT: mulb {{[0-9]+}}(%esp)
129 ; X86-NEXT: xorl %ecx, %ecx
130 ; X86-NEXT: cmpb %al, %dl
131 ; X86-NEXT: setns %cl
132 ; X86-NEXT: addl $127, %ecx
133 ; X86-NEXT: subb %al, %dl
134 ; X86-NEXT: movzbl %dl, %eax
135 ; X86-NEXT: cmovol %ecx, %eax
136 ; X86-NEXT: # kill: def $al killed $al killed $eax
141 ; X64-NEXT: movl %esi, %eax
142 ; X64-NEXT: # kill: def $al killed $al killed $eax
144 ; X64-NEXT: xorl %ecx, %ecx
145 ; X64-NEXT: cmpb %al, %dil
146 ; X64-NEXT: setns %cl
147 ; X64-NEXT: addl $127, %ecx
148 ; X64-NEXT: subb %al, %dil
149 ; X64-NEXT: movzbl %dil, %eax
150 ; X64-NEXT: cmovol %ecx, %eax
151 ; X64-NEXT: # kill: def $al killed $al killed $eax
154 %tmp = call i8 @llvm.ssub.sat.i8(i8 %x, i8 %a)
158 define signext i4 @func4(i4 signext %x, i4 signext %y, i4 signext %z) nounwind {
161 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
162 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
163 ; X86-NEXT: mulb {{[0-9]+}}(%esp)
164 ; X86-NEXT: shlb $4, %al
165 ; X86-NEXT: sarb $4, %al
166 ; X86-NEXT: subb %al, %cl
167 ; X86-NEXT: movzbl %cl, %eax
168 ; X86-NEXT: cmpb $7, %cl
169 ; X86-NEXT: movl $7, %ecx
170 ; X86-NEXT: cmovll %eax, %ecx
171 ; X86-NEXT: cmpb $-8, %cl
172 ; X86-NEXT: movl $248, %eax
173 ; X86-NEXT: cmovgl %ecx, %eax
174 ; X86-NEXT: movsbl %al, %eax
179 ; X64-NEXT: movl %esi, %eax
180 ; X64-NEXT: # kill: def $al killed $al killed $eax
182 ; X64-NEXT: shlb $4, %al
183 ; X64-NEXT: sarb $4, %al
184 ; X64-NEXT: subb %al, %dil
185 ; X64-NEXT: movzbl %dil, %eax
186 ; X64-NEXT: cmpb $7, %al
187 ; X64-NEXT: movl $7, %ecx
188 ; X64-NEXT: cmovll %eax, %ecx
189 ; X64-NEXT: cmpb $-8, %cl
190 ; X64-NEXT: movl $248, %eax
191 ; X64-NEXT: cmovgl %ecx, %eax
192 ; X64-NEXT: movsbl %al, %eax
195 %tmp = call i4 @llvm.ssub.sat.i4(i4 %x, i4 %a)