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, %eax
18 ; X64-NEXT: shll %cl, %eax
19 ; X64-NEXT: movzwl %ax, %edx
20 ; X64-NEXT: movl %edx, %eax
21 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
22 ; X64-NEXT: shrl %cl, %eax
23 ; X64-NEXT: cmpw %ax, %di
24 ; X64-NEXT: movl $65535, %eax # imm = 0xFFFF
25 ; X64-NEXT: cmovel %edx, %eax
26 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
31 ; X86-NEXT: pushl %esi
32 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
33 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
34 ; X86-NEXT: movl %eax, %edx
35 ; X86-NEXT: shll %cl, %edx
36 ; X86-NEXT: movzwl %dx, %edx
37 ; X86-NEXT: movl %edx, %esi
38 ; X86-NEXT: shrl %cl, %esi
39 ; X86-NEXT: cmpw %si, %ax
40 ; X86-NEXT: movl $65535, %eax # imm = 0xFFFF
41 ; X86-NEXT: cmovel %edx, %eax
42 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
45 %tmp = call i16 @llvm.ushl.sat.i16(i16 %x, i16 %y)
49 define i16 @func2(i8 %x, i8 %y) nounwind {
52 ; X64-NEXT: movl %esi, %ecx
53 ; X64-NEXT: movsbl %dil, %eax
54 ; X64-NEXT: addl %eax, %eax
55 ; X64-NEXT: movl %eax, %edx
56 ; X64-NEXT: shll %cl, %edx
57 ; X64-NEXT: movzwl %dx, %edx
58 ; X64-NEXT: movl %edx, %esi
59 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
60 ; X64-NEXT: shrl %cl, %esi
61 ; X64-NEXT: cmpw %si, %ax
62 ; X64-NEXT: movl $65535, %eax # imm = 0xFFFF
63 ; X64-NEXT: cmovel %edx, %eax
66 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
71 ; X86-NEXT: pushl %esi
72 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
73 ; X86-NEXT: movsbl {{[0-9]+}}(%esp), %eax
74 ; X86-NEXT: addl %eax, %eax
75 ; X86-NEXT: movl %eax, %edx
76 ; X86-NEXT: shll %cl, %edx
77 ; X86-NEXT: movzwl %dx, %edx
78 ; X86-NEXT: movl %edx, %esi
79 ; X86-NEXT: shrl %cl, %esi
80 ; X86-NEXT: cmpw %si, %ax
81 ; X86-NEXT: movl $65535, %eax # imm = 0xFFFF
82 ; X86-NEXT: cmovel %edx, %eax
85 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
88 %x2 = sext i8 %x to i15
89 %y2 = sext i8 %y to i15
90 %tmp = call i15 @llvm.ushl.sat.i15(i15 %x2, i15 %y2)
91 %tmp2 = sext i15 %tmp to i16
95 define i16 @func3(i15 %x, i8 %y) nounwind {
98 ; X64-NEXT: movl %esi, %ecx
99 ; X64-NEXT: shll $7, %ecx
100 ; X64-NEXT: addl %edi, %edi
101 ; X64-NEXT: movl %edi, %eax
102 ; X64-NEXT: shll %cl, %eax
103 ; X64-NEXT: movzwl %ax, %eax
104 ; X64-NEXT: movl %eax, %edx
105 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
106 ; X64-NEXT: shrl %cl, %edx
107 ; X64-NEXT: cmpw %dx, %di
108 ; X64-NEXT: movl $65535, %ecx # imm = 0xFFFF
109 ; X64-NEXT: cmovel %eax, %ecx
110 ; X64-NEXT: movswl %cx, %eax
111 ; X64-NEXT: shrl %eax
112 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
117 ; X86-NEXT: pushl %esi
118 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
119 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
120 ; X86-NEXT: shll $7, %ecx
121 ; X86-NEXT: addl %eax, %eax
122 ; X86-NEXT: movl %eax, %edx
123 ; X86-NEXT: shll %cl, %edx
124 ; X86-NEXT: movzwl %dx, %edx
125 ; X86-NEXT: movl %edx, %esi
126 ; X86-NEXT: # kill: def $cl killed $cl killed $ecx
127 ; X86-NEXT: shrl %cl, %esi
128 ; X86-NEXT: cmpw %si, %ax
129 ; X86-NEXT: movl $65535, %eax # imm = 0xFFFF
130 ; X86-NEXT: cmovel %edx, %eax
132 ; X86-NEXT: shrl %eax
133 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
134 ; X86-NEXT: popl %esi
136 %y2 = sext i8 %y to i15
138 %tmp = call i15 @llvm.ushl.sat.i15(i15 %x, i15 %y3)
139 %tmp2 = sext i15 %tmp to i16
143 define i4 @func4(i4 %x, i4 %y) nounwind {
146 ; X64-NEXT: movl %esi, %ecx
147 ; X64-NEXT: andb $15, %cl
148 ; X64-NEXT: shlb $4, %dil
149 ; X64-NEXT: movl %edi, %eax
150 ; X64-NEXT: shlb %cl, %al
151 ; X64-NEXT: movzbl %al, %edx
152 ; X64-NEXT: movl %edx, %eax
153 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
154 ; X64-NEXT: shrb %cl, %al
155 ; X64-NEXT: cmpb %al, %dil
156 ; X64-NEXT: movl $255, %eax
157 ; X64-NEXT: cmovel %edx, %eax
158 ; X64-NEXT: shrb $4, %al
159 ; X64-NEXT: # kill: def $al killed $al killed $eax
164 ; X86-NEXT: pushl %esi
165 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
166 ; X86-NEXT: andb $15, %cl
167 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
168 ; X86-NEXT: shlb $4, %al
169 ; X86-NEXT: movl %eax, %edx
170 ; X86-NEXT: shlb %cl, %dl
171 ; X86-NEXT: movzbl %dl, %esi
172 ; X86-NEXT: shrb %cl, %dl
173 ; X86-NEXT: cmpb %dl, %al
174 ; X86-NEXT: movl $255, %eax
175 ; X86-NEXT: cmovel %esi, %eax
176 ; X86-NEXT: shrb $4, %al
177 ; X86-NEXT: # kill: def $al killed $al killed $eax
178 ; X86-NEXT: popl %esi
180 %tmp = call i4 @llvm.ushl.sat.i4(i4 %x, i4 %y)
184 define i64 @func5(i64 %x, i64 %y) nounwind {
187 ; X64-NEXT: movq %rsi, %rcx
188 ; X64-NEXT: movq %rdi, %rdx
189 ; X64-NEXT: shlq %cl, %rdx
190 ; X64-NEXT: movq %rdx, %rax
191 ; X64-NEXT: # kill: def $cl killed $cl killed $rcx
192 ; X64-NEXT: shrq %cl, %rax
193 ; X64-NEXT: cmpq %rax, %rdi
194 ; X64-NEXT: movq $-1, %rax
195 ; X64-NEXT: cmoveq %rdx, %rax
200 ; X86-NEXT: pushl %ebp
201 ; X86-NEXT: pushl %ebx
202 ; X86-NEXT: pushl %edi
203 ; X86-NEXT: pushl %esi
204 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
205 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
206 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
207 ; X86-NEXT: movl %edi, %esi
208 ; X86-NEXT: shll %cl, %esi
209 ; X86-NEXT: shldl %cl, %edi, %edx
210 ; X86-NEXT: xorl %ebx, %ebx
211 ; X86-NEXT: testb $32, %cl
212 ; X86-NEXT: cmovnel %esi, %edx
213 ; X86-NEXT: cmovnel %ebx, %esi
214 ; X86-NEXT: movl %edx, %ebp
215 ; X86-NEXT: shrl %cl, %ebp
216 ; X86-NEXT: testb $32, %cl
217 ; X86-NEXT: cmovel %ebp, %ebx
218 ; X86-NEXT: movl %esi, %eax
219 ; X86-NEXT: shrdl %cl, %edx, %eax
220 ; X86-NEXT: testb $32, %cl
221 ; X86-NEXT: cmovnel %ebp, %eax
222 ; X86-NEXT: xorl %edi, %eax
223 ; X86-NEXT: xorl {{[0-9]+}}(%esp), %ebx
224 ; X86-NEXT: orl %eax, %ebx
225 ; X86-NEXT: movl $-1, %eax
226 ; X86-NEXT: cmovnel %eax, %esi
227 ; X86-NEXT: cmovnel %eax, %edx
228 ; X86-NEXT: movl %esi, %eax
229 ; X86-NEXT: popl %esi
230 ; X86-NEXT: popl %edi
231 ; X86-NEXT: popl %ebx
232 ; X86-NEXT: popl %ebp
234 %tmp = call i64 @llvm.ushl.sat.i64(i64 %x, i64 %y)
238 define i18 @func6(i16 %x, i16 %y) nounwind {
241 ; X64-NEXT: movl %esi, %ecx
242 ; X64-NEXT: movswl %di, %eax
243 ; X64-NEXT: shll $14, %eax
244 ; X64-NEXT: movl %eax, %edx
245 ; X64-NEXT: shll %cl, %edx
246 ; X64-NEXT: movl %edx, %esi
247 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
248 ; X64-NEXT: shrl %cl, %esi
249 ; X64-NEXT: cmpl %esi, %eax
250 ; X64-NEXT: movl $-1, %eax
251 ; X64-NEXT: cmovel %edx, %eax
252 ; X64-NEXT: shrl $14, %eax
257 ; X86-NEXT: pushl %esi
258 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
259 ; X86-NEXT: movswl {{[0-9]+}}(%esp), %eax
260 ; X86-NEXT: shll $14, %eax
261 ; X86-NEXT: movl %eax, %edx
262 ; X86-NEXT: shll %cl, %edx
263 ; X86-NEXT: movl %edx, %esi
264 ; X86-NEXT: shrl %cl, %esi
265 ; X86-NEXT: cmpl %esi, %eax
266 ; X86-NEXT: movl $-1, %eax
267 ; X86-NEXT: cmovel %edx, %eax
268 ; X86-NEXT: shrl $14, %eax
269 ; X86-NEXT: popl %esi
271 %x2 = sext i16 %x to i18
272 %y2 = sext i16 %y to i18
273 %tmp = call i18 @llvm.ushl.sat.i18(i18 %x2, i18 %y2)
277 define i32 @func7(i32 %x, i32 %y) nounwind {
280 ; X64-NEXT: movl %esi, %ecx
281 ; X64-NEXT: movl %edi, %edx
282 ; X64-NEXT: shll %cl, %edx
283 ; X64-NEXT: movl %edx, %eax
284 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
285 ; X64-NEXT: shrl %cl, %eax
286 ; X64-NEXT: cmpl %eax, %edi
287 ; X64-NEXT: movl $-1, %eax
288 ; X64-NEXT: cmovel %edx, %eax
293 ; X86-NEXT: pushl %esi
294 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
295 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
296 ; X86-NEXT: movl %eax, %edx
297 ; X86-NEXT: shll %cl, %edx
298 ; X86-NEXT: movl %edx, %esi
299 ; X86-NEXT: shrl %cl, %esi
300 ; X86-NEXT: cmpl %esi, %eax
301 ; X86-NEXT: movl $-1, %eax
302 ; X86-NEXT: cmovel %edx, %eax
303 ; X86-NEXT: popl %esi
305 %tmp = call i32 @llvm.ushl.sat.i32(i32 %x, i32 %y)
309 define i8 @func8(i8 %x, i8 %y) nounwind {
312 ; X64-NEXT: movl %esi, %ecx
313 ; X64-NEXT: movl %edi, %eax
314 ; X64-NEXT: shlb %cl, %al
315 ; X64-NEXT: movzbl %al, %edx
316 ; X64-NEXT: movl %edx, %eax
317 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
318 ; X64-NEXT: shrb %cl, %al
319 ; X64-NEXT: cmpb %al, %dil
320 ; X64-NEXT: movl $255, %eax
321 ; X64-NEXT: cmovel %edx, %eax
322 ; X64-NEXT: # kill: def $al killed $al killed $eax
327 ; X86-NEXT: pushl %esi
328 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
329 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
330 ; X86-NEXT: movl %eax, %edx
331 ; X86-NEXT: shlb %cl, %dl
332 ; X86-NEXT: movzbl %dl, %esi
333 ; X86-NEXT: shrb %cl, %dl
334 ; X86-NEXT: cmpb %dl, %al
335 ; X86-NEXT: movl $255, %eax
336 ; X86-NEXT: cmovel %esi, %eax
337 ; X86-NEXT: # kill: def $al killed $al killed $eax
338 ; X86-NEXT: popl %esi
340 %tmp = call i8 @llvm.ushl.sat.i8(i8 %x, i8 %y)