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.smul.fix.sat.i4 (i4, i4, i32)
6 declare i32 @llvm.smul.fix.sat.i32 (i32, i32, i32)
7 declare i64 @llvm.smul.fix.sat.i64 (i64, i64, i32)
8 declare <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32>, <4 x i32>, i32)
10 define i32 @func(i32 %x, i32 %y) nounwind {
13 ; X64-NEXT: movslq %esi, %rax
14 ; X64-NEXT: movslq %edi, %rcx
15 ; X64-NEXT: imulq %rax, %rcx
16 ; X64-NEXT: movq %rcx, %rax
17 ; X64-NEXT: shrq $32, %rax
18 ; X64-NEXT: shrdl $2, %eax, %ecx
19 ; X64-NEXT: cmpl $2, %eax
20 ; X64-NEXT: movl $2147483647, %edx # imm = 0x7FFFFFFF
21 ; X64-NEXT: cmovll %ecx, %edx
22 ; X64-NEXT: cmpl $-2, %eax
23 ; X64-NEXT: movl $-2147483648, %eax # imm = 0x80000000
24 ; X64-NEXT: cmovgel %edx, %eax
29 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
30 ; X86-NEXT: imull {{[0-9]+}}(%esp)
31 ; X86-NEXT: shrdl $2, %edx, %eax
32 ; X86-NEXT: cmpl $2, %edx
33 ; X86-NEXT: movl $2147483647, %ecx # imm = 0x7FFFFFFF
34 ; X86-NEXT: cmovgel %ecx, %eax
35 ; X86-NEXT: cmpl $-2, %edx
36 ; X86-NEXT: movl $-2147483648, %ecx # imm = 0x80000000
37 ; X86-NEXT: cmovll %ecx, %eax
39 %tmp = call i32 @llvm.smul.fix.sat.i32(i32 %x, i32 %y, i32 2)
43 define i64 @func2(i64 %x, i64 %y) nounwind {
46 ; X64-NEXT: movq %rdi, %rax
47 ; X64-NEXT: imulq %rsi
48 ; X64-NEXT: shrdq $2, %rdx, %rax
49 ; X64-NEXT: cmpq $2, %rdx
50 ; X64-NEXT: movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
51 ; X64-NEXT: cmovgeq %rcx, %rax
52 ; X64-NEXT: cmpq $-2, %rdx
53 ; X64-NEXT: movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
54 ; X64-NEXT: cmovlq %rcx, %rax
59 ; X86-NEXT: pushl %ebp
60 ; X86-NEXT: pushl %ebx
61 ; X86-NEXT: pushl %edi
62 ; X86-NEXT: pushl %esi
63 ; X86-NEXT: subl $8, %esp
64 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
65 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
66 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
67 ; X86-NEXT: movl %ecx, %eax
69 ; X86-NEXT: movl %edx, %edi
70 ; X86-NEXT: movl %eax, %ebp
71 ; X86-NEXT: movl %ecx, %eax
73 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
74 ; X86-NEXT: addl %edx, %ebp
75 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
76 ; X86-NEXT: adcl $0, %edi
77 ; X86-NEXT: movl %ecx, %eax
78 ; X86-NEXT: imull %esi
79 ; X86-NEXT: movl %edx, %esi
80 ; X86-NEXT: movl %eax, (%esp) # 4-byte Spill
81 ; X86-NEXT: movl %ecx, %eax
83 ; X86-NEXT: movl %eax, %ebx
84 ; X86-NEXT: addl %ebp, %ebx
85 ; X86-NEXT: adcl %edi, %edx
86 ; X86-NEXT: adcl $0, %esi
87 ; X86-NEXT: addl (%esp), %edx # 4-byte Folded Reload
88 ; X86-NEXT: adcl $0, %esi
89 ; X86-NEXT: movl %edx, %edi
90 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edi
91 ; X86-NEXT: movl %esi, %ebp
92 ; X86-NEXT: sbbl $0, %ebp
93 ; X86-NEXT: testl %ecx, %ecx
94 ; X86-NEXT: cmovnsl %esi, %ebp
95 ; X86-NEXT: cmovnsl %edx, %edi
96 ; X86-NEXT: movl %edi, %ecx
97 ; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx
98 ; X86-NEXT: movl %ebp, %edx
99 ; X86-NEXT: sbbl $0, %edx
100 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
101 ; X86-NEXT: cmovnsl %ebp, %edx
102 ; X86-NEXT: cmovnsl %edi, %ecx
103 ; X86-NEXT: testl %edx, %edx
105 ; X86-NEXT: sete (%esp) # 1-byte Folded Spill
106 ; X86-NEXT: cmpl $2, %ecx
107 ; X86-NEXT: setae %al
108 ; X86-NEXT: andb (%esp), %al # 1-byte Folded Reload
109 ; X86-NEXT: orb %ah, %al
110 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebp # 4-byte Reload
111 ; X86-NEXT: shrdl $2, %ebx, %ebp
112 ; X86-NEXT: shrdl $2, %ecx, %ebx
113 ; X86-NEXT: testb %al, %al
114 ; X86-NEXT: movl $2147483647, %esi # imm = 0x7FFFFFFF
115 ; X86-NEXT: cmovel %ebx, %esi
116 ; X86-NEXT: movl $-1, %edi
117 ; X86-NEXT: cmovel %ebp, %edi
118 ; X86-NEXT: cmpl $-1, %edx
121 ; X86-NEXT: cmpl $-2, %ecx
123 ; X86-NEXT: andb %al, %cl
124 ; X86-NEXT: xorl %eax, %eax
125 ; X86-NEXT: orb %dl, %cl
126 ; X86-NEXT: cmovel %edi, %eax
127 ; X86-NEXT: movl $-2147483648, %edx # imm = 0x80000000
128 ; X86-NEXT: cmovel %esi, %edx
129 ; X86-NEXT: addl $8, %esp
130 ; X86-NEXT: popl %esi
131 ; X86-NEXT: popl %edi
132 ; X86-NEXT: popl %ebx
133 ; X86-NEXT: popl %ebp
135 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 2)
139 define i4 @func3(i4 %x, i4 %y) nounwind {
142 ; X64-NEXT: shlb $4, %sil
143 ; X64-NEXT: sarb $4, %sil
144 ; X64-NEXT: shlb $4, %dil
145 ; X64-NEXT: movsbl %dil, %eax
146 ; X64-NEXT: movsbl %sil, %ecx
147 ; X64-NEXT: imull %eax, %ecx
148 ; X64-NEXT: movl %ecx, %eax
149 ; X64-NEXT: shrb $2, %al
150 ; X64-NEXT: shrl $8, %ecx
151 ; X64-NEXT: movl %ecx, %edx
152 ; X64-NEXT: shlb $6, %dl
153 ; X64-NEXT: orb %al, %dl
154 ; X64-NEXT: movzbl %dl, %eax
155 ; X64-NEXT: cmpb $2, %cl
156 ; X64-NEXT: movl $127, %edx
157 ; X64-NEXT: cmovll %eax, %edx
158 ; X64-NEXT: cmpb $-2, %cl
159 ; X64-NEXT: movl $128, %eax
160 ; X64-NEXT: cmovgel %edx, %eax
161 ; X64-NEXT: sarb $4, %al
162 ; X64-NEXT: # kill: def $al killed $al killed $eax
167 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
168 ; X86-NEXT: shlb $4, %al
169 ; X86-NEXT: sarb $4, %al
170 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
171 ; X86-NEXT: shlb $4, %cl
172 ; X86-NEXT: movsbl %cl, %ecx
173 ; X86-NEXT: movsbl %al, %eax
174 ; X86-NEXT: imull %ecx, %eax
175 ; X86-NEXT: movb %ah, %cl
176 ; X86-NEXT: shlb $6, %cl
177 ; X86-NEXT: shrb $2, %al
178 ; X86-NEXT: orb %cl, %al
179 ; X86-NEXT: movzbl %al, %ecx
180 ; X86-NEXT: cmpb $2, %ah
181 ; X86-NEXT: movl $127, %edx
182 ; X86-NEXT: cmovll %ecx, %edx
183 ; X86-NEXT: cmpb $-2, %ah
184 ; X86-NEXT: movl $128, %eax
185 ; X86-NEXT: cmovgel %edx, %eax
186 ; X86-NEXT: sarb $4, %al
187 ; X86-NEXT: # kill: def $al killed $al killed $eax
189 %tmp = call i4 @llvm.smul.fix.sat.i4(i4 %x, i4 %y, i32 2)
193 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
196 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm1[3,3,3,3]
197 ; X64-NEXT: movd %xmm2, %eax
199 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm0[3,3,3,3]
200 ; X64-NEXT: movd %xmm2, %ecx
201 ; X64-NEXT: movslq %ecx, %rdx
202 ; X64-NEXT: imulq %rax, %rdx
203 ; X64-NEXT: movq %rdx, %rcx
204 ; X64-NEXT: shrq $32, %rcx
205 ; X64-NEXT: shrdl $2, %ecx, %edx
206 ; X64-NEXT: cmpl $2, %ecx
207 ; X64-NEXT: movl $2147483647, %eax # imm = 0x7FFFFFFF
208 ; X64-NEXT: cmovgel %eax, %edx
209 ; X64-NEXT: cmpl $-2, %ecx
210 ; X64-NEXT: movl $-2147483648, %ecx # imm = 0x80000000
211 ; X64-NEXT: cmovll %ecx, %edx
212 ; X64-NEXT: movd %edx, %xmm2
213 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm1[2,3,2,3]
214 ; X64-NEXT: movd %xmm3, %edx
215 ; X64-NEXT: movslq %edx, %rdx
216 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm0[2,3,2,3]
217 ; X64-NEXT: movd %xmm3, %esi
218 ; X64-NEXT: movslq %esi, %rsi
219 ; X64-NEXT: imulq %rdx, %rsi
220 ; X64-NEXT: movq %rsi, %rdx
221 ; X64-NEXT: shrq $32, %rdx
222 ; X64-NEXT: shrdl $2, %edx, %esi
223 ; X64-NEXT: cmpl $2, %edx
224 ; X64-NEXT: cmovgel %eax, %esi
225 ; X64-NEXT: cmpl $-2, %edx
226 ; X64-NEXT: cmovll %ecx, %esi
227 ; X64-NEXT: movd %esi, %xmm3
228 ; X64-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
229 ; X64-NEXT: movd %xmm1, %edx
230 ; X64-NEXT: movslq %edx, %rdx
231 ; X64-NEXT: movd %xmm0, %esi
232 ; X64-NEXT: movslq %esi, %rsi
233 ; X64-NEXT: imulq %rdx, %rsi
234 ; X64-NEXT: movq %rsi, %rdx
235 ; X64-NEXT: shrq $32, %rdx
236 ; X64-NEXT: shrdl $2, %edx, %esi
237 ; X64-NEXT: cmpl $2, %edx
238 ; X64-NEXT: cmovgel %eax, %esi
239 ; X64-NEXT: cmpl $-2, %edx
240 ; X64-NEXT: cmovll %ecx, %esi
241 ; X64-NEXT: movd %esi, %xmm2
242 ; X64-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,1,1]
243 ; X64-NEXT: movd %xmm1, %edx
244 ; X64-NEXT: movslq %edx, %rdx
245 ; X64-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,1,1]
246 ; X64-NEXT: movd %xmm0, %esi
247 ; X64-NEXT: movslq %esi, %rsi
248 ; X64-NEXT: imulq %rdx, %rsi
249 ; X64-NEXT: movq %rsi, %rdx
250 ; X64-NEXT: shrq $32, %rdx
251 ; X64-NEXT: shrdl $2, %edx, %esi
252 ; X64-NEXT: cmpl $2, %edx
253 ; X64-NEXT: cmovgel %eax, %esi
254 ; X64-NEXT: cmpl $-2, %edx
255 ; X64-NEXT: cmovll %ecx, %esi
256 ; X64-NEXT: movd %esi, %xmm0
257 ; X64-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
258 ; X64-NEXT: punpcklqdq {{.*#+}} xmm2 = xmm2[0],xmm3[0]
259 ; X64-NEXT: movdqa %xmm2, %xmm0
264 ; X86-NEXT: pushl %ebp
265 ; X86-NEXT: pushl %ebx
266 ; X86-NEXT: pushl %edi
267 ; X86-NEXT: pushl %esi
268 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
269 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
270 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
271 ; X86-NEXT: imull {{[0-9]+}}(%esp)
272 ; X86-NEXT: movl %eax, %ecx
273 ; X86-NEXT: shrdl $2, %edx, %ecx
274 ; X86-NEXT: cmpl $2, %edx
275 ; X86-NEXT: movl $2147483647, %ebp # imm = 0x7FFFFFFF
276 ; X86-NEXT: cmovgel %ebp, %ecx
277 ; X86-NEXT: cmpl $-2, %edx
278 ; X86-NEXT: movl $-2147483648, %esi # imm = 0x80000000
279 ; X86-NEXT: cmovll %esi, %ecx
280 ; X86-NEXT: movl %edi, %eax
281 ; X86-NEXT: imull {{[0-9]+}}(%esp)
282 ; X86-NEXT: movl %eax, %edi
283 ; X86-NEXT: shrdl $2, %edx, %edi
284 ; X86-NEXT: cmpl $2, %edx
285 ; X86-NEXT: cmovgel %ebp, %edi
286 ; X86-NEXT: cmpl $-2, %edx
287 ; X86-NEXT: cmovll %esi, %edi
288 ; X86-NEXT: movl %ebx, %eax
289 ; X86-NEXT: imull {{[0-9]+}}(%esp)
290 ; X86-NEXT: movl %eax, %ebx
291 ; X86-NEXT: shrdl $2, %edx, %ebx
292 ; X86-NEXT: cmpl $2, %edx
293 ; X86-NEXT: cmovgel %ebp, %ebx
294 ; X86-NEXT: cmpl $-2, %edx
295 ; X86-NEXT: cmovll %esi, %ebx
296 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
297 ; X86-NEXT: imull {{[0-9]+}}(%esp)
298 ; X86-NEXT: shrdl $2, %edx, %eax
299 ; X86-NEXT: cmpl $2, %edx
300 ; X86-NEXT: cmovgel %ebp, %eax
301 ; X86-NEXT: cmpl $-2, %edx
302 ; X86-NEXT: cmovll %esi, %eax
303 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
304 ; X86-NEXT: movl %eax, 12(%edx)
305 ; X86-NEXT: movl %ebx, 8(%edx)
306 ; X86-NEXT: movl %edi, 4(%edx)
307 ; X86-NEXT: movl %ecx, (%edx)
308 ; X86-NEXT: movl %edx, %eax
309 ; X86-NEXT: popl %esi
310 ; X86-NEXT: popl %edi
311 ; X86-NEXT: popl %ebx
312 ; X86-NEXT: popl %ebp
314 %tmp = call <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32> %x, <4 x i32> %y, i32 2)
318 ; These result in regular integer multiplication
319 define i32 @func4(i32 %x, i32 %y) nounwind {
322 ; X64-NEXT: xorl %eax, %eax
323 ; X64-NEXT: movl %edi, %ecx
324 ; X64-NEXT: xorl %esi, %ecx
326 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
327 ; X64-NEXT: imull %esi, %edi
328 ; X64-NEXT: cmovnol %edi, %eax
333 ; X86-NEXT: pushl %esi
334 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
335 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
336 ; X86-NEXT: xorl %ecx, %ecx
337 ; X86-NEXT: movl %eax, %esi
338 ; X86-NEXT: xorl %edx, %esi
340 ; X86-NEXT: addl $2147483647, %ecx # imm = 0x7FFFFFFF
341 ; X86-NEXT: imull %edx, %eax
342 ; X86-NEXT: cmovol %ecx, %eax
343 ; X86-NEXT: popl %esi
345 %tmp = call i32 @llvm.smul.fix.sat.i32(i32 %x, i32 %y, i32 0)
349 define i64 @func5(i64 %x, i64 %y) {
352 ; X64-NEXT: xorl %ecx, %ecx
353 ; X64-NEXT: movq %rdi, %rax
354 ; X64-NEXT: xorq %rsi, %rax
356 ; X64-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
357 ; X64-NEXT: addq %rcx, %rax
358 ; X64-NEXT: imulq %rsi, %rdi
359 ; X64-NEXT: cmovnoq %rdi, %rax
364 ; X86-NEXT: pushl %ebp
365 ; X86-NEXT: .cfi_def_cfa_offset 8
366 ; X86-NEXT: pushl %ebx
367 ; X86-NEXT: .cfi_def_cfa_offset 12
368 ; X86-NEXT: pushl %edi
369 ; X86-NEXT: .cfi_def_cfa_offset 16
370 ; X86-NEXT: pushl %esi
371 ; X86-NEXT: .cfi_def_cfa_offset 20
372 ; X86-NEXT: subl $12, %esp
373 ; X86-NEXT: .cfi_def_cfa_offset 32
374 ; X86-NEXT: .cfi_offset %esi, -20
375 ; X86-NEXT: .cfi_offset %edi, -16
376 ; X86-NEXT: .cfi_offset %ebx, -12
377 ; X86-NEXT: .cfi_offset %ebp, -8
378 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
379 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
380 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
381 ; X86-NEXT: movl %ecx, %edx
382 ; X86-NEXT: sarl $31, %edx
383 ; X86-NEXT: movl %esi, %ebx
384 ; X86-NEXT: movl %esi, %ebp
385 ; X86-NEXT: imull %edx, %ebx
386 ; X86-NEXT: mull %edx
387 ; X86-NEXT: movl %edx, %esi
388 ; X86-NEXT: movl %eax, %edi
389 ; X86-NEXT: addl %eax, %esi
390 ; X86-NEXT: addl %ebx, %esi
391 ; X86-NEXT: movl %ebp, %eax
392 ; X86-NEXT: sarl $31, %eax
393 ; X86-NEXT: movl %eax, %ebp
394 ; X86-NEXT: imull %ecx, %ebp
395 ; X86-NEXT: mull {{[0-9]+}}(%esp)
396 ; X86-NEXT: movl %edx, %ebx
397 ; X86-NEXT: addl %ebp, %ebx
398 ; X86-NEXT: addl %eax, %ebx
399 ; X86-NEXT: addl %edi, %eax
400 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
401 ; X86-NEXT: adcl %esi, %ebx
402 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
403 ; X86-NEXT: movl %ebp, %eax
404 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
405 ; X86-NEXT: mull %edi
406 ; X86-NEXT: movl %edx, %esi
407 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
408 ; X86-NEXT: movl %ecx, %eax
409 ; X86-NEXT: mull %edi
410 ; X86-NEXT: movl %edx, %edi
411 ; X86-NEXT: addl %eax, %esi
412 ; X86-NEXT: adcl $0, %edi
413 ; X86-NEXT: movl %ebp, %eax
414 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
415 ; X86-NEXT: mull %edx
416 ; X86-NEXT: movl %edx, %ebp
417 ; X86-NEXT: addl %eax, %esi
418 ; X86-NEXT: adcl %edi, %ebp
419 ; X86-NEXT: setb {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Folded Spill
420 ; X86-NEXT: movl %ecx, %eax
421 ; X86-NEXT: mull {{[0-9]+}}(%esp)
422 ; X86-NEXT: addl %ebp, %eax
423 ; X86-NEXT: movzbl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 1-byte Folded Reload
424 ; X86-NEXT: adcl %edi, %edx
425 ; X86-NEXT: addl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Folded Reload
426 ; X86-NEXT: adcl %ebx, %edx
427 ; X86-NEXT: movl %esi, %ebx
428 ; X86-NEXT: sarl $31, %ebx
429 ; X86-NEXT: xorl %ebx, %edx
430 ; X86-NEXT: xorl %eax, %ebx
431 ; X86-NEXT: xorl {{[0-9]+}}(%esp), %ecx
432 ; X86-NEXT: sarl $31, %ecx
433 ; X86-NEXT: movl %ecx, %edi
434 ; X86-NEXT: xorl $2147483647, %edi # imm = 0x7FFFFFFF
435 ; X86-NEXT: orl %edx, %ebx
436 ; X86-NEXT: notl %ecx
437 ; X86-NEXT: cmovel {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Folded Reload
438 ; X86-NEXT: cmovel %esi, %edi
439 ; X86-NEXT: movl %ecx, %eax
440 ; X86-NEXT: movl %edi, %edx
441 ; X86-NEXT: addl $12, %esp
442 ; X86-NEXT: .cfi_def_cfa_offset 20
443 ; X86-NEXT: popl %esi
444 ; X86-NEXT: .cfi_def_cfa_offset 16
445 ; X86-NEXT: popl %edi
446 ; X86-NEXT: .cfi_def_cfa_offset 12
447 ; X86-NEXT: popl %ebx
448 ; X86-NEXT: .cfi_def_cfa_offset 8
449 ; X86-NEXT: popl %ebp
450 ; X86-NEXT: .cfi_def_cfa_offset 4
452 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 0)
456 define i4 @func6(i4 %x, i4 %y) nounwind {
459 ; X64-NEXT: movl %edi, %eax
460 ; X64-NEXT: shlb $4, %sil
461 ; X64-NEXT: sarb $4, %sil
462 ; X64-NEXT: shlb $4, %al
463 ; X64-NEXT: xorl %ecx, %ecx
464 ; X64-NEXT: movl %eax, %edx
465 ; X64-NEXT: xorb %sil, %dl
467 ; X64-NEXT: addl $127, %ecx
468 ; X64-NEXT: # kill: def $al killed $al killed $eax
469 ; X64-NEXT: imulb %sil
470 ; X64-NEXT: movzbl %al, %eax
471 ; X64-NEXT: cmovol %ecx, %eax
472 ; X64-NEXT: sarb $4, %al
473 ; X64-NEXT: # kill: def $al killed $al killed $eax
478 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
479 ; X86-NEXT: shlb $4, %cl
480 ; X86-NEXT: sarb $4, %cl
481 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
482 ; X86-NEXT: shlb $4, %al
483 ; X86-NEXT: xorl %edx, %edx
484 ; X86-NEXT: movb %al, %ah
485 ; X86-NEXT: xorb %cl, %ah
487 ; X86-NEXT: addl $127, %edx
488 ; X86-NEXT: imulb %cl
489 ; X86-NEXT: movzbl %al, %eax
490 ; X86-NEXT: cmovol %edx, %eax
491 ; X86-NEXT: sarb $4, %al
492 ; X86-NEXT: # kill: def $al killed $al killed $eax
494 %tmp = call i4 @llvm.smul.fix.sat.i4(i4 %x, i4 %y, i32 0)
498 define <4 x i32> @vec2(<4 x i32> %x, <4 x i32> %y) nounwind {
501 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm1[3,3,3,3]
502 ; X64-NEXT: movd %xmm2, %eax
503 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm0[3,3,3,3]
504 ; X64-NEXT: movd %xmm2, %ecx
505 ; X64-NEXT: xorl %edx, %edx
506 ; X64-NEXT: movl %ecx, %esi
507 ; X64-NEXT: xorl %eax, %esi
509 ; X64-NEXT: addl $2147483647, %edx # imm = 0x7FFFFFFF
510 ; X64-NEXT: imull %eax, %ecx
511 ; X64-NEXT: cmovol %edx, %ecx
512 ; X64-NEXT: movd %ecx, %xmm2
513 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm1[2,3,2,3]
514 ; X64-NEXT: movd %xmm3, %eax
515 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm0[2,3,2,3]
516 ; X64-NEXT: movd %xmm3, %ecx
517 ; X64-NEXT: xorl %edx, %edx
518 ; X64-NEXT: movl %ecx, %esi
519 ; X64-NEXT: xorl %eax, %esi
521 ; X64-NEXT: addl $2147483647, %edx # imm = 0x7FFFFFFF
522 ; X64-NEXT: imull %eax, %ecx
523 ; X64-NEXT: cmovol %edx, %ecx
524 ; X64-NEXT: movd %ecx, %xmm3
525 ; X64-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
526 ; X64-NEXT: movd %xmm1, %eax
527 ; X64-NEXT: movd %xmm0, %ecx
528 ; X64-NEXT: xorl %edx, %edx
529 ; X64-NEXT: movl %ecx, %esi
530 ; X64-NEXT: xorl %eax, %esi
532 ; X64-NEXT: addl $2147483647, %edx # imm = 0x7FFFFFFF
533 ; X64-NEXT: imull %eax, %ecx
534 ; X64-NEXT: cmovol %edx, %ecx
535 ; X64-NEXT: movd %ecx, %xmm2
536 ; X64-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,1,1]
537 ; X64-NEXT: movd %xmm1, %eax
538 ; X64-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,1,1]
539 ; X64-NEXT: movd %xmm0, %ecx
540 ; X64-NEXT: xorl %edx, %edx
541 ; X64-NEXT: movl %ecx, %esi
542 ; X64-NEXT: xorl %eax, %esi
544 ; X64-NEXT: addl $2147483647, %edx # imm = 0x7FFFFFFF
545 ; X64-NEXT: imull %eax, %ecx
546 ; X64-NEXT: cmovol %edx, %ecx
547 ; X64-NEXT: movd %ecx, %xmm0
548 ; X64-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
549 ; X64-NEXT: punpcklqdq {{.*#+}} xmm2 = xmm2[0],xmm3[0]
550 ; X64-NEXT: movdqa %xmm2, %xmm0
555 ; X86-NEXT: pushl %ebp
556 ; X86-NEXT: pushl %ebx
557 ; X86-NEXT: pushl %edi
558 ; X86-NEXT: pushl %esi
559 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
560 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
561 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
562 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
563 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
564 ; X86-NEXT: xorl %eax, %eax
565 ; X86-NEXT: movl %ecx, %edx
566 ; X86-NEXT: xorl %edi, %edx
567 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
569 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
570 ; X86-NEXT: imull %edi, %ecx
571 ; X86-NEXT: cmovol %eax, %ecx
572 ; X86-NEXT: xorl %eax, %eax
573 ; X86-NEXT: movl %edx, %edi
574 ; X86-NEXT: xorl %ebx, %edi
575 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
577 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
578 ; X86-NEXT: imull %ebx, %edx
579 ; X86-NEXT: cmovol %eax, %edx
580 ; X86-NEXT: xorl %eax, %eax
581 ; X86-NEXT: movl %edi, %ebx
582 ; X86-NEXT: xorl %esi, %ebx
583 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
585 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
586 ; X86-NEXT: imull %esi, %edi
587 ; X86-NEXT: cmovol %eax, %edi
588 ; X86-NEXT: xorl %eax, %eax
589 ; X86-NEXT: movl %ebx, %esi
590 ; X86-NEXT: xorl %ebp, %esi
592 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
593 ; X86-NEXT: imull %ebp, %ebx
594 ; X86-NEXT: cmovol %eax, %ebx
595 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
596 ; X86-NEXT: movl %ebx, 12(%eax)
597 ; X86-NEXT: movl %edi, 8(%eax)
598 ; X86-NEXT: movl %edx, 4(%eax)
599 ; X86-NEXT: movl %ecx, (%eax)
600 ; X86-NEXT: popl %esi
601 ; X86-NEXT: popl %edi
602 ; X86-NEXT: popl %ebx
603 ; X86-NEXT: popl %ebp
605 %tmp = call <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32> %x, <4 x i32> %y, i32 0)
609 define i64 @func7(i64 %x, i64 %y) nounwind {
612 ; X64-NEXT: movq %rdi, %rax
613 ; X64-NEXT: imulq %rsi
614 ; X64-NEXT: shrdq $32, %rdx, %rax
615 ; X64-NEXT: cmpq $2147483647, %rdx # imm = 0x7FFFFFFF
616 ; X64-NEXT: movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
617 ; X64-NEXT: cmovgq %rcx, %rax
618 ; X64-NEXT: cmpq $-2147483648, %rdx # imm = 0x80000000
619 ; X64-NEXT: movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
620 ; X64-NEXT: cmovlq %rcx, %rax
625 ; X86-NEXT: pushl %ebp
626 ; X86-NEXT: pushl %ebx
627 ; X86-NEXT: pushl %edi
628 ; X86-NEXT: pushl %esi
629 ; X86-NEXT: pushl %eax
630 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
631 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
632 ; X86-NEXT: movl %ecx, %eax
633 ; X86-NEXT: mull {{[0-9]+}}(%esp)
634 ; X86-NEXT: movl %edx, %edi
635 ; X86-NEXT: movl %eax, %ebp
636 ; X86-NEXT: movl %ecx, %eax
637 ; X86-NEXT: mull {{[0-9]+}}(%esp)
638 ; X86-NEXT: addl %edx, %ebp
639 ; X86-NEXT: adcl $0, %edi
640 ; X86-NEXT: movl %esi, %eax
641 ; X86-NEXT: imull {{[0-9]+}}(%esp)
642 ; X86-NEXT: movl %edx, %ebx
643 ; X86-NEXT: movl %eax, %ecx
644 ; X86-NEXT: movl %esi, %eax
645 ; X86-NEXT: mull {{[0-9]+}}(%esp)
646 ; X86-NEXT: addl %ebp, %eax
647 ; X86-NEXT: adcl %edi, %edx
648 ; X86-NEXT: adcl $0, %ebx
649 ; X86-NEXT: addl %ecx, %edx
650 ; X86-NEXT: adcl $0, %ebx
651 ; X86-NEXT: movl %edx, %ecx
652 ; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx
653 ; X86-NEXT: movl %ebx, %esi
654 ; X86-NEXT: sbbl $0, %esi
655 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
656 ; X86-NEXT: cmovnsl %ebx, %esi
657 ; X86-NEXT: cmovsl %ecx, %edx
658 ; X86-NEXT: movl %edx, %edi
659 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edi
660 ; X86-NEXT: movl %esi, %ecx
661 ; X86-NEXT: sbbl $0, %ecx
662 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
663 ; X86-NEXT: cmovnsl %esi, %ecx
664 ; X86-NEXT: cmovsl %edi, %edx
665 ; X86-NEXT: testl %edx, %edx
666 ; X86-NEXT: setns {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Folded Spill
668 ; X86-NEXT: testl %ecx, %ecx
669 ; X86-NEXT: setg {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Folded Spill
671 ; X86-NEXT: andb %bh, %bl
672 ; X86-NEXT: orb {{[-0-9]+}}(%e{{[sb]}}p), %bl # 1-byte Folded Reload
673 ; X86-NEXT: movl $2147483647, %esi # imm = 0x7FFFFFFF
674 ; X86-NEXT: cmovnel %esi, %edx
675 ; X86-NEXT: movl $-1, %esi
676 ; X86-NEXT: cmovnel %esi, %eax
677 ; X86-NEXT: cmpl $-1, %ecx
680 ; X86-NEXT: andb {{[-0-9]+}}(%e{{[sb]}}p), %ch # 1-byte Folded Reload
681 ; X86-NEXT: xorl %esi, %esi
682 ; X86-NEXT: orb %cl, %ch
683 ; X86-NEXT: cmovnel %esi, %eax
684 ; X86-NEXT: movl $-2147483648, %ecx # imm = 0x80000000
685 ; X86-NEXT: cmovnel %ecx, %edx
686 ; X86-NEXT: addl $4, %esp
687 ; X86-NEXT: popl %esi
688 ; X86-NEXT: popl %edi
689 ; X86-NEXT: popl %ebx
690 ; X86-NEXT: popl %ebp
692 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 32)
696 define i64 @func8(i64 %x, i64 %y) nounwind {
699 ; X64-NEXT: movq %rdi, %rax
700 ; X64-NEXT: imulq %rsi
701 ; X64-NEXT: shrdq $63, %rdx, %rax
702 ; X64-NEXT: movabsq $4611686018427387903, %rcx # imm = 0x3FFFFFFFFFFFFFFF
703 ; X64-NEXT: cmpq %rcx, %rdx
704 ; X64-NEXT: movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
705 ; X64-NEXT: cmovgq %rcx, %rax
706 ; X64-NEXT: movabsq $-4611686018427387904, %rcx # imm = 0xC000000000000000
707 ; X64-NEXT: cmpq %rcx, %rdx
708 ; X64-NEXT: movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
709 ; X64-NEXT: cmovlq %rcx, %rax
714 ; X86-NEXT: pushl %ebp
715 ; X86-NEXT: pushl %ebx
716 ; X86-NEXT: pushl %edi
717 ; X86-NEXT: pushl %esi
718 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
719 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
720 ; X86-NEXT: movl %ecx, %eax
721 ; X86-NEXT: mull {{[0-9]+}}(%esp)
722 ; X86-NEXT: movl %edx, %edi
723 ; X86-NEXT: movl %eax, %ebp
724 ; X86-NEXT: movl %ecx, %eax
725 ; X86-NEXT: mull {{[0-9]+}}(%esp)
726 ; X86-NEXT: addl %edx, %ebp
727 ; X86-NEXT: adcl $0, %edi
728 ; X86-NEXT: movl %esi, %eax
729 ; X86-NEXT: imull {{[0-9]+}}(%esp)
730 ; X86-NEXT: movl %edx, %ebx
731 ; X86-NEXT: movl %eax, %ecx
732 ; X86-NEXT: movl %esi, %eax
733 ; X86-NEXT: mull {{[0-9]+}}(%esp)
734 ; X86-NEXT: addl %ebp, %eax
735 ; X86-NEXT: adcl %edx, %edi
736 ; X86-NEXT: adcl $0, %ebx
737 ; X86-NEXT: addl %ecx, %edi
738 ; X86-NEXT: adcl $0, %ebx
739 ; X86-NEXT: movl %edi, %edx
740 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edx
741 ; X86-NEXT: movl %ebx, %ebp
742 ; X86-NEXT: sbbl $0, %ebp
743 ; X86-NEXT: testl %esi, %esi
744 ; X86-NEXT: cmovnsl %ebx, %ebp
745 ; X86-NEXT: cmovnsl %edi, %edx
746 ; X86-NEXT: movl %edx, %esi
747 ; X86-NEXT: subl {{[0-9]+}}(%esp), %esi
748 ; X86-NEXT: movl %ebp, %ecx
749 ; X86-NEXT: sbbl $0, %ecx
750 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
751 ; X86-NEXT: cmovnsl %ebp, %ecx
752 ; X86-NEXT: cmovnsl %edx, %esi
753 ; X86-NEXT: shrdl $31, %esi, %eax
754 ; X86-NEXT: shrdl $31, %ecx, %esi
755 ; X86-NEXT: cmpl $1073741824, %ecx # imm = 0x40000000
756 ; X86-NEXT: movl $2147483647, %edi # imm = 0x7FFFFFFF
757 ; X86-NEXT: cmovll %esi, %edi
758 ; X86-NEXT: movl $-1, %edx
759 ; X86-NEXT: cmovgel %edx, %eax
760 ; X86-NEXT: xorl %edx, %edx
761 ; X86-NEXT: cmpl $-1073741824, %ecx # imm = 0xC0000000
762 ; X86-NEXT: cmovll %edx, %eax
763 ; X86-NEXT: movl $-2147483648, %edx # imm = 0x80000000
764 ; X86-NEXT: cmovgel %edi, %edx
765 ; X86-NEXT: popl %esi
766 ; X86-NEXT: popl %edi
767 ; X86-NEXT: popl %ebx
768 ; X86-NEXT: popl %ebp
770 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 63)