1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=X64
3 ; RUN: llc < %s -mtriple=i686 -mattr=cmov | FileCheck %s --check-prefix=X86
5 declare i4 @llvm.ushl.sat.i4 (i4, i4)
6 declare i8 @llvm.ushl.sat.i8 (i8, i8)
7 declare i15 @llvm.ushl.sat.i15 (i15, i15)
8 declare i16 @llvm.ushl.sat.i16 (i16, i16)
9 declare i18 @llvm.ushl.sat.i18 (i18, i18)
10 declare i32 @llvm.ushl.sat.i32 (i32, i32)
11 declare i64 @llvm.ushl.sat.i64 (i64, i64)
13 define i16 @func(i16 %x, i16 %y) nounwind {
16 ; X64-NEXT: movl %esi, %ecx
17 ; X64-NEXT: movl %edi, %edx
18 ; X64-NEXT: shll %cl, %edx
19 ; X64-NEXT: movzwl %dx, %eax
20 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
21 ; X64-NEXT: shrl %cl, %eax
22 ; X64-NEXT: cmpw %ax, %di
23 ; X64-NEXT: movl $65535, %eax # imm = 0xFFFF
24 ; X64-NEXT: cmovel %edx, %eax
25 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
30 ; X86-NEXT: pushl %esi
31 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
32 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
33 ; X86-NEXT: movl %eax, %edx
34 ; X86-NEXT: shll %cl, %edx
35 ; X86-NEXT: movzwl %dx, %esi
36 ; X86-NEXT: shrl %cl, %esi
37 ; X86-NEXT: cmpw %si, %ax
38 ; X86-NEXT: movl $65535, %eax # imm = 0xFFFF
39 ; X86-NEXT: cmovel %edx, %eax
40 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
43 %tmp = call i16 @llvm.ushl.sat.i16(i16 %x, i16 %y)
47 define i16 @func2(i8 %x, i8 %y) nounwind {
50 ; X64-NEXT: movl %esi, %ecx
51 ; X64-NEXT: movsbl %dil, %eax
52 ; X64-NEXT: addl %eax, %eax
53 ; X64-NEXT: movl %eax, %edx
54 ; X64-NEXT: shll %cl, %edx
55 ; X64-NEXT: movzwl %dx, %esi
56 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
57 ; X64-NEXT: shrl %cl, %esi
58 ; X64-NEXT: cmpw %si, %ax
59 ; X64-NEXT: movl $65535, %eax # imm = 0xFFFF
60 ; X64-NEXT: cmovel %edx, %eax
63 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
68 ; X86-NEXT: pushl %esi
69 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
70 ; X86-NEXT: movsbl {{[0-9]+}}(%esp), %eax
71 ; X86-NEXT: addl %eax, %eax
72 ; X86-NEXT: movl %eax, %edx
73 ; X86-NEXT: shll %cl, %edx
74 ; X86-NEXT: movzwl %dx, %esi
75 ; X86-NEXT: shrl %cl, %esi
76 ; X86-NEXT: cmpw %si, %ax
77 ; X86-NEXT: movl $65535, %eax # imm = 0xFFFF
78 ; X86-NEXT: cmovel %edx, %eax
81 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
84 %x2 = sext i8 %x to i15
85 %y2 = sext i8 %y to i15
86 %tmp = call i15 @llvm.ushl.sat.i15(i15 %x2, i15 %y2)
87 %tmp2 = sext i15 %tmp to i16
91 define i16 @func3(i15 %x, i8 %y) nounwind {
94 ; X64-NEXT: movl %esi, %ecx
95 ; X64-NEXT: shll $7, %ecx
96 ; X64-NEXT: addl %edi, %edi
97 ; X64-NEXT: movl %edi, %eax
98 ; X64-NEXT: shll %cl, %eax
99 ; X64-NEXT: movzwl %ax, %edx
100 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
101 ; X64-NEXT: shrl %cl, %edx
102 ; X64-NEXT: cmpw %dx, %di
103 ; X64-NEXT: movl $65535, %ecx # imm = 0xFFFF
104 ; X64-NEXT: cmovel %eax, %ecx
105 ; X64-NEXT: movswl %cx, %eax
106 ; X64-NEXT: shrl %eax
107 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
112 ; X86-NEXT: pushl %esi
113 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
114 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
115 ; X86-NEXT: shll $7, %ecx
116 ; X86-NEXT: addl %eax, %eax
117 ; X86-NEXT: movl %eax, %edx
118 ; X86-NEXT: shll %cl, %edx
119 ; X86-NEXT: movzwl %dx, %esi
120 ; X86-NEXT: # kill: def $cl killed $cl killed $ecx
121 ; X86-NEXT: shrl %cl, %esi
122 ; X86-NEXT: cmpw %si, %ax
123 ; X86-NEXT: movl $65535, %eax # imm = 0xFFFF
124 ; X86-NEXT: cmovel %edx, %eax
126 ; X86-NEXT: shrl %eax
127 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
128 ; X86-NEXT: popl %esi
130 %y2 = sext i8 %y to i15
132 %tmp = call i15 @llvm.ushl.sat.i15(i15 %x, i15 %y3)
133 %tmp2 = sext i15 %tmp to i16
137 define i4 @func4(i4 %x, i4 %y) nounwind {
140 ; X64-NEXT: movl %esi, %ecx
141 ; X64-NEXT: andb $15, %cl
142 ; X64-NEXT: shlb $4, %dil
143 ; X64-NEXT: movl %edi, %eax
144 ; X64-NEXT: shlb %cl, %al
145 ; X64-NEXT: movzbl %al, %edx
146 ; X64-NEXT: movl %edx, %eax
147 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
148 ; X64-NEXT: shrb %cl, %al
149 ; X64-NEXT: cmpb %al, %dil
150 ; X64-NEXT: movl $255, %eax
151 ; X64-NEXT: cmovel %edx, %eax
152 ; X64-NEXT: shrb $4, %al
153 ; X64-NEXT: # kill: def $al killed $al killed $eax
158 ; X86-NEXT: pushl %esi
159 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
160 ; X86-NEXT: andb $15, %cl
161 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
162 ; X86-NEXT: shlb $4, %al
163 ; X86-NEXT: movl %eax, %edx
164 ; X86-NEXT: shlb %cl, %dl
165 ; X86-NEXT: movzbl %dl, %esi
166 ; X86-NEXT: shrb %cl, %dl
167 ; X86-NEXT: cmpb %dl, %al
168 ; X86-NEXT: movl $255, %eax
169 ; X86-NEXT: cmovel %esi, %eax
170 ; X86-NEXT: shrb $4, %al
171 ; X86-NEXT: # kill: def $al killed $al killed $eax
172 ; X86-NEXT: popl %esi
174 %tmp = call i4 @llvm.ushl.sat.i4(i4 %x, i4 %y)
178 define i64 @func5(i64 %x, i64 %y) nounwind {
181 ; X64-NEXT: movq %rsi, %rcx
182 ; X64-NEXT: movq %rdi, %rdx
183 ; X64-NEXT: shlq %cl, %rdx
184 ; X64-NEXT: movq %rdx, %rax
185 ; X64-NEXT: # kill: def $cl killed $cl killed $rcx
186 ; X64-NEXT: shrq %cl, %rax
187 ; X64-NEXT: cmpq %rax, %rdi
188 ; X64-NEXT: movq $-1, %rax
189 ; X64-NEXT: cmoveq %rdx, %rax
194 ; X86-NEXT: pushl %ebp
195 ; X86-NEXT: pushl %ebx
196 ; X86-NEXT: pushl %edi
197 ; X86-NEXT: pushl %esi
198 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
199 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
200 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
201 ; X86-NEXT: movl %esi, %edi
202 ; X86-NEXT: shll %cl, %edi
203 ; X86-NEXT: shldl %cl, %esi, %edx
204 ; X86-NEXT: xorl %ebx, %ebx
205 ; X86-NEXT: testb $32, %cl
206 ; X86-NEXT: cmovnel %edi, %edx
207 ; X86-NEXT: cmovnel %ebx, %edi
208 ; X86-NEXT: movl %edx, %ebp
209 ; X86-NEXT: shrl %cl, %ebp
210 ; X86-NEXT: testb $32, %cl
211 ; X86-NEXT: cmovel %ebp, %ebx
212 ; X86-NEXT: movl %edi, %eax
213 ; X86-NEXT: shrdl %cl, %edx, %eax
214 ; X86-NEXT: testb $32, %cl
215 ; X86-NEXT: cmovnel %ebp, %eax
216 ; X86-NEXT: xorl %esi, %eax
217 ; X86-NEXT: xorl {{[0-9]+}}(%esp), %ebx
218 ; X86-NEXT: orl %eax, %ebx
219 ; X86-NEXT: movl $-1, %eax
220 ; X86-NEXT: cmovnel %eax, %edi
221 ; X86-NEXT: cmovnel %eax, %edx
222 ; X86-NEXT: movl %edi, %eax
223 ; X86-NEXT: popl %esi
224 ; X86-NEXT: popl %edi
225 ; X86-NEXT: popl %ebx
226 ; X86-NEXT: popl %ebp
228 %tmp = call i64 @llvm.ushl.sat.i64(i64 %x, i64 %y)
232 define i18 @func6(i16 %x, i16 %y) nounwind {
235 ; X64-NEXT: movl %esi, %ecx
236 ; X64-NEXT: movswl %di, %eax
237 ; X64-NEXT: shll $14, %eax
238 ; X64-NEXT: movl %eax, %edx
239 ; X64-NEXT: shll %cl, %edx
240 ; X64-NEXT: movl %edx, %esi
241 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
242 ; X64-NEXT: shrl %cl, %esi
243 ; X64-NEXT: cmpl %esi, %eax
244 ; X64-NEXT: movl $-1, %eax
245 ; X64-NEXT: cmovel %edx, %eax
246 ; X64-NEXT: shrl $14, %eax
251 ; X86-NEXT: pushl %esi
252 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
253 ; X86-NEXT: movswl {{[0-9]+}}(%esp), %eax
254 ; X86-NEXT: shll $14, %eax
255 ; X86-NEXT: movl %eax, %edx
256 ; X86-NEXT: shll %cl, %edx
257 ; X86-NEXT: movl %edx, %esi
258 ; X86-NEXT: shrl %cl, %esi
259 ; X86-NEXT: cmpl %esi, %eax
260 ; X86-NEXT: movl $-1, %eax
261 ; X86-NEXT: cmovel %edx, %eax
262 ; X86-NEXT: shrl $14, %eax
263 ; X86-NEXT: popl %esi
265 %x2 = sext i16 %x to i18
266 %y2 = sext i16 %y to i18
267 %tmp = call i18 @llvm.ushl.sat.i18(i18 %x2, i18 %y2)
271 define i32 @func7(i32 %x, i32 %y) nounwind {
274 ; X64-NEXT: movl %esi, %ecx
275 ; X64-NEXT: movl %edi, %edx
276 ; X64-NEXT: shll %cl, %edx
277 ; X64-NEXT: movl %edx, %eax
278 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
279 ; X64-NEXT: shrl %cl, %eax
280 ; X64-NEXT: cmpl %eax, %edi
281 ; X64-NEXT: movl $-1, %eax
282 ; X64-NEXT: cmovel %edx, %eax
287 ; X86-NEXT: pushl %esi
288 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
289 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
290 ; X86-NEXT: movl %eax, %edx
291 ; X86-NEXT: shll %cl, %edx
292 ; X86-NEXT: movl %edx, %esi
293 ; X86-NEXT: shrl %cl, %esi
294 ; X86-NEXT: cmpl %esi, %eax
295 ; X86-NEXT: movl $-1, %eax
296 ; X86-NEXT: cmovel %edx, %eax
297 ; X86-NEXT: popl %esi
299 %tmp = call i32 @llvm.ushl.sat.i32(i32 %x, i32 %y)
303 define i8 @func8(i8 %x, i8 %y) nounwind {
306 ; X64-NEXT: movl %esi, %ecx
307 ; X64-NEXT: movl %edi, %eax
308 ; X64-NEXT: shlb %cl, %al
309 ; X64-NEXT: movzbl %al, %edx
310 ; X64-NEXT: movl %edx, %eax
311 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
312 ; X64-NEXT: shrb %cl, %al
313 ; X64-NEXT: cmpb %al, %dil
314 ; X64-NEXT: movl $255, %eax
315 ; X64-NEXT: cmovel %edx, %eax
316 ; X64-NEXT: # kill: def $al killed $al killed $eax
321 ; X86-NEXT: pushl %esi
322 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
323 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
324 ; X86-NEXT: movl %eax, %edx
325 ; X86-NEXT: shlb %cl, %dl
326 ; X86-NEXT: movzbl %dl, %esi
327 ; X86-NEXT: shrb %cl, %dl
328 ; X86-NEXT: cmpb %dl, %al
329 ; X86-NEXT: movl $255, %eax
330 ; X86-NEXT: cmovel %esi, %eax
331 ; X86-NEXT: # kill: def $al killed $al killed $eax
332 ; X86-NEXT: popl %esi
334 %tmp = call i8 @llvm.ushl.sat.i8(i8 %x, i8 %y)