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.sdiv.fix.i4 (i4, i4, i32)
6 declare i15 @llvm.sdiv.fix.i15 (i15, i15, i32)
7 declare i16 @llvm.sdiv.fix.i16 (i16, i16, i32)
8 declare i18 @llvm.sdiv.fix.i18 (i18, i18, i32)
9 declare i64 @llvm.sdiv.fix.i64 (i64, i64, i32)
10 declare <4 x i32> @llvm.sdiv.fix.v4i32(<4 x i32>, <4 x i32>, i32)
12 define i16 @func(i16 %x, i16 %y) nounwind {
15 ; X64-NEXT: movswl %si, %esi
16 ; X64-NEXT: movswl %di, %ecx
17 ; X64-NEXT: shll $7, %ecx
18 ; X64-NEXT: movl %ecx, %eax
20 ; X64-NEXT: idivl %esi
21 ; X64-NEXT: # kill: def $eax killed $eax def $rax
22 ; X64-NEXT: leal -1(%rax), %edi
23 ; X64-NEXT: testl %esi, %esi
25 ; X64-NEXT: testl %ecx, %ecx
27 ; X64-NEXT: xorb %sil, %cl
28 ; X64-NEXT: testl %edx, %edx
30 ; X64-NEXT: testb %cl, %dl
31 ; X64-NEXT: cmovnel %edi, %eax
32 ; X64-NEXT: # kill: def $ax killed $ax killed $rax
37 ; X86-NEXT: pushl %ebx
38 ; X86-NEXT: pushl %edi
39 ; X86-NEXT: pushl %esi
40 ; X86-NEXT: movswl {{[0-9]+}}(%esp), %esi
41 ; X86-NEXT: movswl {{[0-9]+}}(%esp), %ecx
42 ; X86-NEXT: shll $7, %ecx
43 ; X86-NEXT: movl %ecx, %eax
45 ; X86-NEXT: idivl %esi
46 ; X86-NEXT: leal -1(%eax), %edi
47 ; X86-NEXT: testl %esi, %esi
49 ; X86-NEXT: testl %ecx, %ecx
51 ; X86-NEXT: xorb %bl, %cl
52 ; X86-NEXT: testl %edx, %edx
54 ; X86-NEXT: testb %cl, %dl
55 ; X86-NEXT: cmovnel %edi, %eax
56 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
61 %tmp = call i16 @llvm.sdiv.fix.i16(i16 %x, i16 %y, i32 7)
65 define i16 @func2(i8 %x, i8 %y) nounwind {
68 ; X64-NEXT: movsbl %dil, %eax
69 ; X64-NEXT: movsbl %sil, %ecx
70 ; X64-NEXT: movswl %cx, %esi
71 ; X64-NEXT: movswl %ax, %ecx
72 ; X64-NEXT: shll $14, %ecx
73 ; X64-NEXT: movl %ecx, %eax
75 ; X64-NEXT: idivl %esi
76 ; X64-NEXT: # kill: def $eax killed $eax def $rax
77 ; X64-NEXT: leal -1(%rax), %edi
78 ; X64-NEXT: testl %esi, %esi
80 ; X64-NEXT: testl %ecx, %ecx
82 ; X64-NEXT: xorb %sil, %cl
83 ; X64-NEXT: testl %edx, %edx
85 ; X64-NEXT: testb %cl, %dl
86 ; X64-NEXT: cmovel %eax, %edi
87 ; X64-NEXT: addl %edi, %edi
88 ; X64-NEXT: movswl %di, %eax
90 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
95 ; X86-NEXT: pushl %ebx
96 ; X86-NEXT: pushl %edi
97 ; X86-NEXT: pushl %esi
98 ; X86-NEXT: movsbl {{[0-9]+}}(%esp), %esi
99 ; X86-NEXT: movsbl {{[0-9]+}}(%esp), %ecx
100 ; X86-NEXT: shll $14, %ecx
101 ; X86-NEXT: movl %ecx, %eax
103 ; X86-NEXT: idivl %esi
104 ; X86-NEXT: leal -1(%eax), %edi
105 ; X86-NEXT: testl %esi, %esi
107 ; X86-NEXT: testl %ecx, %ecx
109 ; X86-NEXT: xorb %bl, %cl
110 ; X86-NEXT: testl %edx, %edx
111 ; X86-NEXT: setne %dl
112 ; X86-NEXT: testb %cl, %dl
113 ; X86-NEXT: cmovel %eax, %edi
114 ; X86-NEXT: addl %edi, %edi
115 ; X86-NEXT: movswl %di, %eax
116 ; X86-NEXT: shrl %eax
117 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
118 ; X86-NEXT: popl %esi
119 ; X86-NEXT: popl %edi
120 ; X86-NEXT: popl %ebx
122 %x2 = sext i8 %x to i15
123 %y2 = sext i8 %y to i15
124 %tmp = call i15 @llvm.sdiv.fix.i15(i15 %x2, i15 %y2, i32 14)
125 %tmp2 = sext i15 %tmp to i16
129 define i16 @func3(i15 %x, i8 %y) nounwind {
132 ; X64-NEXT: shll $8, %esi
133 ; X64-NEXT: movswl %si, %ecx
134 ; X64-NEXT: addl %edi, %edi
135 ; X64-NEXT: shrl $4, %ecx
136 ; X64-NEXT: movl %edi, %eax
138 ; X64-NEXT: idivw %cx
139 ; X64-NEXT: # kill: def $ax killed $ax def $rax
140 ; X64-NEXT: leal -1(%rax), %esi
141 ; X64-NEXT: testw %di, %di
142 ; X64-NEXT: sets %dil
143 ; X64-NEXT: testw %cx, %cx
145 ; X64-NEXT: xorb %dil, %cl
146 ; X64-NEXT: testw %dx, %dx
147 ; X64-NEXT: setne %dl
148 ; X64-NEXT: testb %cl, %dl
149 ; X64-NEXT: cmovel %eax, %esi
150 ; X64-NEXT: addl %esi, %esi
151 ; X64-NEXT: movswl %si, %eax
152 ; X64-NEXT: shrl %eax
153 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
158 ; X86-NEXT: pushl %edi
159 ; X86-NEXT: pushl %esi
160 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
161 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
162 ; X86-NEXT: shll $8, %eax
163 ; X86-NEXT: movswl %ax, %esi
164 ; X86-NEXT: addl %ecx, %ecx
165 ; X86-NEXT: shrl $4, %esi
166 ; X86-NEXT: movl %ecx, %eax
168 ; X86-NEXT: idivw %si
169 ; X86-NEXT: # kill: def $ax killed $ax def $eax
170 ; X86-NEXT: leal -1(%eax), %edi
171 ; X86-NEXT: testw %cx, %cx
173 ; X86-NEXT: testw %si, %si
175 ; X86-NEXT: xorb %cl, %ch
176 ; X86-NEXT: testw %dx, %dx
177 ; X86-NEXT: setne %cl
178 ; X86-NEXT: testb %ch, %cl
179 ; X86-NEXT: cmovel %eax, %edi
180 ; X86-NEXT: addl %edi, %edi
181 ; X86-NEXT: movswl %di, %eax
182 ; X86-NEXT: shrl %eax
183 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
184 ; X86-NEXT: popl %esi
185 ; X86-NEXT: popl %edi
187 %y2 = sext i8 %y to i15
189 %tmp = call i15 @llvm.sdiv.fix.i15(i15 %x, i15 %y3, i32 4)
190 %tmp2 = sext i15 %tmp to i16
194 define i4 @func4(i4 %x, i4 %y) nounwind {
197 ; X64-NEXT: pushq %rbx
198 ; X64-NEXT: shlb $4, %sil
199 ; X64-NEXT: sarb $4, %sil
200 ; X64-NEXT: shlb $4, %dil
201 ; X64-NEXT: sarb $4, %dil
202 ; X64-NEXT: shlb $2, %dil
203 ; X64-NEXT: movsbl %dil, %ecx
204 ; X64-NEXT: movl %ecx, %eax
205 ; X64-NEXT: idivb %sil
206 ; X64-NEXT: movsbl %ah, %ebx
207 ; X64-NEXT: movzbl %al, %edi
208 ; X64-NEXT: leal -1(%rdi), %eax
209 ; X64-NEXT: movzbl %al, %eax
210 ; X64-NEXT: testb %sil, %sil
212 ; X64-NEXT: testb %cl, %cl
214 ; X64-NEXT: xorb %dl, %cl
215 ; X64-NEXT: testb %bl, %bl
216 ; X64-NEXT: setne %dl
217 ; X64-NEXT: testb %cl, %dl
218 ; X64-NEXT: cmovel %edi, %eax
219 ; X64-NEXT: # kill: def $al killed $al killed $eax
220 ; X64-NEXT: popq %rbx
225 ; X86-NEXT: pushl %esi
226 ; X86-NEXT: movb {{[0-9]+}}(%esp), %dl
227 ; X86-NEXT: shlb $4, %dl
228 ; X86-NEXT: sarb $4, %dl
229 ; X86-NEXT: movb {{[0-9]+}}(%esp), %dh
230 ; X86-NEXT: shlb $4, %dh
231 ; X86-NEXT: sarb $4, %dh
232 ; X86-NEXT: shlb $2, %dh
233 ; X86-NEXT: movsbl %dh, %eax
234 ; X86-NEXT: idivb %dl
235 ; X86-NEXT: movsbl %ah, %ecx
236 ; X86-NEXT: movzbl %al, %esi
238 ; X86-NEXT: movzbl %al, %eax
239 ; X86-NEXT: testb %dl, %dl
241 ; X86-NEXT: testb %dh, %dh
243 ; X86-NEXT: xorb %dl, %dh
244 ; X86-NEXT: testb %cl, %cl
245 ; X86-NEXT: setne %cl
246 ; X86-NEXT: testb %dh, %cl
247 ; X86-NEXT: cmovel %esi, %eax
248 ; X86-NEXT: # kill: def $al killed $al killed $eax
249 ; X86-NEXT: popl %esi
251 %tmp = call i4 @llvm.sdiv.fix.i4(i4 %x, i4 %y, i32 2)
255 define i64 @func5(i64 %x, i64 %y) nounwind {
258 ; X64-NEXT: pushq %rbp
259 ; X64-NEXT: pushq %r15
260 ; X64-NEXT: pushq %r14
261 ; X64-NEXT: pushq %r13
262 ; X64-NEXT: pushq %r12
263 ; X64-NEXT: pushq %rbx
264 ; X64-NEXT: pushq %rax
265 ; X64-NEXT: movq %rsi, %r14
266 ; X64-NEXT: movq %rdi, %r15
267 ; X64-NEXT: movq %rdi, %rbx
268 ; X64-NEXT: sarq $63, %rbx
269 ; X64-NEXT: shldq $31, %rdi, %rbx
270 ; X64-NEXT: shlq $31, %r15
271 ; X64-NEXT: movq %rsi, %r12
272 ; X64-NEXT: sarq $63, %r12
273 ; X64-NEXT: movq %r15, %rdi
274 ; X64-NEXT: movq %rbx, %rsi
275 ; X64-NEXT: movq %r14, %rdx
276 ; X64-NEXT: movq %r12, %rcx
277 ; X64-NEXT: callq __divti3@PLT
278 ; X64-NEXT: movq %rax, %r13
279 ; X64-NEXT: decq %rax
280 ; X64-NEXT: movq %rax, (%rsp) # 8-byte Spill
281 ; X64-NEXT: testq %rbx, %rbx
283 ; X64-NEXT: testq %r12, %r12
284 ; X64-NEXT: sets %bpl
285 ; X64-NEXT: xorb %al, %bpl
286 ; X64-NEXT: movq %r15, %rdi
287 ; X64-NEXT: movq %rbx, %rsi
288 ; X64-NEXT: movq %r14, %rdx
289 ; X64-NEXT: movq %r12, %rcx
290 ; X64-NEXT: callq __modti3@PLT
291 ; X64-NEXT: orq %rax, %rdx
292 ; X64-NEXT: setne %al
293 ; X64-NEXT: testb %bpl, %al
294 ; X64-NEXT: cmovneq (%rsp), %r13 # 8-byte Folded Reload
295 ; X64-NEXT: movq %r13, %rax
296 ; X64-NEXT: addq $8, %rsp
297 ; X64-NEXT: popq %rbx
298 ; X64-NEXT: popq %r12
299 ; X64-NEXT: popq %r13
300 ; X64-NEXT: popq %r14
301 ; X64-NEXT: popq %r15
302 ; X64-NEXT: popq %rbp
307 ; X86-NEXT: pushl %ebp
308 ; X86-NEXT: movl %esp, %ebp
309 ; X86-NEXT: pushl %ebx
310 ; X86-NEXT: pushl %edi
311 ; X86-NEXT: pushl %esi
312 ; X86-NEXT: andl $-8, %esp
313 ; X86-NEXT: subl $72, %esp
314 ; X86-NEXT: movl 8(%ebp), %ecx
315 ; X86-NEXT: movl 12(%ebp), %eax
316 ; X86-NEXT: movl 20(%ebp), %edx
317 ; X86-NEXT: movl %edx, %esi
318 ; X86-NEXT: sarl $31, %esi
319 ; X86-NEXT: movl %eax, %edi
320 ; X86-NEXT: sarl $31, %edi
321 ; X86-NEXT: movl %edi, %ebx
322 ; X86-NEXT: shldl $31, %eax, %ebx
323 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
324 ; X86-NEXT: shldl $31, %ecx, %eax
325 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
326 ; X86-NEXT: shll $31, %ecx
327 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
328 ; X86-NEXT: pushl %esi
329 ; X86-NEXT: pushl %esi
330 ; X86-NEXT: pushl %edx
331 ; X86-NEXT: pushl 16(%ebp)
332 ; X86-NEXT: pushl %edi
333 ; X86-NEXT: pushl %ebx
334 ; X86-NEXT: pushl %eax
335 ; X86-NEXT: pushl %ecx
336 ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
337 ; X86-NEXT: pushl %eax
338 ; X86-NEXT: calll __divti3
339 ; X86-NEXT: addl $32, %esp
340 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
341 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
342 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
343 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
344 ; X86-NEXT: movl %ecx, %eax
345 ; X86-NEXT: subl $1, %eax
346 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
347 ; X86-NEXT: sbbl $0, %ebx
348 ; X86-NEXT: testl %esi, %esi
350 ; X86-NEXT: testl %edi, %edi
352 ; X86-NEXT: xorb %al, %cl
353 ; X86-NEXT: movb %cl, {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Spill
354 ; X86-NEXT: leal {{[0-9]+}}(%esp), %eax
355 ; X86-NEXT: pushl %esi
356 ; X86-NEXT: pushl %esi
357 ; X86-NEXT: pushl 20(%ebp)
358 ; X86-NEXT: pushl 16(%ebp)
359 ; X86-NEXT: pushl %edi
360 ; X86-NEXT: pushl {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Reload
361 ; X86-NEXT: pushl {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Reload
362 ; X86-NEXT: pushl {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Reload
363 ; X86-NEXT: pushl %eax
364 ; X86-NEXT: calll __modti3
365 ; X86-NEXT: addl $32, %esp
366 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
367 ; X86-NEXT: orl {{[0-9]+}}(%esp), %eax
368 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
369 ; X86-NEXT: orl {{[0-9]+}}(%esp), %ecx
370 ; X86-NEXT: orl %eax, %ecx
371 ; X86-NEXT: setne %al
372 ; X86-NEXT: testb %al, {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Folded Reload
373 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
374 ; X86-NEXT: cmovel {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Folded Reload
375 ; X86-NEXT: cmovel {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Folded Reload
376 ; X86-NEXT: movl %ebx, %edx
377 ; X86-NEXT: leal -12(%ebp), %esp
378 ; X86-NEXT: popl %esi
379 ; X86-NEXT: popl %edi
380 ; X86-NEXT: popl %ebx
381 ; X86-NEXT: popl %ebp
383 %tmp = call i64 @llvm.sdiv.fix.i64(i64 %x, i64 %y, i32 31)
387 define i18 @func6(i16 %x, i16 %y) nounwind {
390 ; X64-NEXT: movswl %di, %ecx
391 ; X64-NEXT: movswl %si, %esi
392 ; X64-NEXT: shll $7, %ecx
393 ; X64-NEXT: movl %ecx, %eax
395 ; X64-NEXT: idivl %esi
396 ; X64-NEXT: # kill: def $eax killed $eax def $rax
397 ; X64-NEXT: leal -1(%rax), %edi
398 ; X64-NEXT: testl %esi, %esi
399 ; X64-NEXT: sets %sil
400 ; X64-NEXT: testl %ecx, %ecx
402 ; X64-NEXT: xorb %sil, %cl
403 ; X64-NEXT: testl %edx, %edx
404 ; X64-NEXT: setne %dl
405 ; X64-NEXT: testb %cl, %dl
406 ; X64-NEXT: cmovnel %edi, %eax
407 ; X64-NEXT: # kill: def $eax killed $eax killed $rax
412 ; X86-NEXT: pushl %ebx
413 ; X86-NEXT: pushl %edi
414 ; X86-NEXT: pushl %esi
415 ; X86-NEXT: movswl {{[0-9]+}}(%esp), %esi
416 ; X86-NEXT: movswl {{[0-9]+}}(%esp), %ecx
417 ; X86-NEXT: shll $7, %ecx
418 ; X86-NEXT: movl %ecx, %eax
420 ; X86-NEXT: idivl %esi
421 ; X86-NEXT: leal -1(%eax), %edi
422 ; X86-NEXT: testl %esi, %esi
424 ; X86-NEXT: testl %ecx, %ecx
426 ; X86-NEXT: xorb %bl, %cl
427 ; X86-NEXT: testl %edx, %edx
428 ; X86-NEXT: setne %dl
429 ; X86-NEXT: testb %cl, %dl
430 ; X86-NEXT: cmovnel %edi, %eax
431 ; X86-NEXT: popl %esi
432 ; X86-NEXT: popl %edi
433 ; X86-NEXT: popl %ebx
435 %x2 = sext i16 %x to i18
436 %y2 = sext i16 %y to i18
437 %tmp = call i18 @llvm.sdiv.fix.i18(i18 %x2, i18 %y2, i32 7)
441 define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
444 ; X64-NEXT: pxor %xmm2, %xmm2
445 ; X64-NEXT: pcmpgtd %xmm1, %xmm2
446 ; X64-NEXT: pshufd {{.*#+}} xmm4 = xmm1[2,3,2,3]
447 ; X64-NEXT: movdqa %xmm1, %xmm3
448 ; X64-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
449 ; X64-NEXT: movq %xmm3, %rcx
450 ; X64-NEXT: pxor %xmm5, %xmm5
451 ; X64-NEXT: pcmpgtd %xmm0, %xmm5
452 ; X64-NEXT: pshufd {{.*#+}} xmm1 = xmm0[2,3,2,3]
453 ; X64-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm5[0],xmm0[1],xmm5[1]
454 ; X64-NEXT: psllq $31, %xmm0
455 ; X64-NEXT: movq %xmm0, %rax
457 ; X64-NEXT: idivq %rcx
458 ; X64-NEXT: movq %rax, %r8
459 ; X64-NEXT: movq %rdx, %r11
460 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm3[2,3,2,3]
461 ; X64-NEXT: movq %xmm3, %rcx
462 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm0[2,3,2,3]
463 ; X64-NEXT: movq %xmm3, %rax
465 ; X64-NEXT: idivq %rcx
466 ; X64-NEXT: movq %rax, %r10
467 ; X64-NEXT: movq %rdx, %rcx
468 ; X64-NEXT: pxor %xmm3, %xmm3
469 ; X64-NEXT: pcmpgtd %xmm4, %xmm3
470 ; X64-NEXT: punpckldq {{.*#+}} xmm4 = xmm4[0],xmm3[0],xmm4[1],xmm3[1]
471 ; X64-NEXT: movq %xmm4, %rdi
472 ; X64-NEXT: pxor %xmm5, %xmm5
473 ; X64-NEXT: pcmpgtd %xmm1, %xmm5
474 ; X64-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm5[0],xmm1[1],xmm5[1]
475 ; X64-NEXT: psllq $31, %xmm1
476 ; X64-NEXT: movq %xmm1, %rax
478 ; X64-NEXT: idivq %rdi
479 ; X64-NEXT: movq %rax, %r9
480 ; X64-NEXT: movq %rdx, %rdi
481 ; X64-NEXT: pshufd {{.*#+}} xmm4 = xmm4[2,3,2,3]
482 ; X64-NEXT: movq %xmm4, %rsi
483 ; X64-NEXT: pshufd {{.*#+}} xmm4 = xmm1[2,3,2,3]
484 ; X64-NEXT: movq %xmm4, %rax
486 ; X64-NEXT: idivq %rsi
487 ; X64-NEXT: movq %r11, %xmm4
488 ; X64-NEXT: movq %rcx, %xmm5
489 ; X64-NEXT: pxor %xmm6, %xmm6
490 ; X64-NEXT: punpcklqdq {{.*#+}} xmm4 = xmm4[0],xmm5[0]
491 ; X64-NEXT: pcmpeqd %xmm6, %xmm4
492 ; X64-NEXT: pshufd {{.*#+}} xmm5 = xmm4[1,0,3,2]
493 ; X64-NEXT: pand %xmm4, %xmm5
494 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm2[0,0,1,1]
495 ; X64-NEXT: pxor %xmm4, %xmm4
496 ; X64-NEXT: pcmpgtd %xmm2, %xmm4
497 ; X64-NEXT: pshufd {{.*#+}} xmm0 = xmm0[1,1,3,3]
498 ; X64-NEXT: pxor %xmm2, %xmm2
499 ; X64-NEXT: pcmpgtd %xmm0, %xmm2
500 ; X64-NEXT: movq %r8, %xmm0
501 ; X64-NEXT: pxor %xmm4, %xmm2
502 ; X64-NEXT: movq %r10, %xmm4
503 ; X64-NEXT: pandn %xmm2, %xmm5
504 ; X64-NEXT: punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm4[0]
505 ; X64-NEXT: movdqa %xmm5, %xmm2
506 ; X64-NEXT: pandn %xmm0, %xmm2
507 ; X64-NEXT: pcmpeqd %xmm4, %xmm4
508 ; X64-NEXT: paddq %xmm4, %xmm0
509 ; X64-NEXT: pand %xmm5, %xmm0
510 ; X64-NEXT: por %xmm2, %xmm0
511 ; X64-NEXT: movq %rdi, %xmm2
512 ; X64-NEXT: movq %rdx, %xmm5
513 ; X64-NEXT: punpcklqdq {{.*#+}} xmm2 = xmm2[0],xmm5[0]
514 ; X64-NEXT: pcmpeqd %xmm6, %xmm2
515 ; X64-NEXT: pshufd {{.*#+}} xmm5 = xmm2[1,0,3,2]
516 ; X64-NEXT: pand %xmm2, %xmm5
517 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm3[0,0,1,1]
518 ; X64-NEXT: pxor %xmm3, %xmm3
519 ; X64-NEXT: pcmpgtd %xmm2, %xmm3
520 ; X64-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
521 ; X64-NEXT: pcmpgtd %xmm1, %xmm6
522 ; X64-NEXT: pxor %xmm3, %xmm6
523 ; X64-NEXT: pandn %xmm6, %xmm5
524 ; X64-NEXT: movq %r9, %xmm1
525 ; X64-NEXT: movq %rax, %xmm2
526 ; X64-NEXT: punpcklqdq {{.*#+}} xmm1 = xmm1[0],xmm2[0]
527 ; X64-NEXT: movdqa %xmm5, %xmm2
528 ; X64-NEXT: pandn %xmm1, %xmm2
529 ; X64-NEXT: paddq %xmm4, %xmm1
530 ; X64-NEXT: pand %xmm5, %xmm1
531 ; X64-NEXT: por %xmm2, %xmm1
532 ; X64-NEXT: shufps {{.*#+}} xmm0 = xmm0[0,2],xmm1[0,2]
537 ; X86-NEXT: pushl %ebp
538 ; X86-NEXT: pushl %ebx
539 ; X86-NEXT: pushl %edi
540 ; X86-NEXT: pushl %esi
541 ; X86-NEXT: subl $60, %esp
542 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
543 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
544 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
545 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
546 ; X86-NEXT: movl %esi, %ebp
547 ; X86-NEXT: sarl $31, %ebp
548 ; X86-NEXT: movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
549 ; X86-NEXT: movl %ecx, %edx
550 ; X86-NEXT: shll $31, %edx
551 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
552 ; X86-NEXT: movl %ecx, %eax
553 ; X86-NEXT: shrl $31, %eax
554 ; X86-NEXT: shldl $31, %ecx, %eax
555 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
556 ; X86-NEXT: pushl %ebp
557 ; X86-NEXT: pushl %esi
558 ; X86-NEXT: pushl %eax
559 ; X86-NEXT: pushl %edx
560 ; X86-NEXT: calll __divdi3
561 ; X86-NEXT: addl $16, %esp
562 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
563 ; X86-NEXT: movl %edi, %eax
564 ; X86-NEXT: sarl $31, %eax
565 ; X86-NEXT: movl %ebx, %ebp
566 ; X86-NEXT: shll $31, %ebp
567 ; X86-NEXT: movl %ebx, %ecx
568 ; X86-NEXT: shrl $31, %ecx
569 ; X86-NEXT: shldl $31, %ebx, %ecx
570 ; X86-NEXT: pushl %eax
571 ; X86-NEXT: movl %eax, %esi
572 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
573 ; X86-NEXT: pushl %edi
574 ; X86-NEXT: pushl %ecx
575 ; X86-NEXT: movl %ecx, %ebx
576 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
577 ; X86-NEXT: pushl %ebp
578 ; X86-NEXT: calll __moddi3
579 ; X86-NEXT: addl $16, %esp
580 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
581 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
582 ; X86-NEXT: pushl %esi
583 ; X86-NEXT: pushl %edi
584 ; X86-NEXT: pushl %ebx
585 ; X86-NEXT: pushl %ebp
586 ; X86-NEXT: calll __divdi3
587 ; X86-NEXT: addl $16, %esp
588 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
589 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
590 ; X86-NEXT: movl %eax, %ecx
591 ; X86-NEXT: sarl $31, %ecx
592 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
593 ; X86-NEXT: movl %edx, %ebx
594 ; X86-NEXT: shll $31, %ebx
595 ; X86-NEXT: movl %edx, %edi
596 ; X86-NEXT: shrl $31, %edi
597 ; X86-NEXT: shldl $31, %edx, %edi
598 ; X86-NEXT: pushl %ecx
599 ; X86-NEXT: movl %ecx, %ebp
600 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
601 ; X86-NEXT: pushl %eax
602 ; X86-NEXT: movl %eax, %esi
603 ; X86-NEXT: pushl %edi
604 ; X86-NEXT: pushl %ebx
605 ; X86-NEXT: calll __moddi3
606 ; X86-NEXT: addl $16, %esp
607 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
608 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
609 ; X86-NEXT: pushl %ebp
610 ; X86-NEXT: pushl %esi
611 ; X86-NEXT: pushl %edi
612 ; X86-NEXT: pushl %ebx
613 ; X86-NEXT: calll __divdi3
614 ; X86-NEXT: addl $16, %esp
615 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
616 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
617 ; X86-NEXT: movl %eax, %ebx
618 ; X86-NEXT: sarl $31, %ebx
619 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
620 ; X86-NEXT: movl %ecx, %ebp
621 ; X86-NEXT: shll $31, %ebp
622 ; X86-NEXT: movl %ecx, %esi
623 ; X86-NEXT: shrl $31, %esi
624 ; X86-NEXT: shldl $31, %ecx, %esi
625 ; X86-NEXT: pushl %ebx
626 ; X86-NEXT: pushl %eax
627 ; X86-NEXT: pushl %esi
628 ; X86-NEXT: pushl %ebp
629 ; X86-NEXT: calll __moddi3
630 ; X86-NEXT: addl $16, %esp
631 ; X86-NEXT: movl %eax, (%esp) # 4-byte Spill
632 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
633 ; X86-NEXT: pushl %ebx
634 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
635 ; X86-NEXT: pushl %esi
636 ; X86-NEXT: pushl %ebp
637 ; X86-NEXT: calll __divdi3
638 ; X86-NEXT: addl $16, %esp
639 ; X86-NEXT: testl %esi, %esi
641 ; X86-NEXT: testl %ebx, %ebx
643 ; X86-NEXT: xorb %cl, %dl
644 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
645 ; X86-NEXT: orl (%esp), %ecx # 4-byte Folded Reload
646 ; X86-NEXT: setne %cl
647 ; X86-NEXT: testb %dl, %cl
648 ; X86-NEXT: leal -1(%eax), %ecx
649 ; X86-NEXT: cmovel %eax, %ecx
650 ; X86-NEXT: movl %ecx, (%esp) # 4-byte Spill
651 ; X86-NEXT: testl %edi, %edi
653 ; X86-NEXT: cmpl $0, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Reload
655 ; X86-NEXT: xorb %al, %cl
656 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
657 ; X86-NEXT: orl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Folded Reload
658 ; X86-NEXT: setne %al
659 ; X86-NEXT: testb %cl, %al
660 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
661 ; X86-NEXT: leal -1(%eax), %ecx
662 ; X86-NEXT: cmovel %eax, %ecx
663 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
664 ; X86-NEXT: cmpl $0, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Reload
666 ; X86-NEXT: cmpl $0, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Reload
668 ; X86-NEXT: xorb %al, %cl
669 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
670 ; X86-NEXT: orl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Folded Reload
671 ; X86-NEXT: setne %al
672 ; X86-NEXT: testb %cl, %al
673 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
674 ; X86-NEXT: leal -1(%eax), %ebp
675 ; X86-NEXT: cmovel %eax, %ebp
676 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
677 ; X86-NEXT: testl %edx, %edx
679 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
680 ; X86-NEXT: testl %ecx, %ecx
682 ; X86-NEXT: xorb %al, %bl
683 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Reload
684 ; X86-NEXT: leal -1(%edi), %esi
685 ; X86-NEXT: pushl %ecx
686 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
687 ; X86-NEXT: pushl %edx
688 ; X86-NEXT: pushl {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Reload
689 ; X86-NEXT: calll __moddi3
690 ; X86-NEXT: addl $16, %esp
691 ; X86-NEXT: orl %eax, %edx
692 ; X86-NEXT: setne %al
693 ; X86-NEXT: testb %bl, %al
694 ; X86-NEXT: cmovel %edi, %esi
695 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
696 ; X86-NEXT: movl %esi, 12(%eax)
697 ; X86-NEXT: movl %ebp, 8(%eax)
698 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
699 ; X86-NEXT: movl %ecx, 4(%eax)
700 ; X86-NEXT: movl (%esp), %ecx # 4-byte Reload
701 ; X86-NEXT: movl %ecx, (%eax)
702 ; X86-NEXT: addl $60, %esp
703 ; X86-NEXT: popl %esi
704 ; X86-NEXT: popl %edi
705 ; X86-NEXT: popl %ebx
706 ; X86-NEXT: popl %ebp
708 %tmp = call <4 x i32> @llvm.sdiv.fix.v4i32(<4 x i32> %x, <4 x i32> %y, i32 31)