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 $1, %eax
20 ; X64-NEXT: movl $2147483647, %edx # imm = 0x7FFFFFFF
21 ; X64-NEXT: cmovlel %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 $1, %edx
33 ; X86-NEXT: movl $2147483647, %ecx # imm = 0x7FFFFFFF
34 ; X86-NEXT: cmovgl %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 $1, %rdx
50 ; X64-NEXT: movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
51 ; X64-NEXT: cmovgq %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), %esi
66 ; X86-NEXT: movl %ecx, %eax
68 ; X86-NEXT: movl %edx, %edi
69 ; X86-NEXT: movl %eax, %ebx
70 ; X86-NEXT: movl %ecx, %eax
71 ; X86-NEXT: mull {{[0-9]+}}(%esp)
72 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
73 ; X86-NEXT: movl %edx, %ebp
74 ; X86-NEXT: addl %ebx, %ebp
75 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
76 ; X86-NEXT: adcl $0, %edi
77 ; X86-NEXT: movl %ebx, %eax
78 ; X86-NEXT: imull %esi
79 ; X86-NEXT: movl %edx, %ecx
80 ; X86-NEXT: movl %eax, %esi
81 ; X86-NEXT: movl %ebx, %eax
82 ; X86-NEXT: mull {{[0-9]+}}(%esp)
83 ; X86-NEXT: addl %ebp, %eax
84 ; X86-NEXT: adcl %edi, %edx
85 ; X86-NEXT: adcl $0, %ecx
86 ; X86-NEXT: addl %esi, %edx
87 ; X86-NEXT: adcl $0, %ecx
88 ; X86-NEXT: movl %edx, %esi
89 ; X86-NEXT: subl {{[0-9]+}}(%esp), %esi
90 ; X86-NEXT: movl %ecx, %edi
91 ; X86-NEXT: sbbl $0, %edi
92 ; X86-NEXT: testl %ebx, %ebx
93 ; X86-NEXT: cmovnsl %ecx, %edi
94 ; X86-NEXT: cmovnsl %edx, %esi
95 ; X86-NEXT: movl %esi, %ecx
96 ; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx
97 ; X86-NEXT: movl %edi, %ebp
98 ; X86-NEXT: sbbl $0, %ebp
99 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
100 ; X86-NEXT: cmovnsl %edi, %ebp
101 ; X86-NEXT: cmovnsl %esi, %ecx
102 ; X86-NEXT: testl %ebp, %ebp
104 ; X86-NEXT: sete {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Folded Spill
105 ; X86-NEXT: cmpl $1, %ecx
107 ; X86-NEXT: movl %ecx, %edx
108 ; X86-NEXT: shldl $30, %eax, %edx
109 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
110 ; X86-NEXT: shldl $30, %esi, %eax
111 ; X86-NEXT: andb {{[-0-9]+}}(%e{{[sb]}}p), %bl # 1-byte Folded Reload
112 ; X86-NEXT: orb %bh, %bl
113 ; X86-NEXT: testb %bl, %bl
114 ; X86-NEXT: movl $2147483647, %esi # imm = 0x7FFFFFFF
115 ; X86-NEXT: cmovnel %esi, %edx
116 ; X86-NEXT: movl $-1, %esi
117 ; X86-NEXT: cmovnel %esi, %eax
118 ; X86-NEXT: cmpl $-1, %ebp
121 ; X86-NEXT: cmpl $-2, %ecx
123 ; X86-NEXT: andb %bh, %cl
124 ; X86-NEXT: xorl %esi, %esi
125 ; X86-NEXT: orb %bl, %cl
126 ; X86-NEXT: cmovnel %esi, %eax
127 ; X86-NEXT: movl $-2147483648, %ecx # imm = 0x80000000
128 ; X86-NEXT: cmovnel %ecx, %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 $1, %cl
156 ; X64-NEXT: movl $127, %edx
157 ; X64-NEXT: cmovlel %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: movb {{[0-9]+}}(%esp), %al
168 ; X86-NEXT: shlb $4, %al
169 ; X86-NEXT: sarb $4, %al
170 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
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 $1, %ah
181 ; X86-NEXT: movl $127, %edx
182 ; X86-NEXT: cmovlel %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,1,2,3]
197 ; X64-NEXT: movd %xmm2, %eax
199 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm0[3,1,2,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 $1, %ecx
207 ; X64-NEXT: movl $2147483647, %eax # imm = 0x7FFFFFFF
208 ; X64-NEXT: cmovgl %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,0,1]
214 ; X64-NEXT: movd %xmm3, %edx
215 ; X64-NEXT: movslq %edx, %rdx
216 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm0[2,3,0,1]
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 $1, %edx
224 ; X64-NEXT: cmovgl %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 $1, %edx
238 ; X64-NEXT: cmovgl %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,2,3]
243 ; X64-NEXT: movd %xmm1, %edx
244 ; X64-NEXT: movslq %edx, %rdx
245 ; X64-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,2,3]
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 $1, %edx
253 ; X64-NEXT: cmovgl %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 $1, %edx
275 ; X86-NEXT: movl $2147483647, %ebp # imm = 0x7FFFFFFF
276 ; X86-NEXT: cmovgl %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 $1, %edx
285 ; X86-NEXT: cmovgl %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 $1, %edx
293 ; X86-NEXT: cmovgl %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 $1, %edx
300 ; X86-NEXT: cmovgl %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: movl %edi, %ecx
323 ; X64-NEXT: imull %esi, %ecx
324 ; X64-NEXT: xorl %eax, %eax
325 ; X64-NEXT: testl %ecx, %ecx
326 ; X64-NEXT: setns %al
327 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
328 ; X64-NEXT: imull %esi, %edi
329 ; X64-NEXT: cmovnol %edi, %eax
334 ; X86-NEXT: pushl %esi
335 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
336 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
337 ; X86-NEXT: movl %eax, %esi
338 ; X86-NEXT: imull %edx, %esi
339 ; X86-NEXT: xorl %ecx, %ecx
340 ; X86-NEXT: testl %esi, %esi
341 ; X86-NEXT: setns %cl
342 ; X86-NEXT: addl $2147483647, %ecx # imm = 0x7FFFFFFF
343 ; X86-NEXT: imull %edx, %eax
344 ; X86-NEXT: cmovol %ecx, %eax
345 ; X86-NEXT: popl %esi
347 %tmp = call i32 @llvm.smul.fix.sat.i32(i32 %x, i32 %y, i32 0);
351 define i64 @func5(i64 %x, i64 %y) {
354 ; X64-NEXT: movq %rdi, %rax
355 ; X64-NEXT: imulq %rsi, %rax
356 ; X64-NEXT: xorl %ecx, %ecx
357 ; X64-NEXT: testq %rax, %rax
358 ; X64-NEXT: setns %cl
359 ; X64-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
360 ; X64-NEXT: addq %rcx, %rax
361 ; X64-NEXT: imulq %rsi, %rdi
362 ; X64-NEXT: cmovnoq %rdi, %rax
367 ; X86-NEXT: pushl %edi
368 ; X86-NEXT: .cfi_def_cfa_offset 8
369 ; X86-NEXT: pushl %esi
370 ; X86-NEXT: .cfi_def_cfa_offset 12
371 ; X86-NEXT: pushl %eax
372 ; X86-NEXT: .cfi_def_cfa_offset 16
373 ; X86-NEXT: .cfi_offset %esi, -12
374 ; X86-NEXT: .cfi_offset %edi, -8
375 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
376 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
377 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
378 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
379 ; X86-NEXT: movl $0, (%esp)
380 ; X86-NEXT: movl %esp, %edi
381 ; X86-NEXT: pushl %edi
382 ; X86-NEXT: .cfi_adjust_cfa_offset 4
383 ; X86-NEXT: pushl %esi
384 ; X86-NEXT: .cfi_adjust_cfa_offset 4
385 ; X86-NEXT: pushl %edx
386 ; X86-NEXT: .cfi_adjust_cfa_offset 4
387 ; X86-NEXT: pushl %ecx
388 ; X86-NEXT: .cfi_adjust_cfa_offset 4
389 ; X86-NEXT: pushl %eax
390 ; X86-NEXT: .cfi_adjust_cfa_offset 4
391 ; X86-NEXT: calll __mulodi4
392 ; X86-NEXT: addl $20, %esp
393 ; X86-NEXT: .cfi_adjust_cfa_offset -20
394 ; X86-NEXT: xorl %ecx, %ecx
395 ; X86-NEXT: testl %edx, %edx
396 ; X86-NEXT: setns %cl
397 ; X86-NEXT: addl $2147483647, %ecx # imm = 0x7FFFFFFF
398 ; X86-NEXT: movl %edx, %esi
399 ; X86-NEXT: sarl $31, %esi
400 ; X86-NEXT: cmpl $0, (%esp)
401 ; X86-NEXT: cmovnel %esi, %eax
402 ; X86-NEXT: cmovnel %ecx, %edx
403 ; X86-NEXT: addl $4, %esp
404 ; X86-NEXT: .cfi_def_cfa_offset 12
405 ; X86-NEXT: popl %esi
406 ; X86-NEXT: .cfi_def_cfa_offset 8
407 ; X86-NEXT: popl %edi
408 ; X86-NEXT: .cfi_def_cfa_offset 4
410 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 0);
414 define i4 @func6(i4 %x, i4 %y) nounwind {
417 ; X64-NEXT: movl %edi, %eax
418 ; X64-NEXT: shlb $4, %sil
419 ; X64-NEXT: sarb $4, %sil
420 ; X64-NEXT: shlb $4, %al
421 ; X64-NEXT: # kill: def $al killed $al killed $eax
422 ; X64-NEXT: imulb %sil
424 ; X64-NEXT: xorl %edx, %edx
425 ; X64-NEXT: testb %al, %al
426 ; X64-NEXT: setns %dl
427 ; X64-NEXT: addl $127, %edx
428 ; X64-NEXT: movzbl %al, %eax
429 ; X64-NEXT: testb %cl, %cl
430 ; X64-NEXT: cmovnel %edx, %eax
431 ; X64-NEXT: sarb $4, %al
432 ; X64-NEXT: # kill: def $al killed $al killed $eax
437 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
438 ; X86-NEXT: shlb $4, %cl
439 ; X86-NEXT: sarb $4, %cl
440 ; X86-NEXT: movb {{[0-9]+}}(%esp), %al
441 ; X86-NEXT: shlb $4, %al
442 ; X86-NEXT: imulb %cl
444 ; X86-NEXT: xorl %ecx, %ecx
445 ; X86-NEXT: testb %al, %al
446 ; X86-NEXT: setns %cl
447 ; X86-NEXT: addl $127, %ecx
448 ; X86-NEXT: movzbl %al, %eax
449 ; X86-NEXT: testb %dl, %dl
450 ; X86-NEXT: cmovnel %ecx, %eax
451 ; X86-NEXT: sarb $4, %al
452 ; X86-NEXT: # kill: def $al killed $al killed $eax
454 %tmp = call i4 @llvm.smul.fix.sat.i4(i4 %x, i4 %y, i32 0);
458 define <4 x i32> @vec2(<4 x i32> %x, <4 x i32> %y) nounwind {
461 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm1[1,1,2,3]
462 ; X64-NEXT: movd %xmm2, %ecx
463 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm0[1,1,2,3]
464 ; X64-NEXT: movd %xmm2, %r8d
465 ; X64-NEXT: movl %r8d, %edx
466 ; X64-NEXT: imull %ecx, %edx
467 ; X64-NEXT: xorl %esi, %esi
468 ; X64-NEXT: testl %edx, %edx
469 ; X64-NEXT: setns %sil
470 ; X64-NEXT: addl $2147483647, %esi # imm = 0x7FFFFFFF
471 ; X64-NEXT: imull %ecx, %r8d
472 ; X64-NEXT: cmovol %esi, %r8d
473 ; X64-NEXT: movd %xmm1, %edx
474 ; X64-NEXT: movd %xmm0, %ecx
475 ; X64-NEXT: movl %ecx, %esi
476 ; X64-NEXT: imull %edx, %esi
477 ; X64-NEXT: xorl %edi, %edi
478 ; X64-NEXT: testl %esi, %esi
479 ; X64-NEXT: setns %dil
480 ; X64-NEXT: addl $2147483647, %edi # imm = 0x7FFFFFFF
481 ; X64-NEXT: imull %edx, %ecx
482 ; X64-NEXT: cmovol %edi, %ecx
483 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm1[2,3,0,1]
484 ; X64-NEXT: movd %xmm2, %edx
485 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm0[2,3,0,1]
486 ; X64-NEXT: movd %xmm2, %esi
487 ; X64-NEXT: movl %esi, %edi
488 ; X64-NEXT: imull %edx, %edi
489 ; X64-NEXT: xorl %eax, %eax
490 ; X64-NEXT: testl %edi, %edi
491 ; X64-NEXT: setns %al
492 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
493 ; X64-NEXT: imull %edx, %esi
494 ; X64-NEXT: cmovol %eax, %esi
495 ; X64-NEXT: pshufd {{.*#+}} xmm1 = xmm1[3,1,2,3]
496 ; X64-NEXT: movd %xmm1, %r9d
497 ; X64-NEXT: pshufd {{.*#+}} xmm0 = xmm0[3,1,2,3]
498 ; X64-NEXT: movd %xmm0, %edx
499 ; X64-NEXT: movl %edx, %edi
500 ; X64-NEXT: imull %r9d, %edi
501 ; X64-NEXT: xorl %eax, %eax
502 ; X64-NEXT: testl %edi, %edi
503 ; X64-NEXT: setns %al
504 ; X64-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
505 ; X64-NEXT: imull %r9d, %edx
506 ; X64-NEXT: cmovol %eax, %edx
507 ; X64-NEXT: movd %edx, %xmm0
508 ; X64-NEXT: movd %esi, %xmm1
509 ; X64-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
510 ; X64-NEXT: movd %ecx, %xmm0
511 ; X64-NEXT: movd %r8d, %xmm2
512 ; X64-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
513 ; X64-NEXT: punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
518 ; X86-NEXT: pushl %ebp
519 ; X86-NEXT: pushl %ebx
520 ; X86-NEXT: pushl %edi
521 ; X86-NEXT: pushl %esi
522 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
523 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
524 ; X86-NEXT: movl %ecx, %esi
525 ; X86-NEXT: imull %edx, %esi
526 ; X86-NEXT: xorl %eax, %eax
527 ; X86-NEXT: testl %esi, %esi
528 ; X86-NEXT: setns %al
529 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
530 ; X86-NEXT: imull %edx, %ecx
531 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
532 ; X86-NEXT: cmovol %eax, %ecx
533 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
534 ; X86-NEXT: movl %edx, %edi
535 ; X86-NEXT: imull %esi, %edi
536 ; X86-NEXT: xorl %eax, %eax
537 ; X86-NEXT: testl %edi, %edi
538 ; X86-NEXT: setns %al
539 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
540 ; X86-NEXT: imull %esi, %edx
541 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
542 ; X86-NEXT: cmovol %eax, %edx
543 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
544 ; X86-NEXT: movl %esi, %ebx
545 ; X86-NEXT: imull %edi, %ebx
546 ; X86-NEXT: xorl %eax, %eax
547 ; X86-NEXT: testl %ebx, %ebx
548 ; X86-NEXT: setns %al
549 ; X86-NEXT: addl $2147483647, %eax # imm = 0x7FFFFFFF
550 ; X86-NEXT: imull %edi, %esi
551 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
552 ; X86-NEXT: cmovol %eax, %esi
553 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
554 ; X86-NEXT: movl %edi, %ebp
555 ; X86-NEXT: imull %eax, %ebp
556 ; X86-NEXT: xorl %ebx, %ebx
557 ; X86-NEXT: testl %ebp, %ebp
558 ; X86-NEXT: setns %bl
559 ; X86-NEXT: addl $2147483647, %ebx # imm = 0x7FFFFFFF
560 ; X86-NEXT: imull %eax, %edi
561 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
562 ; X86-NEXT: cmovol %ebx, %edi
563 ; X86-NEXT: movl %ecx, 12(%eax)
564 ; X86-NEXT: movl %edx, 8(%eax)
565 ; X86-NEXT: movl %esi, 4(%eax)
566 ; X86-NEXT: movl %edi, (%eax)
567 ; X86-NEXT: popl %esi
568 ; X86-NEXT: popl %edi
569 ; X86-NEXT: popl %ebx
570 ; X86-NEXT: popl %ebp
572 %tmp = call <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32> %x, <4 x i32> %y, i32 0);
576 define i64 @func7(i64 %x, i64 %y) nounwind {
579 ; X64-NEXT: movq %rdi, %rax
580 ; X64-NEXT: imulq %rsi
581 ; X64-NEXT: shrdq $32, %rdx, %rax
582 ; X64-NEXT: cmpq $2147483647, %rdx # imm = 0x7FFFFFFF
583 ; X64-NEXT: movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
584 ; X64-NEXT: cmovgq %rcx, %rax
585 ; X64-NEXT: cmpq $-2147483648, %rdx # imm = 0x80000000
586 ; X64-NEXT: movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
587 ; X64-NEXT: cmovlq %rcx, %rax
592 ; X86-NEXT: pushl %ebp
593 ; X86-NEXT: pushl %ebx
594 ; X86-NEXT: pushl %edi
595 ; X86-NEXT: pushl %esi
596 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
597 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
598 ; X86-NEXT: movl %ecx, %eax
599 ; X86-NEXT: mull {{[0-9]+}}(%esp)
600 ; X86-NEXT: movl %edx, %edi
601 ; X86-NEXT: movl %eax, %ebx
602 ; X86-NEXT: movl %ecx, %eax
603 ; X86-NEXT: mull {{[0-9]+}}(%esp)
604 ; X86-NEXT: addl %edx, %ebx
605 ; X86-NEXT: adcl $0, %edi
606 ; X86-NEXT: movl %esi, %eax
607 ; X86-NEXT: imull {{[0-9]+}}(%esp)
608 ; X86-NEXT: movl %edx, %ebp
609 ; X86-NEXT: movl %eax, %ecx
610 ; X86-NEXT: movl %esi, %eax
611 ; X86-NEXT: mull {{[0-9]+}}(%esp)
612 ; X86-NEXT: addl %ebx, %eax
613 ; X86-NEXT: adcl %edi, %edx
614 ; X86-NEXT: adcl $0, %ebp
615 ; X86-NEXT: addl %ecx, %edx
616 ; X86-NEXT: adcl $0, %ebp
617 ; X86-NEXT: movl %edx, %ecx
618 ; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx
619 ; X86-NEXT: movl %ebp, %esi
620 ; X86-NEXT: sbbl $0, %esi
621 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
622 ; X86-NEXT: cmovnsl %ebp, %esi
623 ; X86-NEXT: cmovnsl %edx, %ecx
624 ; X86-NEXT: movl %ecx, %edx
625 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edx
626 ; X86-NEXT: movl %esi, %edi
627 ; X86-NEXT: sbbl $0, %edi
628 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
629 ; X86-NEXT: cmovnsl %esi, %edi
630 ; X86-NEXT: cmovnsl %ecx, %edx
631 ; X86-NEXT: testl %edx, %edx
632 ; X86-NEXT: setns %cl
634 ; X86-NEXT: testl %edi, %edi
637 ; X86-NEXT: andb %ch, %bh
638 ; X86-NEXT: orb %bl, %bh
639 ; X86-NEXT: movl $2147483647, %esi # imm = 0x7FFFFFFF
640 ; X86-NEXT: cmovnel %esi, %edx
641 ; X86-NEXT: movl $-1, %esi
642 ; X86-NEXT: cmovnel %esi, %eax
643 ; X86-NEXT: cmpl $-1, %edi
646 ; X86-NEXT: andb %cl, %bl
647 ; X86-NEXT: xorl %esi, %esi
648 ; X86-NEXT: orb %ch, %bl
649 ; X86-NEXT: cmovnel %esi, %eax
650 ; X86-NEXT: movl $-2147483648, %ecx # imm = 0x80000000
651 ; X86-NEXT: cmovnel %ecx, %edx
652 ; X86-NEXT: popl %esi
653 ; X86-NEXT: popl %edi
654 ; X86-NEXT: popl %ebx
655 ; X86-NEXT: popl %ebp
657 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 32);
661 define i64 @func8(i64 %x, i64 %y) nounwind {
664 ; X64-NEXT: movq %rdi, %rax
665 ; X64-NEXT: imulq %rsi
666 ; X64-NEXT: shrdq $63, %rdx, %rax
667 ; X64-NEXT: movabsq $4611686018427387903, %rcx # imm = 0x3FFFFFFFFFFFFFFF
668 ; X64-NEXT: cmpq %rcx, %rdx
669 ; X64-NEXT: movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
670 ; X64-NEXT: cmovgq %rcx, %rax
671 ; X64-NEXT: movabsq $-4611686018427387904, %rcx # imm = 0xC000000000000000
672 ; X64-NEXT: cmpq %rcx, %rdx
673 ; X64-NEXT: movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
674 ; X64-NEXT: cmovlq %rcx, %rax
679 ; X86-NEXT: pushl %ebp
680 ; X86-NEXT: pushl %ebx
681 ; X86-NEXT: pushl %edi
682 ; X86-NEXT: pushl %esi
683 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
684 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
685 ; X86-NEXT: movl %ecx, %eax
686 ; X86-NEXT: mull {{[0-9]+}}(%esp)
687 ; X86-NEXT: movl %edx, %edi
688 ; X86-NEXT: movl %eax, %ebx
689 ; X86-NEXT: movl %ecx, %eax
690 ; X86-NEXT: mull {{[0-9]+}}(%esp)
691 ; X86-NEXT: movl %edx, %ebp
692 ; X86-NEXT: addl %ebx, %ebp
693 ; X86-NEXT: adcl $0, %edi
694 ; X86-NEXT: movl %esi, %eax
695 ; X86-NEXT: imull {{[0-9]+}}(%esp)
696 ; X86-NEXT: movl %edx, %ebx
697 ; X86-NEXT: movl %eax, %ecx
698 ; X86-NEXT: movl %esi, %eax
699 ; X86-NEXT: mull {{[0-9]+}}(%esp)
700 ; X86-NEXT: addl %ebp, %eax
701 ; X86-NEXT: adcl %edi, %edx
702 ; X86-NEXT: adcl $0, %ebx
703 ; X86-NEXT: addl %ecx, %edx
704 ; X86-NEXT: adcl $0, %ebx
705 ; X86-NEXT: movl %edx, %ecx
706 ; X86-NEXT: subl {{[0-9]+}}(%esp), %ecx
707 ; X86-NEXT: movl %ebx, %esi
708 ; X86-NEXT: sbbl $0, %esi
709 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
710 ; X86-NEXT: cmovnsl %ebx, %esi
711 ; X86-NEXT: cmovnsl %edx, %ecx
712 ; X86-NEXT: movl %ecx, %edi
713 ; X86-NEXT: subl {{[0-9]+}}(%esp), %edi
714 ; X86-NEXT: movl %esi, %ebx
715 ; X86-NEXT: sbbl $0, %ebx
716 ; X86-NEXT: cmpl $0, {{[0-9]+}}(%esp)
717 ; X86-NEXT: cmovnsl %esi, %ebx
718 ; X86-NEXT: cmovnsl %ecx, %edi
719 ; X86-NEXT: movl %ebx, %edx
720 ; X86-NEXT: shldl $1, %edi, %edx
721 ; X86-NEXT: shrdl $31, %edi, %eax
722 ; X86-NEXT: cmpl $1073741823, %ebx # imm = 0x3FFFFFFF
723 ; X86-NEXT: movl $2147483647, %ecx # imm = 0x7FFFFFFF
724 ; X86-NEXT: cmovgl %ecx, %edx
725 ; X86-NEXT: movl $-1, %ecx
726 ; X86-NEXT: cmovgl %ecx, %eax
727 ; X86-NEXT: xorl %ecx, %ecx
728 ; X86-NEXT: cmpl $-1073741824, %ebx # imm = 0xC0000000
729 ; X86-NEXT: cmovll %ecx, %eax
730 ; X86-NEXT: movl $-2147483648, %ecx # imm = 0x80000000
731 ; X86-NEXT: cmovll %ecx, %edx
732 ; X86-NEXT: popl %esi
733 ; X86-NEXT: popl %edi
734 ; X86-NEXT: popl %ebx
735 ; X86-NEXT: popl %ebp
737 %tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 63);