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.sshl.sat.i4 (i4, i4)
6 declare i8 @llvm.sshl.sat.i8 (i8, i8)
7 declare i15 @llvm.sshl.sat.i15 (i15, i15)
8 declare i16 @llvm.sshl.sat.i16 (i16, i16)
9 declare i18 @llvm.sshl.sat.i18 (i18, i18)
10 declare i32 @llvm.sshl.sat.i32 (i32, i32)
11 declare i64 @llvm.sshl.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: movswl %dx, %esi
20 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
21 ; X64-NEXT: sarl %cl, %esi
22 ; X64-NEXT: xorl %eax, %eax
23 ; X64-NEXT: testw %di, %di
25 ; X64-NEXT: addl $32767, %eax # imm = 0x7FFF
26 ; X64-NEXT: cmpw %si, %di
27 ; X64-NEXT: cmovel %edx, %eax
28 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
33 ; X86-NEXT: pushl %edi
34 ; X86-NEXT: pushl %esi
35 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
36 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
37 ; X86-NEXT: movl %edx, %esi
38 ; X86-NEXT: shll %cl, %esi
39 ; X86-NEXT: movswl %si, %edi
40 ; X86-NEXT: sarl %cl, %edi
41 ; X86-NEXT: xorl %eax, %eax
42 ; X86-NEXT: testw %dx, %dx
44 ; X86-NEXT: addl $32767, %eax # imm = 0x7FFF
45 ; X86-NEXT: cmpw %di, %dx
46 ; X86-NEXT: cmovel %esi, %eax
47 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
51 %tmp = call i16 @llvm.sshl.sat.i16(i16 %x, i16 %y)
55 define i16 @func2(i8 %x, i8 %y) nounwind {
58 ; X64-NEXT: movl %esi, %ecx
59 ; X64-NEXT: movsbl %dil, %eax
60 ; X64-NEXT: addl %eax, %eax
61 ; X64-NEXT: xorl %edx, %edx
62 ; X64-NEXT: testw %ax, %ax
64 ; X64-NEXT: addl $32767, %edx # imm = 0x7FFF
65 ; X64-NEXT: movl %eax, %esi
66 ; X64-NEXT: shll %cl, %esi
67 ; X64-NEXT: movswl %si, %edi
68 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
69 ; X64-NEXT: sarl %cl, %edi
70 ; X64-NEXT: cmpw %di, %ax
71 ; X64-NEXT: cmovnel %edx, %esi
72 ; X64-NEXT: movswl %si, %eax
74 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
79 ; X86-NEXT: pushl %edi
80 ; X86-NEXT: pushl %esi
81 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
82 ; X86-NEXT: movsbl {{[0-9]+}}(%esp), %edx
83 ; X86-NEXT: addl %edx, %edx
84 ; X86-NEXT: movl %edx, %esi
85 ; X86-NEXT: shll %cl, %esi
86 ; X86-NEXT: movswl %si, %edi
87 ; X86-NEXT: sarl %cl, %edi
88 ; X86-NEXT: xorl %eax, %eax
89 ; X86-NEXT: testw %dx, %dx
91 ; X86-NEXT: addl $32767, %eax # imm = 0x7FFF
92 ; X86-NEXT: cmpw %di, %dx
93 ; X86-NEXT: cmovel %esi, %eax
96 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
100 %x2 = sext i8 %x to i15
101 %y2 = sext i8 %y to i15
102 %tmp = call i15 @llvm.sshl.sat.i15(i15 %x2, i15 %y2)
103 %tmp2 = sext i15 %tmp to i16
107 define i16 @func3(i15 %x, i8 %y) nounwind {
110 ; X64-NEXT: movl %esi, %ecx
111 ; X64-NEXT: shll $7, %ecx
112 ; X64-NEXT: addl %edi, %edi
113 ; X64-NEXT: movl %edi, %eax
114 ; X64-NEXT: shll %cl, %eax
115 ; X64-NEXT: movswl %ax, %edx
116 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
117 ; X64-NEXT: sarl %cl, %edx
118 ; X64-NEXT: xorl %ecx, %ecx
119 ; X64-NEXT: testw %di, %di
121 ; X64-NEXT: addl $32767, %ecx # imm = 0x7FFF
122 ; X64-NEXT: cmpw %dx, %di
123 ; X64-NEXT: cmovel %eax, %ecx
124 ; X64-NEXT: movswl %cx, %eax
125 ; X64-NEXT: shrl %eax
126 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
131 ; X86-NEXT: pushl %edi
132 ; X86-NEXT: pushl %esi
133 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
134 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
135 ; X86-NEXT: shll $7, %ecx
136 ; X86-NEXT: addl %edx, %edx
137 ; X86-NEXT: movl %edx, %esi
138 ; X86-NEXT: shll %cl, %esi
139 ; X86-NEXT: movswl %si, %edi
140 ; X86-NEXT: # kill: def $cl killed $cl killed $ecx
141 ; X86-NEXT: sarl %cl, %edi
142 ; X86-NEXT: xorl %eax, %eax
143 ; X86-NEXT: testw %dx, %dx
145 ; X86-NEXT: addl $32767, %eax # imm = 0x7FFF
146 ; X86-NEXT: cmpw %di, %dx
147 ; X86-NEXT: cmovel %esi, %eax
149 ; X86-NEXT: shrl %eax
150 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
151 ; X86-NEXT: popl %esi
152 ; X86-NEXT: popl %edi
154 %y2 = sext i8 %y to i15
156 %tmp = call i15 @llvm.sshl.sat.i15(i15 %x, i15 %y3)
157 %tmp2 = sext i15 %tmp to i16
161 define i4 @func4(i4 %x, i4 %y) nounwind {
164 ; X64-NEXT: movl %esi, %ecx
165 ; X64-NEXT: andb $15, %cl
166 ; X64-NEXT: shlb $4, %dil
167 ; X64-NEXT: movl %edi, %eax
168 ; X64-NEXT: shlb %cl, %al
169 ; X64-NEXT: movzbl %al, %esi
170 ; X64-NEXT: movl %esi, %edx
171 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
172 ; X64-NEXT: sarb %cl, %dl
173 ; X64-NEXT: xorl %eax, %eax
174 ; X64-NEXT: testb %dil, %dil
176 ; X64-NEXT: addl $127, %eax
177 ; X64-NEXT: cmpb %dl, %dil
178 ; X64-NEXT: cmovel %esi, %eax
179 ; X64-NEXT: sarb $4, %al
180 ; X64-NEXT: # kill: def $al killed $al killed $eax
185 ; X86-NEXT: pushl %esi
186 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
187 ; X86-NEXT: andb $15, %cl
188 ; X86-NEXT: movb {{[0-9]+}}(%esp), %dl
189 ; X86-NEXT: shlb $4, %dl
190 ; X86-NEXT: movb %dl, %ch
191 ; X86-NEXT: shlb %cl, %ch
192 ; X86-NEXT: movzbl %ch, %esi
193 ; X86-NEXT: sarb %cl, %ch
194 ; X86-NEXT: xorl %eax, %eax
195 ; X86-NEXT: testb %dl, %dl
197 ; X86-NEXT: addl $127, %eax
198 ; X86-NEXT: cmpb %ch, %dl
199 ; X86-NEXT: cmovel %esi, %eax
200 ; X86-NEXT: sarb $4, %al
201 ; X86-NEXT: # kill: def $al killed $al killed $eax
202 ; X86-NEXT: popl %esi
204 %tmp = call i4 @llvm.sshl.sat.i4(i4 %x, i4 %y)
208 define i64 @func5(i64 %x, i64 %y) nounwind {
211 ; X64-NEXT: movq %rsi, %rcx
212 ; X64-NEXT: xorl %edx, %edx
213 ; X64-NEXT: testq %rdi, %rdi
215 ; X64-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
216 ; X64-NEXT: addq %rdx, %rax
217 ; X64-NEXT: movq %rdi, %rdx
218 ; X64-NEXT: shlq %cl, %rdx
219 ; X64-NEXT: movq %rdx, %rsi
220 ; X64-NEXT: # kill: def $cl killed $cl killed $rcx
221 ; X64-NEXT: sarq %cl, %rsi
222 ; X64-NEXT: cmpq %rsi, %rdi
223 ; X64-NEXT: cmoveq %rdx, %rax
228 ; X86-NEXT: pushl %ebp
229 ; X86-NEXT: pushl %ebx
230 ; X86-NEXT: pushl %edi
231 ; X86-NEXT: pushl %esi
232 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
233 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
234 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
235 ; X86-NEXT: movl %eax, %ebp
236 ; X86-NEXT: shll %cl, %ebp
237 ; X86-NEXT: shldl %cl, %eax, %ebx
238 ; X86-NEXT: xorl %edx, %edx
239 ; X86-NEXT: testb $32, %cl
240 ; X86-NEXT: cmovnel %ebp, %ebx
241 ; X86-NEXT: cmovnel %edx, %ebp
242 ; X86-NEXT: movl %ebx, %edx
243 ; X86-NEXT: sarl %cl, %edx
244 ; X86-NEXT: movl %ebx, %edi
245 ; X86-NEXT: sarl $31, %edi
246 ; X86-NEXT: testb $32, %cl
247 ; X86-NEXT: cmovel %edx, %edi
248 ; X86-NEXT: movl %ebp, %esi
249 ; X86-NEXT: shrdl %cl, %ebx, %esi
250 ; X86-NEXT: testb $32, %cl
251 ; X86-NEXT: cmovnel %edx, %esi
252 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
253 ; X86-NEXT: xorl %ecx, %edi
254 ; X86-NEXT: xorl %eax, %esi
255 ; X86-NEXT: xorl %edx, %edx
256 ; X86-NEXT: testl %ecx, %ecx
257 ; X86-NEXT: movl $-1, %eax
258 ; X86-NEXT: movl $0, %ecx
259 ; X86-NEXT: cmovsl %ecx, %eax
261 ; X86-NEXT: addl $2147483647, %edx # imm = 0x7FFFFFFF
262 ; X86-NEXT: orl %edi, %esi
263 ; X86-NEXT: cmovel %ebp, %eax
264 ; X86-NEXT: cmovel %ebx, %edx
265 ; X86-NEXT: popl %esi
266 ; X86-NEXT: popl %edi
267 ; X86-NEXT: popl %ebx
268 ; X86-NEXT: popl %ebp
270 %tmp = call i64 @llvm.sshl.sat.i64(i64 %x, i64 %y)
274 define i18 @func6(i16 %x, i16 %y) nounwind {
277 ; X64-NEXT: movl %esi, %ecx
278 ; X64-NEXT: movswl %di, %edx
279 ; X64-NEXT: shll $14, %edx
280 ; X64-NEXT: movl %edx, %esi
281 ; X64-NEXT: shll %cl, %esi
282 ; X64-NEXT: movl %esi, %edi
283 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
284 ; X64-NEXT: sarl %cl, %edi
285 ; X64-NEXT: xorl %eax, %eax
286 ; X64-NEXT: testl %edx, %edx
288 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
289 ; X64-NEXT: cmpl %edi, %edx
290 ; X64-NEXT: cmovel %esi, %eax
291 ; X64-NEXT: sarl $14, %eax
296 ; X86-NEXT: pushl %edi
297 ; X86-NEXT: pushl %esi
298 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
299 ; X86-NEXT: movswl {{[0-9]+}}(%esp), %edx
300 ; X86-NEXT: shll $14, %edx
301 ; X86-NEXT: movl %edx, %esi
302 ; X86-NEXT: shll %cl, %esi
303 ; X86-NEXT: movl %esi, %edi
304 ; X86-NEXT: sarl %cl, %edi
305 ; X86-NEXT: xorl %eax, %eax
306 ; X86-NEXT: testl %edx, %edx
308 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
309 ; X86-NEXT: cmpl %edi, %edx
310 ; X86-NEXT: cmovel %esi, %eax
311 ; X86-NEXT: sarl $14, %eax
312 ; X86-NEXT: popl %esi
313 ; X86-NEXT: popl %edi
315 %x2 = sext i16 %x to i18
316 %y2 = sext i16 %y to i18
317 %tmp = call i18 @llvm.sshl.sat.i18(i18 %x2, i18 %y2)
321 define i32 @func7(i32 %x, i32 %y) nounwind {
324 ; X64-NEXT: movl %esi, %ecx
325 ; X64-NEXT: movl %edi, %edx
326 ; X64-NEXT: shll %cl, %edx
327 ; X64-NEXT: movl %edx, %esi
328 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
329 ; X64-NEXT: sarl %cl, %esi
330 ; X64-NEXT: xorl %eax, %eax
331 ; X64-NEXT: testl %edi, %edi
333 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
334 ; X64-NEXT: cmpl %esi, %edi
335 ; X64-NEXT: cmovel %edx, %eax
340 ; X86-NEXT: pushl %edi
341 ; X86-NEXT: pushl %esi
342 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
343 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
344 ; X86-NEXT: movl %edx, %esi
345 ; X86-NEXT: shll %cl, %esi
346 ; X86-NEXT: movl %esi, %edi
347 ; X86-NEXT: sarl %cl, %edi
348 ; X86-NEXT: xorl %eax, %eax
349 ; X86-NEXT: testl %edx, %edx
351 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
352 ; X86-NEXT: cmpl %edi, %edx
353 ; X86-NEXT: cmovel %esi, %eax
354 ; X86-NEXT: popl %esi
355 ; X86-NEXT: popl %edi
357 %tmp = call i32 @llvm.sshl.sat.i32(i32 %x, i32 %y)
361 define i8 @func8(i8 %x, i8 %y) nounwind {
364 ; X64-NEXT: movl %esi, %ecx
365 ; X64-NEXT: movl %edi, %eax
366 ; X64-NEXT: shlb %cl, %al
367 ; X64-NEXT: movzbl %al, %esi
368 ; X64-NEXT: movl %esi, %edx
369 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
370 ; X64-NEXT: sarb %cl, %dl
371 ; X64-NEXT: xorl %eax, %eax
372 ; X64-NEXT: testb %dil, %dil
374 ; X64-NEXT: addl $127, %eax
375 ; X64-NEXT: cmpb %dl, %dil
376 ; X64-NEXT: cmovel %esi, %eax
377 ; X64-NEXT: # kill: def $al killed $al killed $eax
382 ; X86-NEXT: pushl %esi
383 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
384 ; X86-NEXT: movb {{[0-9]+}}(%esp), %dl
385 ; X86-NEXT: movb %dl, %ch
386 ; X86-NEXT: shlb %cl, %ch
387 ; X86-NEXT: movzbl %ch, %esi
388 ; X86-NEXT: sarb %cl, %ch
389 ; X86-NEXT: xorl %eax, %eax
390 ; X86-NEXT: testb %dl, %dl
392 ; X86-NEXT: addl $127, %eax
393 ; X86-NEXT: cmpb %ch, %dl
394 ; X86-NEXT: cmovel %esi, %eax
395 ; X86-NEXT: # kill: def $al killed $al killed $eax
396 ; X86-NEXT: popl %esi
398 %tmp = call i8 @llvm.sshl.sat.i8(i8 %x, i8 %y)