1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse,+sse2 | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse,+sse2 | FileCheck %s --check-prefix=X64
5 ; If the target does not have a single div/rem operation,
6 ; -div-rem-pairs pass will decompose the remainder calculation as:
7 ; X % Y --> X - ((X / Y) * Y)
8 ; But if the target does have a single div/rem operation,
9 ; the opposite transform is likely beneficial.
11 define i8 @scalar_i8(i8 %x, i8 %y, ptr %divdst) nounwind {
12 ; X86-LABEL: scalar_i8:
14 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
15 ; X86-NEXT: movb {{[0-9]+}}(%esp), %ch
16 ; X86-NEXT: movb {{[0-9]+}}(%esp), %cl
17 ; X86-NEXT: movzbl %cl, %eax
19 ; X86-NEXT: movb %al, (%edx)
21 ; X86-NEXT: subb %al, %cl
22 ; X86-NEXT: movl %ecx, %eax
25 ; X64-LABEL: scalar_i8:
27 ; X64-NEXT: movzbl %dil, %ecx
28 ; X64-NEXT: movl %ecx, %eax
30 ; X64-NEXT: movb %al, (%rdx)
32 ; X64-NEXT: subb %al, %cl
33 ; X64-NEXT: movl %ecx, %eax
36 store i8 %div, ptr %divdst, align 4
42 define i16 @scalar_i16(i16 %x, i16 %y, ptr %divdst) nounwind {
43 ; X86-LABEL: scalar_i16:
45 ; X86-NEXT: pushl %edi
46 ; X86-NEXT: pushl %esi
47 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
48 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
49 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
50 ; X86-NEXT: movl %ecx, %eax
51 ; X86-NEXT: xorl %edx, %edx
53 ; X86-NEXT: # kill: def $ax killed $ax def $eax
54 ; X86-NEXT: movw %ax, (%edi)
55 ; X86-NEXT: imull %eax, %esi
56 ; X86-NEXT: subl %esi, %ecx
57 ; X86-NEXT: movl %ecx, %eax
62 ; X64-LABEL: scalar_i16:
64 ; X64-NEXT: movq %rdx, %rcx
65 ; X64-NEXT: movl %edi, %eax
66 ; X64-NEXT: xorl %edx, %edx
68 ; X64-NEXT: # kill: def $ax killed $ax def $eax
69 ; X64-NEXT: movw %ax, (%rcx)
70 ; X64-NEXT: imull %eax, %esi
71 ; X64-NEXT: subl %esi, %edi
72 ; X64-NEXT: movl %edi, %eax
74 %div = udiv i16 %x, %y
75 store i16 %div, ptr %divdst, align 4
76 %t1 = mul i16 %div, %y
81 define i32 @scalar_i32(i32 %x, i32 %y, ptr %divdst) nounwind {
82 ; X86-LABEL: scalar_i32:
84 ; X86-NEXT: pushl %edi
85 ; X86-NEXT: pushl %esi
86 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
87 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
88 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
89 ; X86-NEXT: movl %ecx, %eax
90 ; X86-NEXT: xorl %edx, %edx
92 ; X86-NEXT: movl %eax, (%esi)
93 ; X86-NEXT: imull %edi, %eax
94 ; X86-NEXT: subl %eax, %ecx
95 ; X86-NEXT: movl %ecx, %eax
100 ; X64-LABEL: scalar_i32:
102 ; X64-NEXT: movq %rdx, %rcx
103 ; X64-NEXT: movl %edi, %eax
104 ; X64-NEXT: xorl %edx, %edx
105 ; X64-NEXT: divl %esi
106 ; X64-NEXT: movl %eax, (%rcx)
107 ; X64-NEXT: imull %esi, %eax
108 ; X64-NEXT: subl %eax, %edi
109 ; X64-NEXT: movl %edi, %eax
111 %div = udiv i32 %x, %y
112 store i32 %div, ptr %divdst, align 4
113 %t1 = mul i32 %div, %y
114 %t2 = sub i32 %x, %t1
118 define i64 @scalar_i64(i64 %x, i64 %y, ptr %divdst) nounwind {
119 ; X86-LABEL: scalar_i64:
121 ; X86-NEXT: pushl %ebp
122 ; X86-NEXT: pushl %ebx
123 ; X86-NEXT: pushl %edi
124 ; X86-NEXT: pushl %esi
125 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
126 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
127 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
128 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
129 ; X86-NEXT: pushl %ebp
130 ; X86-NEXT: pushl %ebx
131 ; X86-NEXT: pushl %edi
132 ; X86-NEXT: pushl %esi
133 ; X86-NEXT: calll __udivdi3
134 ; X86-NEXT: addl $16, %esp
135 ; X86-NEXT: movl %edx, %ecx
136 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
137 ; X86-NEXT: movl %ecx, 4(%edx)
138 ; X86-NEXT: movl %eax, (%edx)
139 ; X86-NEXT: imull %eax, %ebp
140 ; X86-NEXT: mull %ebx
141 ; X86-NEXT: addl %ebp, %edx
142 ; X86-NEXT: imull %ebx, %ecx
143 ; X86-NEXT: addl %edx, %ecx
144 ; X86-NEXT: subl %eax, %esi
145 ; X86-NEXT: sbbl %ecx, %edi
146 ; X86-NEXT: movl %esi, %eax
147 ; X86-NEXT: movl %edi, %edx
148 ; X86-NEXT: popl %esi
149 ; X86-NEXT: popl %edi
150 ; X86-NEXT: popl %ebx
151 ; X86-NEXT: popl %ebp
154 ; X64-LABEL: scalar_i64:
156 ; X64-NEXT: movq %rdx, %rcx
157 ; X64-NEXT: movq %rdi, %rax
158 ; X64-NEXT: xorl %edx, %edx
159 ; X64-NEXT: divq %rsi
160 ; X64-NEXT: movq %rax, (%rcx)
161 ; X64-NEXT: imulq %rsi, %rax
162 ; X64-NEXT: subq %rax, %rdi
163 ; X64-NEXT: movq %rdi, %rax
165 %div = udiv i64 %x, %y
166 store i64 %div, ptr %divdst, align 4
167 %t1 = mul i64 %div, %y
168 %t2 = sub i64 %x, %t1
172 ; X86 doesn't have __divti3, so the urem is expanded into a loop.
173 define i128 @scalar_i128(i128 %x, i128 %y, ptr %divdst) nounwind {
174 ; X86-LABEL: scalar_i128:
175 ; X86: # %bb.0: # %_udiv-special-cases
176 ; X86-NEXT: pushl %ebp
177 ; X86-NEXT: pushl %ebx
178 ; X86-NEXT: pushl %edi
179 ; X86-NEXT: pushl %esi
180 ; X86-NEXT: subl $136, %esp
181 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
182 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
183 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
184 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
185 ; X86-NEXT: orl %edi, %eax
186 ; X86-NEXT: movl %ebp, %ecx
187 ; X86-NEXT: orl %esi, %ecx
188 ; X86-NEXT: orl %eax, %ecx
189 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
191 ; X86-NEXT: orl {{[0-9]+}}(%esp), %eax
192 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
193 ; X86-NEXT: orl {{[0-9]+}}(%esp), %edx
194 ; X86-NEXT: orl %eax, %edx
196 ; X86-NEXT: orb %bl, %al
197 ; X86-NEXT: movb %al, (%esp) # 1-byte Spill
198 ; X86-NEXT: bsrl %edi, %edx
199 ; X86-NEXT: xorl $31, %edx
200 ; X86-NEXT: bsrl %esi, %ecx
201 ; X86-NEXT: xorl $31, %ecx
202 ; X86-NEXT: addl $32, %ecx
203 ; X86-NEXT: testl %edi, %edi
204 ; X86-NEXT: movl %edi, %ebx
205 ; X86-NEXT: cmovnel %edx, %ecx
206 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
207 ; X86-NEXT: bsrl %eax, %edx
208 ; X86-NEXT: xorl $31, %edx
209 ; X86-NEXT: bsrl %ebp, %ebp
210 ; X86-NEXT: movl %esi, %edi
211 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
212 ; X86-NEXT: xorl $31, %ebp
213 ; X86-NEXT: addl $32, %ebp
214 ; X86-NEXT: testl %eax, %eax
215 ; X86-NEXT: cmovnel %edx, %ebp
216 ; X86-NEXT: addl $64, %ebp
217 ; X86-NEXT: movl %edi, %edx
218 ; X86-NEXT: orl %ebx, %edx
219 ; X86-NEXT: cmovnel %ecx, %ebp
220 ; X86-NEXT: bsrl %esi, %edx
221 ; X86-NEXT: movl %esi, %ebx
222 ; X86-NEXT: xorl $31, %edx
223 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
224 ; X86-NEXT: bsrl %eax, %ecx
225 ; X86-NEXT: xorl $31, %ecx
226 ; X86-NEXT: addl $32, %ecx
227 ; X86-NEXT: testl %esi, %esi
228 ; X86-NEXT: cmovnel %edx, %ecx
229 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
230 ; X86-NEXT: bsrl %edi, %esi
231 ; X86-NEXT: xorl $31, %esi
232 ; X86-NEXT: bsrl {{[0-9]+}}(%esp), %edx
233 ; X86-NEXT: xorl $31, %edx
234 ; X86-NEXT: addl $32, %edx
235 ; X86-NEXT: testl %edi, %edi
236 ; X86-NEXT: cmovnel %esi, %edx
237 ; X86-NEXT: addl $64, %edx
238 ; X86-NEXT: orl %ebx, %eax
239 ; X86-NEXT: cmovnel %ecx, %edx
240 ; X86-NEXT: subl %edx, %ebp
241 ; X86-NEXT: movl $0, %edx
242 ; X86-NEXT: sbbl %edx, %edx
243 ; X86-NEXT: movl $0, %esi
244 ; X86-NEXT: sbbl %esi, %esi
245 ; X86-NEXT: movl $0, %edi
246 ; X86-NEXT: sbbl %edi, %edi
247 ; X86-NEXT: movl $127, %ecx
248 ; X86-NEXT: cmpl %ebp, %ecx
249 ; X86-NEXT: movl $0, %ecx
250 ; X86-NEXT: sbbl %edx, %ecx
251 ; X86-NEXT: movl $0, %ecx
252 ; X86-NEXT: sbbl %esi, %ecx
253 ; X86-NEXT: movl $0, %ecx
254 ; X86-NEXT: sbbl %edi, %ecx
256 ; X86-NEXT: orb (%esp), %cl # 1-byte Folded Reload
257 ; X86-NEXT: movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
258 ; X86-NEXT: movl %ebp, %eax
259 ; X86-NEXT: xorl $127, %eax
260 ; X86-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
261 ; X86-NEXT: orl %esi, %eax
262 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
263 ; X86-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
264 ; X86-NEXT: orl %edi, %edx
265 ; X86-NEXT: orl %eax, %edx
267 ; X86-NEXT: testb %cl, %cl
268 ; X86-NEXT: movl %ebx, %edx
269 ; X86-NEXT: movl $0, %edi
270 ; X86-NEXT: cmovnel %edi, %edx
271 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
272 ; X86-NEXT: cmovnel %edi, %esi
273 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
274 ; X86-NEXT: cmovnel %edi, %ebp
275 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
276 ; X86-NEXT: cmovnel %edi, %ebx
277 ; X86-NEXT: orb %cl, %al
278 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
279 ; X86-NEXT: jne .LBB4_7
280 ; X86-NEXT: # %bb.1: # %udiv-bb1
281 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
282 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
283 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
284 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
285 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
286 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
287 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
288 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
289 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
290 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
291 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
292 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
293 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Reload
294 ; X86-NEXT: movl %ebx, %eax
295 ; X86-NEXT: xorb $127, %al
296 ; X86-NEXT: movb %al, %ch
297 ; X86-NEXT: andb $7, %ch
298 ; X86-NEXT: shrb $3, %al
299 ; X86-NEXT: andb $15, %al
301 ; X86-NEXT: movsbl %al, %eax
302 ; X86-NEXT: movl 128(%esp,%eax), %edx
303 ; X86-NEXT: movl 132(%esp,%eax), %esi
304 ; X86-NEXT: movb %ch, %cl
305 ; X86-NEXT: shldl %cl, %edx, %esi
306 ; X86-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
307 ; X86-NEXT: shll %cl, %edx
309 ; X86-NEXT: movl 124(%esp,%eax), %ebp
310 ; X86-NEXT: movl %ebp, %esi
311 ; X86-NEXT: shrl %esi
312 ; X86-NEXT: shrl %cl, %esi
313 ; X86-NEXT: orl %edx, %esi
314 ; X86-NEXT: movl 120(%esp,%eax), %eax
315 ; X86-NEXT: movb %ch, %cl
316 ; X86-NEXT: shldl %cl, %eax, %ebp
317 ; X86-NEXT: shll %cl, %eax
318 ; X86-NEXT: movl %eax, (%esp) # 4-byte Spill
319 ; X86-NEXT: addl $1, %ebx
320 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
321 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
322 ; X86-NEXT: adcl $0, %ecx
323 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
324 ; X86-NEXT: adcl $0, %eax
325 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Reload
326 ; X86-NEXT: adcl $0, %ebx
327 ; X86-NEXT: jae .LBB4_2
329 ; X86-NEXT: xorl %eax, %eax
330 ; X86-NEXT: xorl %ecx, %ecx
331 ; X86-NEXT: jmp .LBB4_6
332 ; X86-NEXT: .LBB4_2: # %udiv-preheader
333 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
334 ; X86-NEXT: movl %edx, {{[0-9]+}}(%esp)
335 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
336 ; X86-NEXT: movl %edx, {{[0-9]+}}(%esp)
337 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
338 ; X86-NEXT: movl %edx, {{[0-9]+}}(%esp)
339 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
340 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
341 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
342 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
343 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
344 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
345 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
346 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
347 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
348 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
349 ; X86-NEXT: movb %al, %ch
350 ; X86-NEXT: andb $7, %ch
351 ; X86-NEXT: # kill: def $al killed $al killed $eax
352 ; X86-NEXT: shrb $3, %al
353 ; X86-NEXT: andb $15, %al
354 ; X86-NEXT: movzbl %al, %eax
355 ; X86-NEXT: movl 84(%esp,%eax), %ebx
356 ; X86-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
357 ; X86-NEXT: movl 80(%esp,%eax), %esi
358 ; X86-NEXT: movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
359 ; X86-NEXT: movl %esi, %edx
360 ; X86-NEXT: movb %ch, %cl
361 ; X86-NEXT: shrdl %cl, %ebx, %edx
362 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
363 ; X86-NEXT: movl 72(%esp,%eax), %ebp
364 ; X86-NEXT: movl 76(%esp,%eax), %edx
365 ; X86-NEXT: movl %edx, %eax
366 ; X86-NEXT: shrl %cl, %eax
368 ; X86-NEXT: addl %esi, %esi
369 ; X86-NEXT: shll %cl, %esi
370 ; X86-NEXT: orl %eax, %esi
371 ; X86-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
372 ; X86-NEXT: movb %ch, %cl
373 ; X86-NEXT: shrl %cl, %ebx
374 ; X86-NEXT: movl %ebx, %edi
375 ; X86-NEXT: shrdl %cl, %edx, %ebp
376 ; X86-NEXT: movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
377 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
378 ; X86-NEXT: addl $-1, %eax
379 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
380 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
381 ; X86-NEXT: adcl $-1, %eax
382 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
383 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
384 ; X86-NEXT: adcl $-1, %ecx
385 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
386 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
387 ; X86-NEXT: adcl $-1, %edx
388 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
389 ; X86-NEXT: xorl %ecx, %ecx
390 ; X86-NEXT: movl $0, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Spill
391 ; X86-NEXT: movl (%esp), %edx # 4-byte Reload
392 ; X86-NEXT: .p2align 4, 0x90
393 ; X86-NEXT: .LBB4_3: # %udiv-do-while
394 ; X86-NEXT: # =>This Inner Loop Header: Depth=1
395 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
396 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebp # 4-byte Reload
397 ; X86-NEXT: shldl $1, %ebp, %edi
398 ; X86-NEXT: movl %edi, (%esp) # 4-byte Spill
399 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Reload
400 ; X86-NEXT: shldl $1, %ebx, %ebp
401 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
402 ; X86-NEXT: shldl $1, %esi, %ebx
403 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Reload
404 ; X86-NEXT: shldl $1, %edi, %esi
405 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
406 ; X86-NEXT: shldl $1, %eax, %edi
407 ; X86-NEXT: orl %ecx, %edi
408 ; X86-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
409 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Reload
410 ; X86-NEXT: shldl $1, %edi, %eax
411 ; X86-NEXT: orl %ecx, %eax
412 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
413 ; X86-NEXT: shldl $1, %edx, %edi
414 ; X86-NEXT: orl %ecx, %edi
415 ; X86-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
416 ; X86-NEXT: addl %edx, %edx
417 ; X86-NEXT: orl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Folded Reload
418 ; X86-NEXT: cmpl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Reload
419 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
420 ; X86-NEXT: sbbl %ebx, %ecx
421 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
422 ; X86-NEXT: sbbl %ebp, %ecx
423 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
424 ; X86-NEXT: sbbl (%esp), %ecx # 4-byte Folded Reload
425 ; X86-NEXT: sarl $31, %ecx
426 ; X86-NEXT: movl %ecx, %eax
427 ; X86-NEXT: andl $1, %eax
428 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
429 ; X86-NEXT: movl %ecx, %eax
430 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
431 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
432 ; X86-NEXT: movl %ecx, %edi
433 ; X86-NEXT: andl {{[0-9]+}}(%esp), %edi
434 ; X86-NEXT: movl %ecx, %eax
435 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
436 ; X86-NEXT: andl {{[0-9]+}}(%esp), %ecx
437 ; X86-NEXT: subl %ecx, %esi
438 ; X86-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
439 ; X86-NEXT: sbbl %eax, %ebx
440 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
441 ; X86-NEXT: sbbl %edi, %ebp
442 ; X86-NEXT: movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
443 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
444 ; X86-NEXT: sbbl %eax, (%esp) # 4-byte Folded Spill
445 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
446 ; X86-NEXT: addl $-1, %ecx
447 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
448 ; X86-NEXT: adcl $-1, %eax
449 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Reload
450 ; X86-NEXT: adcl $-1, %ebx
451 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Reload
452 ; X86-NEXT: adcl $-1, %edi
453 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
454 ; X86-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
455 ; X86-NEXT: orl %edi, %eax
456 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
457 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
458 ; X86-NEXT: orl %ebx, %ecx
459 ; X86-NEXT: movl (%esp), %edi # 4-byte Reload
460 ; X86-NEXT: orl %eax, %ecx
461 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
462 ; X86-NEXT: jne .LBB4_3
464 ; X86-NEXT: movl %edx, (%esp) # 4-byte Spill
465 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Reload
466 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebp # 4-byte Reload
467 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
468 ; X86-NEXT: .LBB4_6: # %udiv-loop-exit
469 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
470 ; X86-NEXT: shldl $1, %esi, %edx
471 ; X86-NEXT: orl %ecx, %edx
472 ; X86-NEXT: shldl $1, %ebp, %esi
473 ; X86-NEXT: orl %ecx, %esi
474 ; X86-NEXT: movl (%esp), %ebx # 4-byte Reload
475 ; X86-NEXT: shldl $1, %ebx, %ebp
476 ; X86-NEXT: orl %ecx, %ebp
477 ; X86-NEXT: addl %ebx, %ebx
478 ; X86-NEXT: orl %eax, %ebx
479 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
480 ; X86-NEXT: .LBB4_7: # %udiv-end
481 ; X86-NEXT: movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
482 ; X86-NEXT: movl %ebx, (%eax)
483 ; X86-NEXT: movl %ebp, 4(%eax)
484 ; X86-NEXT: movl %esi, 8(%eax)
485 ; X86-NEXT: movl %edx, 12(%eax)
486 ; X86-NEXT: movl %ebx, %ecx
487 ; X86-NEXT: movl %ebx, (%esp) # 4-byte Spill
488 ; X86-NEXT: movl %esi, %ebx
489 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
490 ; X86-NEXT: movl %eax, %esi
491 ; X86-NEXT: imull %ebp, %esi
492 ; X86-NEXT: movl %edx, %edi
493 ; X86-NEXT: mull %ecx
494 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
495 ; X86-NEXT: addl %esi, %edx
496 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
497 ; X86-NEXT: imull %ecx, %ebp
498 ; X86-NEXT: addl %edx, %ebp
499 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
500 ; X86-NEXT: movl %esi, %eax
501 ; X86-NEXT: mull %ebx
502 ; X86-NEXT: movl %eax, %ecx
503 ; X86-NEXT: imull %esi, %edi
504 ; X86-NEXT: addl %edx, %edi
505 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
506 ; X86-NEXT: imull %eax, %ebx
507 ; X86-NEXT: addl %edi, %ebx
508 ; X86-NEXT: addl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Folded Reload
509 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
510 ; X86-NEXT: adcl %ebp, %ebx
511 ; X86-NEXT: movl (%esp), %ebp # 4-byte Reload
512 ; X86-NEXT: movl %ebp, %eax
513 ; X86-NEXT: mull %esi
514 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
515 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
516 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
517 ; X86-NEXT: mull %esi
518 ; X86-NEXT: movl %edx, %edi
519 ; X86-NEXT: movl %eax, %ecx
520 ; X86-NEXT: addl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Folded Reload
521 ; X86-NEXT: adcl $0, %edi
522 ; X86-NEXT: movl %ebp, %eax
523 ; X86-NEXT: mull {{[0-9]+}}(%esp)
524 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
525 ; X86-NEXT: movl %edx, %ebp
526 ; X86-NEXT: addl %ecx, %eax
527 ; X86-NEXT: movl %eax, (%esp) # 4-byte Spill
528 ; X86-NEXT: adcl %edi, %ebp
530 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
531 ; X86-NEXT: mull {{[0-9]+}}(%esp)
532 ; X86-NEXT: addl %ebp, %eax
533 ; X86-NEXT: movzbl %cl, %ecx
534 ; X86-NEXT: adcl %ecx, %edx
535 ; X86-NEXT: addl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Folded Reload
536 ; X86-NEXT: adcl %ebx, %edx
537 ; X86-NEXT: subl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Folded Reload
538 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
539 ; X86-NEXT: sbbl (%esp), %edi # 4-byte Folded Reload
540 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
541 ; X86-NEXT: sbbl %eax, %ebx
542 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
543 ; X86-NEXT: sbbl %edx, %ecx
544 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
545 ; X86-NEXT: movl %esi, (%eax)
546 ; X86-NEXT: movl %edi, 4(%eax)
547 ; X86-NEXT: movl %ebx, 8(%eax)
548 ; X86-NEXT: movl %ecx, 12(%eax)
549 ; X86-NEXT: addl $136, %esp
550 ; X86-NEXT: popl %esi
551 ; X86-NEXT: popl %edi
552 ; X86-NEXT: popl %ebx
553 ; X86-NEXT: popl %ebp
556 ; X64-LABEL: scalar_i128:
558 ; X64-NEXT: pushq %r15
559 ; X64-NEXT: pushq %r14
560 ; X64-NEXT: pushq %r13
561 ; X64-NEXT: pushq %r12
562 ; X64-NEXT: pushq %rbx
563 ; X64-NEXT: movq %r8, %r15
564 ; X64-NEXT: movq %rcx, %r12
565 ; X64-NEXT: movq %rdx, %r13
566 ; X64-NEXT: movq %rsi, %rbx
567 ; X64-NEXT: movq %rdi, %r14
568 ; X64-NEXT: callq __udivti3@PLT
569 ; X64-NEXT: movq %rdx, %rcx
570 ; X64-NEXT: movq %rdx, 8(%r15)
571 ; X64-NEXT: movq %rax, (%r15)
572 ; X64-NEXT: imulq %rax, %r12
573 ; X64-NEXT: mulq %r13
574 ; X64-NEXT: addq %r12, %rdx
575 ; X64-NEXT: imulq %r13, %rcx
576 ; X64-NEXT: addq %rdx, %rcx
577 ; X64-NEXT: subq %rax, %r14
578 ; X64-NEXT: sbbq %rcx, %rbx
579 ; X64-NEXT: movq %r14, %rax
580 ; X64-NEXT: movq %rbx, %rdx
581 ; X64-NEXT: popq %rbx
582 ; X64-NEXT: popq %r12
583 ; X64-NEXT: popq %r13
584 ; X64-NEXT: popq %r14
585 ; X64-NEXT: popq %r15
587 %div = udiv i128 %x, %y
588 store i128 %div, ptr %divdst, align 4
589 %t1 = mul i128 %div, %y
590 %t2 = sub i128 %x, %t1
594 define <16 x i8> @vector_i128_i8(<16 x i8> %x, <16 x i8> %y, ptr %divdst) nounwind {
595 ; X86-LABEL: vector_i128_i8:
597 ; X86-NEXT: pushl %ebp
598 ; X86-NEXT: movl %esp, %ebp
599 ; X86-NEXT: pushl %ebx
600 ; X86-NEXT: pushl %edi
601 ; X86-NEXT: pushl %esi
602 ; X86-NEXT: andl $-16, %esp
603 ; X86-NEXT: subl $48, %esp
604 ; X86-NEXT: movdqa %xmm0, (%esp)
605 ; X86-NEXT: movdqa %xmm1, {{[0-9]+}}(%esp)
606 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
607 ; X86-NEXT: divb {{[0-9]+}}(%esp)
608 ; X86-NEXT: movzbl %al, %eax
609 ; X86-NEXT: movd %eax, %xmm2
610 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
611 ; X86-NEXT: divb {{[0-9]+}}(%esp)
612 ; X86-NEXT: movzbl %al, %eax
613 ; X86-NEXT: movd %eax, %xmm3
614 ; X86-NEXT: punpcklbw {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1],xmm3[2],xmm2[2],xmm3[3],xmm2[3],xmm3[4],xmm2[4],xmm3[5],xmm2[5],xmm3[6],xmm2[6],xmm3[7],xmm2[7]
615 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
616 ; X86-NEXT: divb {{[0-9]+}}(%esp)
617 ; X86-NEXT: movzbl %al, %eax
618 ; X86-NEXT: movd %eax, %xmm4
619 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
620 ; X86-NEXT: divb {{[0-9]+}}(%esp)
621 ; X86-NEXT: movzbl %al, %eax
622 ; X86-NEXT: movd %eax, %xmm2
623 ; X86-NEXT: punpcklbw {{.*#+}} xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1],xmm2[2],xmm4[2],xmm2[3],xmm4[3],xmm2[4],xmm4[4],xmm2[5],xmm4[5],xmm2[6],xmm4[6],xmm2[7],xmm4[7]
624 ; X86-NEXT: punpcklwd {{.*#+}} xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1],xmm2[2],xmm3[2],xmm2[3],xmm3[3]
625 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
626 ; X86-NEXT: divb {{[0-9]+}}(%esp)
627 ; X86-NEXT: movzbl %al, %eax
628 ; X86-NEXT: movd %eax, %xmm3
629 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
630 ; X86-NEXT: divb {{[0-9]+}}(%esp)
631 ; X86-NEXT: movzbl %al, %eax
632 ; X86-NEXT: movd %eax, %xmm4
633 ; X86-NEXT: punpcklbw {{.*#+}} xmm4 = xmm4[0],xmm3[0],xmm4[1],xmm3[1],xmm4[2],xmm3[2],xmm4[3],xmm3[3],xmm4[4],xmm3[4],xmm4[5],xmm3[5],xmm4[6],xmm3[6],xmm4[7],xmm3[7]
634 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
635 ; X86-NEXT: divb {{[0-9]+}}(%esp)
636 ; X86-NEXT: movzbl %al, %eax
637 ; X86-NEXT: movd %eax, %xmm5
638 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
639 ; X86-NEXT: divb {{[0-9]+}}(%esp)
640 ; X86-NEXT: movzbl %al, %eax
641 ; X86-NEXT: movd %eax, %xmm3
642 ; X86-NEXT: punpcklbw {{.*#+}} xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1],xmm3[2],xmm5[2],xmm3[3],xmm5[3],xmm3[4],xmm5[4],xmm3[5],xmm5[5],xmm3[6],xmm5[6],xmm3[7],xmm5[7]
643 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
644 ; X86-NEXT: divb {{[0-9]+}}(%esp)
645 ; X86-NEXT: movzbl %al, %eax
646 ; X86-NEXT: movd %eax, %xmm5
647 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
648 ; X86-NEXT: divb {{[0-9]+}}(%esp)
649 ; X86-NEXT: movzbl %al, %eax
650 ; X86-NEXT: movd %eax, %xmm6
651 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
652 ; X86-NEXT: divb {{[0-9]+}}(%esp)
653 ; X86-NEXT: movzbl %al, %edx
654 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
655 ; X86-NEXT: divb {{[0-9]+}}(%esp)
656 ; X86-NEXT: movzbl %al, %esi
657 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
658 ; X86-NEXT: divb {{[0-9]+}}(%esp)
659 ; X86-NEXT: movzbl %al, %edi
660 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
661 ; X86-NEXT: divb {{[0-9]+}}(%esp)
662 ; X86-NEXT: movzbl %al, %ebx
663 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
664 ; X86-NEXT: divb {{[0-9]+}}(%esp)
665 ; X86-NEXT: movl %eax, %ecx
666 ; X86-NEXT: movzbl (%esp), %eax
667 ; X86-NEXT: divb {{[0-9]+}}(%esp)
668 ; X86-NEXT: punpcklwd {{.*#+}} xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1],xmm3[2],xmm4[2],xmm3[3],xmm4[3]
669 ; X86-NEXT: movd %edx, %xmm7
670 ; X86-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
671 ; X86-NEXT: movd %esi, %xmm4
672 ; X86-NEXT: punpcklbw {{.*#+}} xmm6 = xmm6[0],xmm5[0],xmm6[1],xmm5[1],xmm6[2],xmm5[2],xmm6[3],xmm5[3],xmm6[4],xmm5[4],xmm6[5],xmm5[5],xmm6[6],xmm5[6],xmm6[7],xmm5[7]
673 ; X86-NEXT: movd %edi, %xmm2
674 ; X86-NEXT: punpcklbw {{.*#+}} xmm4 = xmm4[0],xmm7[0],xmm4[1],xmm7[1],xmm4[2],xmm7[2],xmm4[3],xmm7[3],xmm4[4],xmm7[4],xmm4[5],xmm7[5],xmm4[6],xmm7[6],xmm4[7],xmm7[7]
675 ; X86-NEXT: punpcklwd {{.*#+}} xmm4 = xmm4[0],xmm6[0],xmm4[1],xmm6[1],xmm4[2],xmm6[2],xmm4[3],xmm6[3]
676 ; X86-NEXT: movd %ebx, %xmm5
677 ; X86-NEXT: movzbl %cl, %ecx
678 ; X86-NEXT: movd %ecx, %xmm6
679 ; X86-NEXT: movl 8(%ebp), %ecx
680 ; X86-NEXT: punpcklbw {{.*#+}} xmm5 = xmm5[0],xmm2[0],xmm5[1],xmm2[1],xmm5[2],xmm2[2],xmm5[3],xmm2[3],xmm5[4],xmm2[4],xmm5[5],xmm2[5],xmm5[6],xmm2[6],xmm5[7],xmm2[7]
681 ; X86-NEXT: movzbl %al, %eax
682 ; X86-NEXT: movd %eax, %xmm2
683 ; X86-NEXT: punpcklbw {{.*#+}} xmm2 = xmm2[0],xmm6[0],xmm2[1],xmm6[1],xmm2[2],xmm6[2],xmm2[3],xmm6[3],xmm2[4],xmm6[4],xmm2[5],xmm6[5],xmm2[6],xmm6[6],xmm2[7],xmm6[7]
684 ; X86-NEXT: punpcklwd {{.*#+}} xmm2 = xmm2[0],xmm5[0],xmm2[1],xmm5[1],xmm2[2],xmm5[2],xmm2[3],xmm5[3]
685 ; X86-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
686 ; X86-NEXT: movdqa %xmm2, %xmm4
687 ; X86-NEXT: punpcklqdq {{.*#+}} xmm4 = xmm4[0],xmm3[0]
688 ; X86-NEXT: movdqa %xmm4, (%ecx)
689 ; X86-NEXT: punpcklbw {{.*#+}} xmm3 = xmm3[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
690 ; X86-NEXT: movdqa %xmm1, %xmm4
691 ; X86-NEXT: punpckhbw {{.*#+}} xmm4 = xmm4[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
692 ; X86-NEXT: pmullw %xmm3, %xmm4
693 ; X86-NEXT: movdqa {{.*#+}} xmm3 = [255,255,255,255,255,255,255,255]
694 ; X86-NEXT: pand %xmm3, %xmm4
695 ; X86-NEXT: punpcklbw {{.*#+}} xmm2 = xmm2[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
696 ; X86-NEXT: punpcklbw {{.*#+}} xmm1 = xmm1[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
697 ; X86-NEXT: pmullw %xmm2, %xmm1
698 ; X86-NEXT: pand %xmm3, %xmm1
699 ; X86-NEXT: packuswb %xmm4, %xmm1
700 ; X86-NEXT: psubb %xmm1, %xmm0
701 ; X86-NEXT: leal -12(%ebp), %esp
702 ; X86-NEXT: popl %esi
703 ; X86-NEXT: popl %edi
704 ; X86-NEXT: popl %ebx
705 ; X86-NEXT: popl %ebp
708 ; X64-LABEL: vector_i128_i8:
710 ; X64-NEXT: pushq %rbp
711 ; X64-NEXT: pushq %r15
712 ; X64-NEXT: pushq %r14
713 ; X64-NEXT: pushq %r13
714 ; X64-NEXT: pushq %r12
715 ; X64-NEXT: pushq %rbx
716 ; X64-NEXT: movq %rdi, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
717 ; X64-NEXT: movdqa %xmm0, -{{[0-9]+}}(%rsp)
718 ; X64-NEXT: movdqa %xmm1, -{{[0-9]+}}(%rsp)
719 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
720 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
721 ; X64-NEXT: movzbl %al, %eax
722 ; X64-NEXT: movd %eax, %xmm2
723 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
724 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
725 ; X64-NEXT: movzbl %al, %edi
726 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
727 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
728 ; X64-NEXT: movzbl %al, %esi
729 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
730 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
731 ; X64-NEXT: movzbl %al, %r8d
732 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
733 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
734 ; X64-NEXT: movzbl %al, %r9d
735 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
736 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
737 ; X64-NEXT: movzbl %al, %r10d
738 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
739 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
740 ; X64-NEXT: movzbl %al, %r11d
741 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
742 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
743 ; X64-NEXT: movzbl %al, %ebx
744 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
745 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
746 ; X64-NEXT: movzbl %al, %ebp
747 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
748 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
749 ; X64-NEXT: movzbl %al, %r14d
750 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
751 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
752 ; X64-NEXT: movzbl %al, %r15d
753 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
754 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
755 ; X64-NEXT: movzbl %al, %r12d
756 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
757 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
758 ; X64-NEXT: movzbl %al, %r13d
759 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
760 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
761 ; X64-NEXT: movzbl %al, %edx
762 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
763 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
764 ; X64-NEXT: movl %eax, %ecx
765 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
766 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
767 ; X64-NEXT: movd %edi, %xmm3
768 ; X64-NEXT: movd %esi, %xmm4
769 ; X64-NEXT: movd %r8d, %xmm5
770 ; X64-NEXT: movd %r9d, %xmm6
771 ; X64-NEXT: punpcklbw {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1],xmm3[2],xmm2[2],xmm3[3],xmm2[3],xmm3[4],xmm2[4],xmm3[5],xmm2[5],xmm3[6],xmm2[6],xmm3[7],xmm2[7]
772 ; X64-NEXT: movd %r10d, %xmm7
773 ; X64-NEXT: punpcklbw {{.*#+}} xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1],xmm5[2],xmm4[2],xmm5[3],xmm4[3],xmm5[4],xmm4[4],xmm5[5],xmm4[5],xmm5[6],xmm4[6],xmm5[7],xmm4[7]
774 ; X64-NEXT: movd %r11d, %xmm4
775 ; X64-NEXT: punpcklwd {{.*#+}} xmm5 = xmm5[0],xmm3[0],xmm5[1],xmm3[1],xmm5[2],xmm3[2],xmm5[3],xmm3[3]
776 ; X64-NEXT: movd %ebx, %xmm2
777 ; X64-NEXT: punpcklbw {{.*#+}} xmm7 = xmm7[0],xmm6[0],xmm7[1],xmm6[1],xmm7[2],xmm6[2],xmm7[3],xmm6[3],xmm7[4],xmm6[4],xmm7[5],xmm6[5],xmm7[6],xmm6[6],xmm7[7],xmm6[7]
778 ; X64-NEXT: movd %ebp, %xmm3
779 ; X64-NEXT: punpcklbw {{.*#+}} xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1],xmm2[2],xmm4[2],xmm2[3],xmm4[3],xmm2[4],xmm4[4],xmm2[5],xmm4[5],xmm2[6],xmm4[6],xmm2[7],xmm4[7]
780 ; X64-NEXT: movd %r14d, %xmm4
781 ; X64-NEXT: punpcklwd {{.*#+}} xmm2 = xmm2[0],xmm7[0],xmm2[1],xmm7[1],xmm2[2],xmm7[2],xmm2[3],xmm7[3]
782 ; X64-NEXT: movd %r15d, %xmm6
783 ; X64-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm5[0],xmm2[1],xmm5[1]
784 ; X64-NEXT: movd %r12d, %xmm5
785 ; X64-NEXT: punpcklbw {{.*#+}} xmm4 = xmm4[0],xmm3[0],xmm4[1],xmm3[1],xmm4[2],xmm3[2],xmm4[3],xmm3[3],xmm4[4],xmm3[4],xmm4[5],xmm3[5],xmm4[6],xmm3[6],xmm4[7],xmm3[7]
786 ; X64-NEXT: movd %r13d, %xmm3
787 ; X64-NEXT: punpcklbw {{.*#+}} xmm5 = xmm5[0],xmm6[0],xmm5[1],xmm6[1],xmm5[2],xmm6[2],xmm5[3],xmm6[3],xmm5[4],xmm6[4],xmm5[5],xmm6[5],xmm5[6],xmm6[6],xmm5[7],xmm6[7]
788 ; X64-NEXT: movd %edx, %xmm6
789 ; X64-NEXT: punpcklwd {{.*#+}} xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1],xmm5[2],xmm4[2],xmm5[3],xmm4[3]
790 ; X64-NEXT: movzbl %cl, %ecx
791 ; X64-NEXT: movd %ecx, %xmm4
792 ; X64-NEXT: punpcklbw {{.*#+}} xmm6 = xmm6[0],xmm3[0],xmm6[1],xmm3[1],xmm6[2],xmm3[2],xmm6[3],xmm3[3],xmm6[4],xmm3[4],xmm6[5],xmm3[5],xmm6[6],xmm3[6],xmm6[7],xmm3[7]
793 ; X64-NEXT: movzbl %al, %eax
794 ; X64-NEXT: movd %eax, %xmm3
795 ; X64-NEXT: punpcklbw {{.*#+}} xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1],xmm3[2],xmm4[2],xmm3[3],xmm4[3],xmm3[4],xmm4[4],xmm3[5],xmm4[5],xmm3[6],xmm4[6],xmm3[7],xmm4[7]
796 ; X64-NEXT: punpcklwd {{.*#+}} xmm3 = xmm3[0],xmm6[0],xmm3[1],xmm6[1],xmm3[2],xmm6[2],xmm3[3],xmm6[3]
797 ; X64-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
798 ; X64-NEXT: movdqa %xmm3, %xmm4
799 ; X64-NEXT: punpcklqdq {{.*#+}} xmm4 = xmm4[0],xmm2[0]
800 ; X64-NEXT: movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
801 ; X64-NEXT: movdqa %xmm4, (%rax)
802 ; X64-NEXT: punpcklbw {{.*#+}} xmm2 = xmm2[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
803 ; X64-NEXT: movdqa %xmm1, %xmm4
804 ; X64-NEXT: punpckhbw {{.*#+}} xmm4 = xmm4[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
805 ; X64-NEXT: pmullw %xmm2, %xmm4
806 ; X64-NEXT: movdqa {{.*#+}} xmm2 = [255,255,255,255,255,255,255,255]
807 ; X64-NEXT: pand %xmm2, %xmm4
808 ; X64-NEXT: punpcklbw {{.*#+}} xmm3 = xmm3[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
809 ; X64-NEXT: punpcklbw {{.*#+}} xmm1 = xmm1[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
810 ; X64-NEXT: pmullw %xmm3, %xmm1
811 ; X64-NEXT: pand %xmm2, %xmm1
812 ; X64-NEXT: packuswb %xmm4, %xmm1
813 ; X64-NEXT: psubb %xmm1, %xmm0
814 ; X64-NEXT: popq %rbx
815 ; X64-NEXT: popq %r12
816 ; X64-NEXT: popq %r13
817 ; X64-NEXT: popq %r14
818 ; X64-NEXT: popq %r15
819 ; X64-NEXT: popq %rbp
821 %div = udiv <16 x i8> %x, %y
822 store <16 x i8> %div, ptr %divdst, align 16
823 %t1 = mul <16 x i8> %div, %y
824 %t2 = sub <16 x i8> %x, %t1
828 define <8 x i16> @vector_i128_i16(<8 x i16> %x, <8 x i16> %y, ptr %divdst) nounwind {
829 ; X86-LABEL: vector_i128_i16:
831 ; X86-NEXT: pushl %esi
832 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
833 ; X86-NEXT: pextrw $7, %xmm0, %eax
834 ; X86-NEXT: pextrw $7, %xmm1, %esi
835 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
836 ; X86-NEXT: xorl %edx, %edx
838 ; X86-NEXT: # kill: def $ax killed $ax def $eax
839 ; X86-NEXT: movd %eax, %xmm2
840 ; X86-NEXT: pextrw $6, %xmm0, %eax
841 ; X86-NEXT: pextrw $6, %xmm1, %esi
842 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
843 ; X86-NEXT: xorl %edx, %edx
845 ; X86-NEXT: # kill: def $ax killed $ax def $eax
846 ; X86-NEXT: movd %eax, %xmm3
847 ; X86-NEXT: punpcklwd {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1],xmm3[2],xmm2[2],xmm3[3],xmm2[3]
848 ; X86-NEXT: pextrw $5, %xmm0, %eax
849 ; X86-NEXT: pextrw $5, %xmm1, %esi
850 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
851 ; X86-NEXT: xorl %edx, %edx
853 ; X86-NEXT: # kill: def $ax killed $ax def $eax
854 ; X86-NEXT: movd %eax, %xmm4
855 ; X86-NEXT: pextrw $4, %xmm0, %eax
856 ; X86-NEXT: pextrw $4, %xmm1, %esi
857 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
858 ; X86-NEXT: xorl %edx, %edx
860 ; X86-NEXT: # kill: def $ax killed $ax def $eax
861 ; X86-NEXT: movd %eax, %xmm2
862 ; X86-NEXT: punpcklwd {{.*#+}} xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1],xmm2[2],xmm4[2],xmm2[3],xmm4[3]
863 ; X86-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
864 ; X86-NEXT: pextrw $3, %xmm0, %eax
865 ; X86-NEXT: pextrw $3, %xmm1, %esi
866 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
867 ; X86-NEXT: xorl %edx, %edx
869 ; X86-NEXT: # kill: def $ax killed $ax def $eax
870 ; X86-NEXT: movd %eax, %xmm4
871 ; X86-NEXT: pextrw $2, %xmm0, %eax
872 ; X86-NEXT: pextrw $2, %xmm1, %esi
873 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
874 ; X86-NEXT: xorl %edx, %edx
876 ; X86-NEXT: # kill: def $ax killed $ax def $eax
877 ; X86-NEXT: movd %eax, %xmm3
878 ; X86-NEXT: punpcklwd {{.*#+}} xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1],xmm3[2],xmm4[2],xmm3[3],xmm4[3]
879 ; X86-NEXT: pextrw $1, %xmm0, %eax
880 ; X86-NEXT: pextrw $1, %xmm1, %esi
881 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
882 ; X86-NEXT: xorl %edx, %edx
884 ; X86-NEXT: # kill: def $ax killed $ax def $eax
885 ; X86-NEXT: movd %eax, %xmm4
886 ; X86-NEXT: movd %xmm0, %eax
887 ; X86-NEXT: movd %xmm1, %esi
888 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
889 ; X86-NEXT: xorl %edx, %edx
891 ; X86-NEXT: # kill: def $ax killed $ax def $eax
892 ; X86-NEXT: movd %eax, %xmm5
893 ; X86-NEXT: punpcklwd {{.*#+}} xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1],xmm5[2],xmm4[2],xmm5[3],xmm4[3]
894 ; X86-NEXT: punpckldq {{.*#+}} xmm5 = xmm5[0],xmm3[0],xmm5[1],xmm3[1]
895 ; X86-NEXT: punpcklqdq {{.*#+}} xmm5 = xmm5[0],xmm2[0]
896 ; X86-NEXT: movdqa %xmm5, (%ecx)
897 ; X86-NEXT: pmullw %xmm1, %xmm5
898 ; X86-NEXT: psubw %xmm5, %xmm0
899 ; X86-NEXT: popl %esi
902 ; X64-LABEL: vector_i128_i16:
904 ; X64-NEXT: pextrw $7, %xmm0, %eax
905 ; X64-NEXT: pextrw $7, %xmm1, %ecx
906 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
907 ; X64-NEXT: xorl %edx, %edx
909 ; X64-NEXT: # kill: def $ax killed $ax def $eax
910 ; X64-NEXT: movd %eax, %xmm2
911 ; X64-NEXT: pextrw $6, %xmm0, %eax
912 ; X64-NEXT: pextrw $6, %xmm1, %ecx
913 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
914 ; X64-NEXT: xorl %edx, %edx
916 ; X64-NEXT: # kill: def $ax killed $ax def $eax
917 ; X64-NEXT: movd %eax, %xmm3
918 ; X64-NEXT: punpcklwd {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1],xmm3[2],xmm2[2],xmm3[3],xmm2[3]
919 ; X64-NEXT: pextrw $5, %xmm0, %eax
920 ; X64-NEXT: pextrw $5, %xmm1, %ecx
921 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
922 ; X64-NEXT: xorl %edx, %edx
924 ; X64-NEXT: # kill: def $ax killed $ax def $eax
925 ; X64-NEXT: movd %eax, %xmm4
926 ; X64-NEXT: pextrw $4, %xmm0, %eax
927 ; X64-NEXT: pextrw $4, %xmm1, %ecx
928 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
929 ; X64-NEXT: xorl %edx, %edx
931 ; X64-NEXT: # kill: def $ax killed $ax def $eax
932 ; X64-NEXT: movd %eax, %xmm2
933 ; X64-NEXT: punpcklwd {{.*#+}} xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1],xmm2[2],xmm4[2],xmm2[3],xmm4[3]
934 ; X64-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
935 ; X64-NEXT: pextrw $3, %xmm0, %eax
936 ; X64-NEXT: pextrw $3, %xmm1, %ecx
937 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
938 ; X64-NEXT: xorl %edx, %edx
940 ; X64-NEXT: # kill: def $ax killed $ax def $eax
941 ; X64-NEXT: movd %eax, %xmm3
942 ; X64-NEXT: pextrw $2, %xmm0, %eax
943 ; X64-NEXT: pextrw $2, %xmm1, %ecx
944 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
945 ; X64-NEXT: xorl %edx, %edx
947 ; X64-NEXT: # kill: def $ax killed $ax def $eax
948 ; X64-NEXT: movd %eax, %xmm4
949 ; X64-NEXT: punpcklwd {{.*#+}} xmm4 = xmm4[0],xmm3[0],xmm4[1],xmm3[1],xmm4[2],xmm3[2],xmm4[3],xmm3[3]
950 ; X64-NEXT: pextrw $1, %xmm0, %eax
951 ; X64-NEXT: pextrw $1, %xmm1, %ecx
952 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
953 ; X64-NEXT: xorl %edx, %edx
955 ; X64-NEXT: # kill: def $ax killed $ax def $eax
956 ; X64-NEXT: movd %eax, %xmm3
957 ; X64-NEXT: movd %xmm0, %eax
958 ; X64-NEXT: movd %xmm1, %ecx
959 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
960 ; X64-NEXT: xorl %edx, %edx
962 ; X64-NEXT: # kill: def $ax killed $ax def $eax
963 ; X64-NEXT: movd %eax, %xmm5
964 ; X64-NEXT: punpcklwd {{.*#+}} xmm5 = xmm5[0],xmm3[0],xmm5[1],xmm3[1],xmm5[2],xmm3[2],xmm5[3],xmm3[3]
965 ; X64-NEXT: punpckldq {{.*#+}} xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1]
966 ; X64-NEXT: punpcklqdq {{.*#+}} xmm5 = xmm5[0],xmm2[0]
967 ; X64-NEXT: movdqa %xmm5, (%rdi)
968 ; X64-NEXT: pmullw %xmm1, %xmm5
969 ; X64-NEXT: psubw %xmm5, %xmm0
971 %div = udiv <8 x i16> %x, %y
972 store <8 x i16> %div, ptr %divdst, align 16
973 %t1 = mul <8 x i16> %div, %y
974 %t2 = sub <8 x i16> %x, %t1
978 define <4 x i32> @vector_i128_i32(<4 x i32> %x, <4 x i32> %y, ptr %divdst) nounwind {
979 ; X86-LABEL: vector_i128_i32:
981 ; X86-NEXT: pushl %esi
982 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
983 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm0[3,3,3,3]
984 ; X86-NEXT: movd %xmm2, %eax
985 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm1[3,3,3,3]
986 ; X86-NEXT: movd %xmm2, %esi
987 ; X86-NEXT: xorl %edx, %edx
988 ; X86-NEXT: divl %esi
989 ; X86-NEXT: movd %eax, %xmm3
990 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm0[2,3,2,3]
991 ; X86-NEXT: movd %xmm2, %eax
992 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm1[2,3,2,3]
993 ; X86-NEXT: movd %xmm2, %esi
994 ; X86-NEXT: xorl %edx, %edx
995 ; X86-NEXT: divl %esi
996 ; X86-NEXT: movd %eax, %xmm2
997 ; X86-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
998 ; X86-NEXT: movd %xmm0, %eax
999 ; X86-NEXT: movd %xmm1, %esi
1000 ; X86-NEXT: xorl %edx, %edx
1001 ; X86-NEXT: divl %esi
1002 ; X86-NEXT: movd %eax, %xmm3
1003 ; X86-NEXT: pshufd {{.*#+}} xmm4 = xmm0[1,1,1,1]
1004 ; X86-NEXT: movd %xmm4, %eax
1005 ; X86-NEXT: pshufd {{.*#+}} xmm4 = xmm1[1,1,1,1]
1006 ; X86-NEXT: movd %xmm4, %esi
1007 ; X86-NEXT: xorl %edx, %edx
1008 ; X86-NEXT: divl %esi
1009 ; X86-NEXT: movd %eax, %xmm4
1010 ; X86-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1]
1011 ; X86-NEXT: punpcklqdq {{.*#+}} xmm3 = xmm3[0],xmm2[0]
1012 ; X86-NEXT: movdqa %xmm3, (%ecx)
1013 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm3[1,1,3,3]
1014 ; X86-NEXT: pmuludq %xmm1, %xmm3
1015 ; X86-NEXT: pshufd {{.*#+}} xmm3 = xmm3[0,2,2,3]
1016 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
1017 ; X86-NEXT: pmuludq %xmm2, %xmm1
1018 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
1019 ; X86-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
1020 ; X86-NEXT: psubd %xmm3, %xmm0
1021 ; X86-NEXT: popl %esi
1024 ; X64-LABEL: vector_i128_i32:
1026 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm0[3,3,3,3]
1027 ; X64-NEXT: movd %xmm2, %eax
1028 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm1[3,3,3,3]
1029 ; X64-NEXT: movd %xmm2, %ecx
1030 ; X64-NEXT: xorl %edx, %edx
1031 ; X64-NEXT: divl %ecx
1032 ; X64-NEXT: movd %eax, %xmm2
1033 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm0[2,3,2,3]
1034 ; X64-NEXT: movd %xmm3, %eax
1035 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm1[2,3,2,3]
1036 ; X64-NEXT: movd %xmm3, %ecx
1037 ; X64-NEXT: xorl %edx, %edx
1038 ; X64-NEXT: divl %ecx
1039 ; X64-NEXT: movd %eax, %xmm3
1040 ; X64-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
1041 ; X64-NEXT: movd %xmm0, %eax
1042 ; X64-NEXT: movd %xmm1, %ecx
1043 ; X64-NEXT: xorl %edx, %edx
1044 ; X64-NEXT: divl %ecx
1045 ; X64-NEXT: movd %eax, %xmm2
1046 ; X64-NEXT: pshufd {{.*#+}} xmm4 = xmm0[1,1,1,1]
1047 ; X64-NEXT: movd %xmm4, %eax
1048 ; X64-NEXT: pshufd {{.*#+}} xmm4 = xmm1[1,1,1,1]
1049 ; X64-NEXT: movd %xmm4, %ecx
1050 ; X64-NEXT: xorl %edx, %edx
1051 ; X64-NEXT: divl %ecx
1052 ; X64-NEXT: movd %eax, %xmm4
1053 ; X64-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
1054 ; X64-NEXT: punpcklqdq {{.*#+}} xmm2 = xmm2[0],xmm3[0]
1055 ; X64-NEXT: movdqa %xmm2, (%rdi)
1056 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm2[1,1,3,3]
1057 ; X64-NEXT: pmuludq %xmm1, %xmm2
1058 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3]
1059 ; X64-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
1060 ; X64-NEXT: pmuludq %xmm3, %xmm1
1061 ; X64-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
1062 ; X64-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
1063 ; X64-NEXT: psubd %xmm2, %xmm0
1065 %div = udiv <4 x i32> %x, %y
1066 store <4 x i32> %div, ptr %divdst, align 16
1067 %t1 = mul <4 x i32> %div, %y
1068 %t2 = sub <4 x i32> %x, %t1
1072 define <2 x i64> @vector_i128_i64(<2 x i64> %x, <2 x i64> %y, ptr %divdst) nounwind {
1073 ; X86-LABEL: vector_i128_i64:
1075 ; X86-NEXT: pushl %esi
1076 ; X86-NEXT: subl $64, %esp
1077 ; X86-NEXT: movdqu %xmm1, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
1078 ; X86-NEXT: movdqu %xmm0, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
1079 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1080 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm1[3,3,3,3]
1081 ; X86-NEXT: movd %xmm2, {{[0-9]+}}(%esp)
1082 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm1[2,3,2,3]
1083 ; X86-NEXT: movd %xmm2, {{[0-9]+}}(%esp)
1084 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm0[3,3,3,3]
1085 ; X86-NEXT: movd %xmm1, {{[0-9]+}}(%esp)
1086 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm0[2,3,2,3]
1087 ; X86-NEXT: movd %xmm1, (%esp)
1088 ; X86-NEXT: calll __udivdi3
1089 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm1 # 16-byte Reload
1090 ; X86-NEXT: pshufd {{.*#+}} xmm0 = xmm1[1,1,1,1]
1091 ; X86-NEXT: movd %xmm0, {{[0-9]+}}(%esp)
1092 ; X86-NEXT: movd %xmm1, {{[0-9]+}}(%esp)
1093 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm1 # 16-byte Reload
1094 ; X86-NEXT: pshufd {{.*#+}} xmm0 = xmm1[1,1,1,1]
1095 ; X86-NEXT: movd %xmm0, {{[0-9]+}}(%esp)
1096 ; X86-NEXT: movd %xmm1, (%esp)
1097 ; X86-NEXT: movd %edx, %xmm0
1098 ; X86-NEXT: movd %eax, %xmm1
1099 ; X86-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
1100 ; X86-NEXT: movdqu %xmm1, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
1101 ; X86-NEXT: calll __udivdi3
1102 ; X86-NEXT: movd %edx, %xmm1
1103 ; X86-NEXT: movd %eax, %xmm3
1104 ; X86-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
1105 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm0 # 16-byte Reload
1106 ; X86-NEXT: punpcklqdq {{.*#+}} xmm3 = xmm3[0],xmm0[0]
1107 ; X86-NEXT: movdqa %xmm3, (%esi)
1108 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm0 # 16-byte Reload
1109 ; X86-NEXT: movdqa %xmm0, %xmm1
1110 ; X86-NEXT: psrlq $32, %xmm1
1111 ; X86-NEXT: pmuludq %xmm3, %xmm1
1112 ; X86-NEXT: movdqa %xmm3, %xmm2
1113 ; X86-NEXT: psrlq $32, %xmm2
1114 ; X86-NEXT: pmuludq %xmm0, %xmm2
1115 ; X86-NEXT: paddq %xmm1, %xmm2
1116 ; X86-NEXT: psllq $32, %xmm2
1117 ; X86-NEXT: pmuludq %xmm0, %xmm3
1118 ; X86-NEXT: paddq %xmm2, %xmm3
1119 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm0 # 16-byte Reload
1120 ; X86-NEXT: psubq %xmm3, %xmm0
1121 ; X86-NEXT: addl $64, %esp
1122 ; X86-NEXT: popl %esi
1125 ; X64-LABEL: vector_i128_i64:
1127 ; X64-NEXT: movq %xmm0, %rax
1128 ; X64-NEXT: movq %xmm1, %rcx
1129 ; X64-NEXT: xorl %edx, %edx
1130 ; X64-NEXT: divq %rcx
1131 ; X64-NEXT: movq %rax, %xmm2
1132 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm0[2,3,2,3]
1133 ; X64-NEXT: movq %xmm3, %rax
1134 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm1[2,3,2,3]
1135 ; X64-NEXT: movq %xmm3, %rcx
1136 ; X64-NEXT: xorl %edx, %edx
1137 ; X64-NEXT: divq %rcx
1138 ; X64-NEXT: movq %rax, %xmm3
1139 ; X64-NEXT: punpcklqdq {{.*#+}} xmm2 = xmm2[0],xmm3[0]
1140 ; X64-NEXT: movdqa %xmm2, (%rdi)
1141 ; X64-NEXT: movdqa %xmm1, %xmm3
1142 ; X64-NEXT: psrlq $32, %xmm3
1143 ; X64-NEXT: pmuludq %xmm2, %xmm3
1144 ; X64-NEXT: movdqa %xmm2, %xmm4
1145 ; X64-NEXT: psrlq $32, %xmm4
1146 ; X64-NEXT: pmuludq %xmm1, %xmm4
1147 ; X64-NEXT: paddq %xmm3, %xmm4
1148 ; X64-NEXT: psllq $32, %xmm4
1149 ; X64-NEXT: pmuludq %xmm1, %xmm2
1150 ; X64-NEXT: paddq %xmm4, %xmm2
1151 ; X64-NEXT: psubq %xmm2, %xmm0
1153 %div = udiv <2 x i64> %x, %y
1154 store <2 x i64> %div, ptr %divdst, align 16
1155 %t1 = mul <2 x i64> %div, %y
1156 %t2 = sub <2 x i64> %x, %t1
1162 define i32 @scalar_i32_commutative(i32 %x, ptr %ysrc, ptr %divdst) nounwind {
1163 ; X86-LABEL: scalar_i32_commutative:
1165 ; X86-NEXT: pushl %edi
1166 ; X86-NEXT: pushl %esi
1167 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1168 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1169 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1170 ; X86-NEXT: movl (%eax), %edi
1171 ; X86-NEXT: movl %ecx, %eax
1172 ; X86-NEXT: xorl %edx, %edx
1173 ; X86-NEXT: divl %edi
1174 ; X86-NEXT: movl %eax, (%esi)
1175 ; X86-NEXT: imull %eax, %edi
1176 ; X86-NEXT: subl %edi, %ecx
1177 ; X86-NEXT: movl %ecx, %eax
1178 ; X86-NEXT: popl %esi
1179 ; X86-NEXT: popl %edi
1182 ; X64-LABEL: scalar_i32_commutative:
1184 ; X64-NEXT: movq %rdx, %rcx
1185 ; X64-NEXT: movl (%rsi), %esi
1186 ; X64-NEXT: movl %edi, %eax
1187 ; X64-NEXT: xorl %edx, %edx
1188 ; X64-NEXT: divl %esi
1189 ; X64-NEXT: movl %eax, (%rcx)
1190 ; X64-NEXT: imull %eax, %esi
1191 ; X64-NEXT: subl %esi, %edi
1192 ; X64-NEXT: movl %edi, %eax
1194 %y = load i32, ptr %ysrc, align 4
1195 %div = udiv i32 %x, %y
1196 store i32 %div, ptr %divdst, align 4
1197 %t1 = mul i32 %y, %div ; commutative
1198 %t2 = sub i32 %x, %t1
1202 ; We do not care about extra uses.
1203 define i32 @extrause(i32 %x, i32 %y, ptr %divdst, ptr %t1dst) nounwind {
1204 ; X86-LABEL: extrause:
1206 ; X86-NEXT: pushl %ebx
1207 ; X86-NEXT: pushl %edi
1208 ; X86-NEXT: pushl %esi
1209 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1210 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
1211 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1212 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
1213 ; X86-NEXT: movl %ecx, %eax
1214 ; X86-NEXT: xorl %edx, %edx
1215 ; X86-NEXT: divl %ebx
1216 ; X86-NEXT: movl %eax, (%edi)
1217 ; X86-NEXT: imull %ebx, %eax
1218 ; X86-NEXT: movl %eax, (%esi)
1219 ; X86-NEXT: subl %eax, %ecx
1220 ; X86-NEXT: movl %ecx, %eax
1221 ; X86-NEXT: popl %esi
1222 ; X86-NEXT: popl %edi
1223 ; X86-NEXT: popl %ebx
1226 ; X64-LABEL: extrause:
1228 ; X64-NEXT: movq %rdx, %r8
1229 ; X64-NEXT: movl %edi, %eax
1230 ; X64-NEXT: xorl %edx, %edx
1231 ; X64-NEXT: divl %esi
1232 ; X64-NEXT: movl %eax, (%r8)
1233 ; X64-NEXT: imull %esi, %eax
1234 ; X64-NEXT: movl %eax, (%rcx)
1235 ; X64-NEXT: subl %eax, %edi
1236 ; X64-NEXT: movl %edi, %eax
1238 %div = udiv i32 %x, %y
1239 store i32 %div, ptr %divdst, align 4
1240 %t1 = mul i32 %div, %y
1241 store i32 %t1, ptr %t1dst, align 4
1242 %t2 = sub i32 %x, %t1
1246 ; 'rem' should appear next to 'div'.
1247 define i32 @multiple_bb(i32 %x, i32 %y, ptr %divdst, i1 zeroext %store_urem, ptr %uremdst) nounwind {
1248 ; X86-LABEL: multiple_bb:
1250 ; X86-NEXT: pushl %ebx
1251 ; X86-NEXT: pushl %edi
1252 ; X86-NEXT: pushl %esi
1253 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1254 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1255 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ebx
1256 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
1257 ; X86-NEXT: movl %ecx, %eax
1258 ; X86-NEXT: xorl %edx, %edx
1259 ; X86-NEXT: divl %esi
1260 ; X86-NEXT: movl %eax, (%edi)
1261 ; X86-NEXT: testb %bl, %bl
1262 ; X86-NEXT: je .LBB11_2
1263 ; X86-NEXT: # %bb.1: # %do_urem
1264 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
1265 ; X86-NEXT: movl %eax, %edi
1266 ; X86-NEXT: imull %esi, %edi
1267 ; X86-NEXT: subl %edi, %ecx
1268 ; X86-NEXT: movl %ecx, (%edx)
1269 ; X86-NEXT: .LBB11_2: # %end
1270 ; X86-NEXT: popl %esi
1271 ; X86-NEXT: popl %edi
1272 ; X86-NEXT: popl %ebx
1275 ; X64-LABEL: multiple_bb:
1277 ; X64-NEXT: movq %rdx, %r9
1278 ; X64-NEXT: movl %edi, %eax
1279 ; X64-NEXT: xorl %edx, %edx
1280 ; X64-NEXT: divl %esi
1281 ; X64-NEXT: movl %eax, (%r9)
1282 ; X64-NEXT: testl %ecx, %ecx
1283 ; X64-NEXT: je .LBB11_2
1284 ; X64-NEXT: # %bb.1: # %do_urem
1285 ; X64-NEXT: movl %eax, %ecx
1286 ; X64-NEXT: imull %esi, %ecx
1287 ; X64-NEXT: subl %ecx, %edi
1288 ; X64-NEXT: movl %edi, (%r8)
1289 ; X64-NEXT: .LBB11_2: # %end
1291 %div = udiv i32 %x, %y
1292 store i32 %div, ptr %divdst, align 4
1293 br i1 %store_urem, label %do_urem, label %end
1295 %t1 = mul i32 %div, %y
1296 %t2 = sub i32 %x, %t1
1297 store i32 %t2, ptr %uremdst, align 4
1303 define i32 @negative_different_x(i32 %x0, i32 %x1, i32 %y, ptr %divdst) nounwind {
1304 ; X86-LABEL: negative_different_x:
1306 ; X86-NEXT: pushl %edi
1307 ; X86-NEXT: pushl %esi
1308 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1309 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1310 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1311 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
1312 ; X86-NEXT: xorl %edx, %edx
1313 ; X86-NEXT: divl %edi
1314 ; X86-NEXT: movl %eax, (%esi)
1315 ; X86-NEXT: imull %edi, %eax
1316 ; X86-NEXT: subl %eax, %ecx
1317 ; X86-NEXT: movl %ecx, %eax
1318 ; X86-NEXT: popl %esi
1319 ; X86-NEXT: popl %edi
1322 ; X64-LABEL: negative_different_x:
1324 ; X64-NEXT: movl %edx, %r8d
1325 ; X64-NEXT: movl %edi, %eax
1326 ; X64-NEXT: xorl %edx, %edx
1327 ; X64-NEXT: divl %r8d
1328 ; X64-NEXT: movl %eax, (%rcx)
1329 ; X64-NEXT: imull %r8d, %eax
1330 ; X64-NEXT: subl %eax, %esi
1331 ; X64-NEXT: movl %esi, %eax
1333 %div = udiv i32 %x0, %y ; not %x1
1334 store i32 %div, ptr %divdst, align 4
1335 %t1 = mul i32 %div, %y
1336 %t2 = sub i32 %x1, %t1 ; not %x0
1340 define i32 @negative_different_y(i32 %x0, i32 %x1, i32 %y, i32 %z, ptr %divdst) nounwind {
1341 ; X86-LABEL: negative_different_y:
1343 ; X86-NEXT: pushl %esi
1344 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1345 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1346 ; X86-NEXT: movl %ecx, %eax
1347 ; X86-NEXT: xorl %edx, %edx
1348 ; X86-NEXT: divl {{[0-9]+}}(%esp)
1349 ; X86-NEXT: movl %eax, (%esi)
1350 ; X86-NEXT: imull {{[0-9]+}}(%esp), %eax
1351 ; X86-NEXT: subl %eax, %ecx
1352 ; X86-NEXT: movl %ecx, %eax
1353 ; X86-NEXT: popl %esi
1356 ; X64-LABEL: negative_different_y:
1358 ; X64-NEXT: movl %edx, %edi
1359 ; X64-NEXT: movl %esi, %eax
1360 ; X64-NEXT: xorl %edx, %edx
1361 ; X64-NEXT: divl %ecx
1362 ; X64-NEXT: movl %eax, (%r8)
1363 ; X64-NEXT: imull %eax, %edi
1364 ; X64-NEXT: subl %edi, %esi
1365 ; X64-NEXT: movl %esi, %eax
1367 %div = udiv i32 %x1, %z ; not %x0
1368 store i32 %div, ptr %divdst, align 4
1369 %t1 = mul i32 %div, %y
1370 %t2 = sub i32 %x1, %t1
1374 define i32 @negative_inverted_division(i32 %x0, i32 %x1, i32 %y, ptr %divdst) nounwind {
1375 ; X86-LABEL: negative_inverted_division:
1377 ; X86-NEXT: pushl %esi
1378 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1379 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1380 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1381 ; X86-NEXT: xorl %edx, %edx
1382 ; X86-NEXT: divl %ecx
1383 ; X86-NEXT: movl %eax, (%esi)
1384 ; X86-NEXT: imull %ecx, %eax
1385 ; X86-NEXT: subl %eax, %ecx
1386 ; X86-NEXT: movl %ecx, %eax
1387 ; X86-NEXT: popl %esi
1390 ; X64-LABEL: negative_inverted_division:
1392 ; X64-NEXT: movl %edi, %eax
1393 ; X64-NEXT: xorl %edx, %edx
1394 ; X64-NEXT: divl %esi
1395 ; X64-NEXT: movl %eax, (%rcx)
1396 ; X64-NEXT: imull %esi, %eax
1397 ; X64-NEXT: subl %eax, %esi
1398 ; X64-NEXT: movl %esi, %eax
1400 %div = udiv i32 %x0, %x1 ; inverted division
1401 store i32 %div, ptr %divdst, align 4
1402 %t1 = mul i32 %div, %x1
1403 %t2 = sub i32 %x1, %t1