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: movzbl {{[0-9]+}}(%esp), %ecx
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 %esi
80 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
81 ; X86-NEXT: movsbl {{[0-9]+}}(%esp), %eax
82 ; X86-NEXT: addl %eax, %eax
83 ; X86-NEXT: movl %eax, %edx
84 ; X86-NEXT: shll %cl, %edx
85 ; X86-NEXT: movswl %dx, %esi
86 ; X86-NEXT: sarl %cl, %esi
87 ; X86-NEXT: xorl %ecx, %ecx
88 ; X86-NEXT: testw %ax, %ax
90 ; X86-NEXT: addl $32767, %ecx # imm = 0x7FFF
91 ; X86-NEXT: cmpw %si, %ax
92 ; X86-NEXT: cmovel %edx, %ecx
93 ; X86-NEXT: movswl %cx, %eax
95 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
98 %x2 = sext i8 %x to i15
99 %y2 = sext i8 %y to i15
100 %tmp = call i15 @llvm.sshl.sat.i15(i15 %x2, i15 %y2)
101 %tmp2 = sext i15 %tmp to i16
105 define i16 @func3(i15 %x, i8 %y) nounwind {
108 ; X64-NEXT: movl %esi, %ecx
109 ; X64-NEXT: shll $7, %ecx
110 ; X64-NEXT: addl %edi, %edi
111 ; X64-NEXT: movl %edi, %eax
112 ; X64-NEXT: shll %cl, %eax
113 ; X64-NEXT: movswl %ax, %edx
114 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
115 ; X64-NEXT: sarl %cl, %edx
116 ; X64-NEXT: xorl %ecx, %ecx
117 ; X64-NEXT: testw %di, %di
119 ; X64-NEXT: addl $32767, %ecx # imm = 0x7FFF
120 ; X64-NEXT: cmpw %dx, %di
121 ; X64-NEXT: cmovel %eax, %ecx
122 ; X64-NEXT: movswl %cx, %eax
123 ; X64-NEXT: shrl %eax
124 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
129 ; X86-NEXT: pushl %esi
130 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
131 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
132 ; X86-NEXT: shll $7, %ecx
133 ; X86-NEXT: addl %eax, %eax
134 ; X86-NEXT: movl %eax, %edx
135 ; X86-NEXT: shll %cl, %edx
136 ; X86-NEXT: movswl %dx, %esi
137 ; X86-NEXT: # kill: def $cl killed $cl killed $ecx
138 ; X86-NEXT: sarl %cl, %esi
139 ; X86-NEXT: xorl %ecx, %ecx
140 ; X86-NEXT: testw %ax, %ax
142 ; X86-NEXT: addl $32767, %ecx # imm = 0x7FFF
143 ; X86-NEXT: cmpw %si, %ax
144 ; X86-NEXT: cmovel %edx, %ecx
145 ; X86-NEXT: movswl %cx, %eax
146 ; X86-NEXT: shrl %eax
147 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
148 ; X86-NEXT: popl %esi
150 %y2 = sext i8 %y to i15
152 %tmp = call i15 @llvm.sshl.sat.i15(i15 %x, i15 %y3)
153 %tmp2 = sext i15 %tmp to i16
157 define i4 @func4(i4 %x, i4 %y) nounwind {
160 ; X64-NEXT: movl %esi, %ecx
161 ; X64-NEXT: andb $15, %cl
162 ; X64-NEXT: shlb $4, %dil
163 ; X64-NEXT: movl %edi, %eax
164 ; X64-NEXT: shlb %cl, %al
165 ; X64-NEXT: movzbl %al, %edx
166 ; X64-NEXT: movl %edx, %esi
167 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
168 ; X64-NEXT: sarb %cl, %sil
169 ; X64-NEXT: xorl %eax, %eax
170 ; X64-NEXT: testb %dil, %dil
172 ; X64-NEXT: addl $127, %eax
173 ; X64-NEXT: cmpb %sil, %dil
174 ; X64-NEXT: cmovel %edx, %eax
175 ; X64-NEXT: sarb $4, %al
176 ; X64-NEXT: # kill: def $al killed $al killed $eax
181 ; X86-NEXT: pushl %esi
182 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
183 ; X86-NEXT: andb $15, %cl
184 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %edx
185 ; X86-NEXT: shlb $4, %dl
186 ; X86-NEXT: movb %dl, %ch
187 ; X86-NEXT: shlb %cl, %ch
188 ; X86-NEXT: movzbl %ch, %esi
189 ; X86-NEXT: sarb %cl, %ch
190 ; X86-NEXT: xorl %eax, %eax
191 ; X86-NEXT: testb %dl, %dl
193 ; X86-NEXT: addl $127, %eax
194 ; X86-NEXT: cmpb %ch, %dl
195 ; X86-NEXT: cmovel %esi, %eax
196 ; X86-NEXT: sarb $4, %al
197 ; X86-NEXT: # kill: def $al killed $al killed $eax
198 ; X86-NEXT: popl %esi
200 %tmp = call i4 @llvm.sshl.sat.i4(i4 %x, i4 %y)
204 define i64 @func5(i64 %x, i64 %y) nounwind {
207 ; X64-NEXT: movq %rsi, %rcx
208 ; X64-NEXT: xorl %eax, %eax
209 ; X64-NEXT: testq %rdi, %rdi
211 ; X64-NEXT: movabsq $9223372036854775807, %rdx # imm = 0x7FFFFFFFFFFFFFFF
212 ; X64-NEXT: addq %rax, %rdx
213 ; X64-NEXT: movq %rdi, %rax
214 ; X64-NEXT: shlq %cl, %rax
215 ; X64-NEXT: movq %rax, %rsi
216 ; X64-NEXT: # kill: def $cl killed $cl killed $rcx
217 ; X64-NEXT: sarq %cl, %rsi
218 ; X64-NEXT: cmpq %rsi, %rdi
219 ; X64-NEXT: cmovneq %rdx, %rax
224 ; X86-NEXT: pushl %ebp
225 ; X86-NEXT: pushl %ebx
226 ; X86-NEXT: pushl %edi
227 ; X86-NEXT: pushl %esi
228 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
229 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
230 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
231 ; X86-NEXT: movl %edx, %ebx
232 ; X86-NEXT: shll %cl, %ebx
233 ; X86-NEXT: movl %eax, %esi
234 ; X86-NEXT: shldl %cl, %edx, %esi
235 ; X86-NEXT: xorl %edi, %edi
236 ; X86-NEXT: testb $32, %cl
237 ; X86-NEXT: cmovnel %ebx, %esi
238 ; X86-NEXT: cmovel %ebx, %edi
239 ; X86-NEXT: movl %esi, %edx
240 ; X86-NEXT: sarl %cl, %edx
241 ; X86-NEXT: movl %esi, %ebx
242 ; X86-NEXT: sarl $31, %ebx
243 ; X86-NEXT: testb $32, %cl
244 ; X86-NEXT: cmovel %edx, %ebx
245 ; X86-NEXT: movl %edi, %ebp
246 ; X86-NEXT: shrdl %cl, %esi, %ebp
247 ; X86-NEXT: testb $32, %cl
248 ; X86-NEXT: cmovnel %edx, %ebp
249 ; X86-NEXT: xorl %eax, %ebx
250 ; X86-NEXT: xorl {{[0-9]+}}(%esp), %ebp
251 ; X86-NEXT: sarl $31, %eax
252 ; X86-NEXT: movl %eax, %edx
253 ; X86-NEXT: xorl $2147483647, %edx # imm = 0x7FFFFFFF
254 ; X86-NEXT: orl %ebx, %ebp
255 ; X86-NEXT: notl %eax
256 ; X86-NEXT: cmovel %edi, %eax
257 ; X86-NEXT: cmovel %esi, %edx
258 ; X86-NEXT: popl %esi
259 ; X86-NEXT: popl %edi
260 ; X86-NEXT: popl %ebx
261 ; X86-NEXT: popl %ebp
263 %tmp = call i64 @llvm.sshl.sat.i64(i64 %x, i64 %y)
267 define i18 @func6(i16 %x, i16 %y) nounwind {
270 ; X64-NEXT: movl %esi, %ecx
271 ; X64-NEXT: movswl %di, %edx
272 ; X64-NEXT: shll $14, %edx
273 ; X64-NEXT: movl %edx, %esi
274 ; X64-NEXT: shll %cl, %esi
275 ; X64-NEXT: movl %esi, %edi
276 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
277 ; X64-NEXT: sarl %cl, %edi
278 ; X64-NEXT: xorl %eax, %eax
279 ; X64-NEXT: testl %edx, %edx
281 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
282 ; X64-NEXT: cmpl %edi, %edx
283 ; X64-NEXT: cmovel %esi, %eax
284 ; X64-NEXT: sarl $14, %eax
289 ; X86-NEXT: pushl %edi
290 ; X86-NEXT: pushl %esi
291 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
292 ; X86-NEXT: movswl {{[0-9]+}}(%esp), %edx
293 ; X86-NEXT: shll $14, %edx
294 ; X86-NEXT: movl %edx, %esi
295 ; X86-NEXT: shll %cl, %esi
296 ; X86-NEXT: movl %esi, %edi
297 ; X86-NEXT: sarl %cl, %edi
298 ; X86-NEXT: xorl %eax, %eax
299 ; X86-NEXT: testl %edx, %edx
301 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
302 ; X86-NEXT: cmpl %edi, %edx
303 ; X86-NEXT: cmovel %esi, %eax
304 ; X86-NEXT: sarl $14, %eax
305 ; X86-NEXT: popl %esi
306 ; X86-NEXT: popl %edi
308 %x2 = sext i16 %x to i18
309 %y2 = sext i16 %y to i18
310 %tmp = call i18 @llvm.sshl.sat.i18(i18 %x2, i18 %y2)
314 define i32 @func7(i32 %x, i32 %y) nounwind {
317 ; X64-NEXT: movl %esi, %ecx
318 ; X64-NEXT: movl %edi, %edx
319 ; X64-NEXT: shll %cl, %edx
320 ; X64-NEXT: movl %edx, %esi
321 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
322 ; X64-NEXT: sarl %cl, %esi
323 ; X64-NEXT: xorl %eax, %eax
324 ; X64-NEXT: testl %edi, %edi
326 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
327 ; X64-NEXT: cmpl %esi, %edi
328 ; X64-NEXT: cmovel %edx, %eax
333 ; X86-NEXT: pushl %edi
334 ; X86-NEXT: pushl %esi
335 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
336 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
337 ; X86-NEXT: movl %edx, %esi
338 ; X86-NEXT: shll %cl, %esi
339 ; X86-NEXT: movl %esi, %edi
340 ; X86-NEXT: sarl %cl, %edi
341 ; X86-NEXT: xorl %eax, %eax
342 ; X86-NEXT: testl %edx, %edx
344 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
345 ; X86-NEXT: cmpl %edi, %edx
346 ; X86-NEXT: cmovel %esi, %eax
347 ; X86-NEXT: popl %esi
348 ; X86-NEXT: popl %edi
350 %tmp = call i32 @llvm.sshl.sat.i32(i32 %x, i32 %y)
354 define i8 @func8(i8 %x, i8 %y) nounwind {
357 ; X64-NEXT: movl %esi, %ecx
358 ; X64-NEXT: movl %edi, %eax
359 ; X64-NEXT: shlb %cl, %al
360 ; X64-NEXT: movzbl %al, %edx
361 ; X64-NEXT: movl %edx, %esi
362 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
363 ; X64-NEXT: sarb %cl, %sil
364 ; X64-NEXT: xorl %eax, %eax
365 ; X64-NEXT: testb %dil, %dil
367 ; X64-NEXT: addl $127, %eax
368 ; X64-NEXT: cmpb %sil, %dil
369 ; X64-NEXT: cmovel %edx, %eax
370 ; X64-NEXT: # kill: def $al killed $al killed $eax
375 ; X86-NEXT: pushl %esi
376 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
377 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %edx
378 ; X86-NEXT: movb %dl, %ch
379 ; X86-NEXT: shlb %cl, %ch
380 ; X86-NEXT: movzbl %ch, %esi
381 ; X86-NEXT: sarb %cl, %ch
382 ; X86-NEXT: xorl %eax, %eax
383 ; X86-NEXT: testb %dl, %dl
385 ; X86-NEXT: addl $127, %eax
386 ; X86-NEXT: cmpb %ch, %dl
387 ; X86-NEXT: cmovel %esi, %eax
388 ; X86-NEXT: # kill: def $al killed $al killed $eax
389 ; X86-NEXT: popl %esi
391 %tmp = call i8 @llvm.sshl.sat.i8(i8 %x, i8 %y)