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), %edx
182 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
183 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
184 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
185 ; X86-NEXT: orl %esi, %eax
186 ; X86-NEXT: orl %edx, %ecx
187 ; X86-NEXT: movl %edx, %edi
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 %esi, %edx
199 ; X86-NEXT: xorl $31, %edx
200 ; X86-NEXT: bsrl %edi, %ecx
201 ; X86-NEXT: xorl $31, %ecx
202 ; X86-NEXT: addl $32, %ecx
203 ; X86-NEXT: testl %esi, %esi
204 ; X86-NEXT: cmovnel %edx, %ecx
205 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
206 ; X86-NEXT: bsrl %eax, %edx
207 ; X86-NEXT: xorl $31, %edx
208 ; X86-NEXT: bsrl {{[0-9]+}}(%esp), %ebp
209 ; X86-NEXT: movl %esi, %ebx
210 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
211 ; X86-NEXT: xorl $31, %ebp
212 ; X86-NEXT: addl $32, %ebp
213 ; X86-NEXT: testl %eax, %eax
214 ; X86-NEXT: cmovnel %edx, %ebp
215 ; X86-NEXT: addl $64, %ebp
216 ; X86-NEXT: orl %ebx, %edi
217 ; X86-NEXT: cmovnel %ecx, %ebp
218 ; X86-NEXT: bsrl %esi, %edx
219 ; X86-NEXT: xorl $31, %edx
220 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
221 ; X86-NEXT: bsrl %ebx, %ecx
222 ; X86-NEXT: xorl $31, %ecx
223 ; X86-NEXT: addl $32, %ecx
224 ; X86-NEXT: testl %esi, %esi
225 ; X86-NEXT: cmovnel %edx, %ecx
226 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
227 ; X86-NEXT: bsrl %edi, %esi
228 ; X86-NEXT: xorl $31, %esi
229 ; X86-NEXT: bsrl {{[0-9]+}}(%esp), %edx
230 ; X86-NEXT: xorl $31, %edx
231 ; X86-NEXT: addl $32, %edx
232 ; X86-NEXT: testl %edi, %edi
233 ; X86-NEXT: movl %edi, %eax
234 ; X86-NEXT: cmovnel %esi, %edx
235 ; X86-NEXT: addl $64, %edx
236 ; X86-NEXT: movl %ebx, %esi
237 ; X86-NEXT: orl {{[0-9]+}}(%esp), %esi
238 ; X86-NEXT: cmovnel %ecx, %edx
239 ; X86-NEXT: xorl %ecx, %ecx
240 ; X86-NEXT: subl %edx, %ebp
241 ; X86-NEXT: movl $0, %esi
242 ; X86-NEXT: sbbl %esi, %esi
243 ; X86-NEXT: movl $0, %edi
244 ; X86-NEXT: sbbl %edi, %edi
245 ; X86-NEXT: movl $0, %ebx
246 ; X86-NEXT: sbbl %ebx, %ebx
247 ; X86-NEXT: movl $127, %edx
248 ; X86-NEXT: movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
249 ; X86-NEXT: cmpl %ebp, %edx
250 ; X86-NEXT: movl $0, %edx
251 ; X86-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
252 ; X86-NEXT: sbbl %esi, %edx
253 ; X86-NEXT: movl $0, %edx
254 ; X86-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
255 ; X86-NEXT: sbbl %edi, %edx
256 ; X86-NEXT: movl $0, %edx
257 ; X86-NEXT: sbbl %ebx, %edx
259 ; X86-NEXT: orb (%esp), %dl # 1-byte Folded Reload
260 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
261 ; X86-NEXT: cmovnel %ecx, %edx
262 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
263 ; X86-NEXT: cmovnel %ecx, %esi
264 ; X86-NEXT: cmovnel %ecx, %eax
265 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
266 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
267 ; X86-NEXT: cmovnel %ecx, %ebp
268 ; X86-NEXT: jne .LBB4_8
269 ; X86-NEXT: # %bb.1: # %_udiv-special-cases
270 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
271 ; X86-NEXT: xorl $127, %eax
272 ; X86-NEXT: orl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Folded Reload
273 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
274 ; X86-NEXT: orl %ebx, %ecx
275 ; X86-NEXT: orl %eax, %ecx
276 ; X86-NEXT: je .LBB4_8
277 ; X86-NEXT: # %bb.2: # %udiv-bb1
278 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
279 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
280 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
281 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
282 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
283 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
284 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
285 ; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
286 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
287 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
288 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
289 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
290 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
291 ; X86-NEXT: movl %ecx, %eax
292 ; X86-NEXT: movl %ecx, %edi
293 ; X86-NEXT: xorb $127, %al
294 ; X86-NEXT: movb %al, %ch
295 ; X86-NEXT: andb $7, %ch
296 ; X86-NEXT: shrb $3, %al
297 ; X86-NEXT: andb $15, %al
299 ; X86-NEXT: movsbl %al, %eax
300 ; X86-NEXT: movl 128(%esp,%eax), %edx
301 ; X86-NEXT: movl 132(%esp,%eax), %esi
302 ; X86-NEXT: movb %ch, %cl
303 ; X86-NEXT: shldl %cl, %edx, %esi
304 ; X86-NEXT: movl %esi, (%esp) # 4-byte Spill
305 ; X86-NEXT: shll %cl, %edx
307 ; X86-NEXT: movl 124(%esp,%eax), %ebp
308 ; X86-NEXT: movl %ebp, %esi
309 ; X86-NEXT: shrl %esi
310 ; X86-NEXT: shrl %cl, %esi
311 ; X86-NEXT: orl %edx, %esi
312 ; X86-NEXT: movl %ebp, %edx
313 ; X86-NEXT: movl 120(%esp,%eax), %ebp
314 ; X86-NEXT: movb %ch, %cl
315 ; X86-NEXT: shldl %cl, %ebp, %edx
316 ; X86-NEXT: shll %cl, %ebp
317 ; X86-NEXT: addl $1, %edi
318 ; X86-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
319 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
320 ; X86-NEXT: adcl $0, %ecx
321 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
322 ; X86-NEXT: adcl $0, %eax
323 ; X86-NEXT: adcl $0, %ebx
324 ; X86-NEXT: jae .LBB4_3
326 ; X86-NEXT: xorl %eax, %eax
327 ; X86-NEXT: xorl %ecx, %ecx
328 ; X86-NEXT: movl %edx, %ebx
329 ; X86-NEXT: jmp .LBB4_7
330 ; X86-NEXT: .LBB4_3: # %udiv-preheader
331 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
332 ; X86-NEXT: movl %edi, {{[0-9]+}}(%esp)
333 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
334 ; X86-NEXT: movl %edi, {{[0-9]+}}(%esp)
335 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
336 ; X86-NEXT: movl %edi, {{[0-9]+}}(%esp)
337 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
338 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
339 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
340 ; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
341 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
342 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
343 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
344 ; X86-NEXT: movl $0, {{[0-9]+}}(%esp)
345 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
346 ; X86-NEXT: movb %al, %ch
347 ; X86-NEXT: andb $7, %ch
348 ; X86-NEXT: movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
349 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
350 ; X86-NEXT: # kill: def $al killed $al killed $eax
351 ; X86-NEXT: shrb $3, %al
352 ; X86-NEXT: andb $15, %al
353 ; X86-NEXT: movzbl %al, %eax
354 ; X86-NEXT: movl 84(%esp,%eax), %ebp
355 ; X86-NEXT: movl %esi, %edi
356 ; X86-NEXT: movl 80(%esp,%eax), %ebx
357 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
358 ; X86-NEXT: movl %ebx, %esi
359 ; X86-NEXT: movb %ch, %cl
360 ; X86-NEXT: shrdl %cl, %ebp, %esi
361 ; X86-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
362 ; X86-NEXT: movl 72(%esp,%eax), %esi
363 ; X86-NEXT: movl 76(%esp,%eax), %eax
364 ; X86-NEXT: movl %eax, %edx
365 ; X86-NEXT: shrl %cl, %edx
367 ; X86-NEXT: addl %ebx, %ebx
368 ; X86-NEXT: shll %cl, %ebx
369 ; X86-NEXT: orl %edx, %ebx
370 ; X86-NEXT: movb %ch, %cl
371 ; X86-NEXT: shrl %cl, %ebp
372 ; X86-NEXT: shrdl %cl, %eax, %esi
373 ; X86-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
374 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
375 ; X86-NEXT: addl $-1, %eax
376 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
377 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
378 ; X86-NEXT: adcl $-1, %eax
379 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
380 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
381 ; X86-NEXT: adcl $-1, %ecx
382 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
383 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
384 ; X86-NEXT: adcl $-1, %esi
385 ; X86-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
386 ; X86-NEXT: xorl %ecx, %ecx
387 ; X86-NEXT: movl $0, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Spill
388 ; X86-NEXT: movl (%esp), %esi # 4-byte Reload
389 ; X86-NEXT: .p2align 4, 0x90
390 ; X86-NEXT: .LBB4_4: # %udiv-do-while
391 ; X86-NEXT: # =>This Inner Loop Header: Depth=1
392 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
393 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
394 ; X86-NEXT: shldl $1, %edx, %ebp
395 ; X86-NEXT: movl %ebp, (%esp) # 4-byte Spill
396 ; X86-NEXT: shldl $1, %ebx, %edx
397 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebp # 4-byte Reload
398 ; X86-NEXT: shldl $1, %ebp, %ebx
399 ; X86-NEXT: shldl $1, %esi, %ebp
400 ; X86-NEXT: shldl $1, %edi, %esi
401 ; X86-NEXT: orl %ecx, %esi
402 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
403 ; X86-NEXT: shldl $1, %eax, %edi
404 ; X86-NEXT: orl %ecx, %edi
405 ; X86-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
406 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Reload
407 ; X86-NEXT: shldl $1, %edi, %eax
408 ; X86-NEXT: orl %ecx, %eax
409 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
410 ; X86-NEXT: addl %edi, %edi
411 ; X86-NEXT: orl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Folded Reload
412 ; X86-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
413 ; X86-NEXT: cmpl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Folded Reload
414 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
415 ; X86-NEXT: sbbl %ebx, %ecx
416 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
417 ; X86-NEXT: sbbl %edx, %ecx
418 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
419 ; X86-NEXT: sbbl (%esp), %ecx # 4-byte Folded Reload
420 ; X86-NEXT: sarl $31, %ecx
421 ; X86-NEXT: movl %ecx, %eax
422 ; X86-NEXT: andl $1, %eax
423 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
424 ; X86-NEXT: movl %ecx, %eax
425 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
426 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
427 ; X86-NEXT: movl %ecx, %edi
428 ; X86-NEXT: andl {{[0-9]+}}(%esp), %edi
429 ; X86-NEXT: movl %ecx, %eax
430 ; X86-NEXT: andl {{[0-9]+}}(%esp), %eax
431 ; X86-NEXT: andl {{[0-9]+}}(%esp), %ecx
432 ; X86-NEXT: subl %ecx, %ebp
433 ; X86-NEXT: movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
434 ; X86-NEXT: sbbl %eax, %ebx
435 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
436 ; X86-NEXT: sbbl %edi, %edx
437 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
438 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Reload
439 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
440 ; X86-NEXT: sbbl %eax, (%esp) # 4-byte Folded Spill
441 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
442 ; X86-NEXT: addl $-1, %ecx
443 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
444 ; X86-NEXT: adcl $-1, %eax
445 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edx # 4-byte Reload
446 ; X86-NEXT: adcl $-1, %edx
447 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Reload
448 ; X86-NEXT: adcl $-1, %ebx
449 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
450 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
451 ; X86-NEXT: orl %ebx, %eax
452 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Reload
453 ; X86-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
454 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
455 ; X86-NEXT: orl %edx, %ecx
456 ; X86-NEXT: movl (%esp), %ebp # 4-byte Reload
457 ; X86-NEXT: orl %eax, %ecx
458 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
459 ; X86-NEXT: jne .LBB4_4
461 ; X86-NEXT: movl %esi, (%esp) # 4-byte Spill
462 ; X86-NEXT: movl %edi, %esi
463 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx # 4-byte Reload
464 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebp # 4-byte Reload
465 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
466 ; X86-NEXT: .LBB4_7: # %udiv-loop-exit
467 ; X86-NEXT: movl (%esp), %edx # 4-byte Reload
468 ; X86-NEXT: shldl $1, %esi, %edx
469 ; X86-NEXT: orl %ecx, %edx
470 ; X86-NEXT: shldl $1, %ebx, %esi
471 ; X86-NEXT: orl %ecx, %esi
472 ; X86-NEXT: shldl $1, %ebp, %ebx
473 ; X86-NEXT: orl %ecx, %ebx
474 ; X86-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
475 ; X86-NEXT: addl %ebp, %ebp
476 ; X86-NEXT: orl %eax, %ebp
477 ; X86-NEXT: .LBB4_8: # %udiv-end
478 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
479 ; X86-NEXT: movl %ebp, (%eax)
480 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Reload
481 ; X86-NEXT: movl %ecx, 4(%eax)
482 ; X86-NEXT: movl %esi, 8(%eax)
483 ; X86-NEXT: movl %edx, 12(%eax)
484 ; X86-NEXT: movl %esi, %ebx
485 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
486 ; X86-NEXT: movl %eax, %esi
487 ; X86-NEXT: imull %ecx, %esi
488 ; X86-NEXT: movl %ebp, %ecx
489 ; X86-NEXT: movl %ebp, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
490 ; X86-NEXT: movl %edx, %ebp
491 ; X86-NEXT: mull %ecx
492 ; X86-NEXT: movl %eax, (%esp) # 4-byte Spill
493 ; X86-NEXT: addl %esi, %edx
494 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
495 ; X86-NEXT: imull %ecx, %edi
496 ; X86-NEXT: addl %edx, %edi
497 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
498 ; X86-NEXT: movl %esi, %eax
499 ; X86-NEXT: mull %ebx
500 ; X86-NEXT: movl %eax, %ecx
501 ; X86-NEXT: imull %esi, %ebp
502 ; X86-NEXT: addl %edx, %ebp
503 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
504 ; X86-NEXT: imull %eax, %ebx
505 ; X86-NEXT: addl %ebp, %ebx
506 ; X86-NEXT: addl (%esp), %ecx # 4-byte Folded Reload
507 ; X86-NEXT: movl %ecx, (%esp) # 4-byte Spill
508 ; X86-NEXT: adcl %edi, %ebx
509 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebp # 4-byte Reload
510 ; X86-NEXT: movl %ebp, %eax
511 ; X86-NEXT: mull %esi
512 ; X86-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
513 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
514 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
515 ; X86-NEXT: mull %esi
516 ; X86-NEXT: movl %edx, %edi
517 ; X86-NEXT: movl %eax, %ecx
518 ; X86-NEXT: addl {{[-0-9]+}}(%e{{[sb]}}p), %ecx # 4-byte Folded Reload
519 ; X86-NEXT: adcl $0, %edi
520 ; X86-NEXT: movl %ebp, %eax
521 ; X86-NEXT: mull {{[0-9]+}}(%esp)
522 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
523 ; X86-NEXT: movl %edx, %ebp
524 ; X86-NEXT: addl %ecx, %eax
525 ; X86-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) # 4-byte Spill
526 ; X86-NEXT: adcl %edi, %ebp
528 ; X86-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax # 4-byte Reload
529 ; X86-NEXT: mull {{[0-9]+}}(%esp)
530 ; X86-NEXT: addl %ebp, %eax
531 ; X86-NEXT: movzbl %cl, %ecx
532 ; X86-NEXT: adcl %ecx, %edx
533 ; X86-NEXT: addl (%esp), %eax # 4-byte Folded Reload
534 ; X86-NEXT: adcl %ebx, %edx
535 ; X86-NEXT: subl {{[-0-9]+}}(%e{{[sb]}}p), %esi # 4-byte Folded Reload
536 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
537 ; X86-NEXT: sbbl {{[-0-9]+}}(%e{{[sb]}}p), %edi # 4-byte Folded Reload
538 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
539 ; X86-NEXT: sbbl %eax, %ebx
540 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
541 ; X86-NEXT: sbbl %edx, %ecx
542 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
543 ; X86-NEXT: movl %esi, (%eax)
544 ; X86-NEXT: movl %edi, 4(%eax)
545 ; X86-NEXT: movl %ebx, 8(%eax)
546 ; X86-NEXT: movl %ecx, 12(%eax)
547 ; X86-NEXT: addl $136, %esp
548 ; X86-NEXT: popl %esi
549 ; X86-NEXT: popl %edi
550 ; X86-NEXT: popl %ebx
551 ; X86-NEXT: popl %ebp
554 ; X64-LABEL: scalar_i128:
556 ; X64-NEXT: pushq %r15
557 ; X64-NEXT: pushq %r14
558 ; X64-NEXT: pushq %r13
559 ; X64-NEXT: pushq %r12
560 ; X64-NEXT: pushq %rbx
561 ; X64-NEXT: movq %r8, %r15
562 ; X64-NEXT: movq %rcx, %r12
563 ; X64-NEXT: movq %rdx, %r13
564 ; X64-NEXT: movq %rsi, %rbx
565 ; X64-NEXT: movq %rdi, %r14
566 ; X64-NEXT: callq __udivti3@PLT
567 ; X64-NEXT: movq %rdx, %rcx
568 ; X64-NEXT: movq %rdx, 8(%r15)
569 ; X64-NEXT: movq %rax, (%r15)
570 ; X64-NEXT: imulq %rax, %r12
571 ; X64-NEXT: mulq %r13
572 ; X64-NEXT: addq %r12, %rdx
573 ; X64-NEXT: imulq %r13, %rcx
574 ; X64-NEXT: addq %rdx, %rcx
575 ; X64-NEXT: subq %rax, %r14
576 ; X64-NEXT: sbbq %rcx, %rbx
577 ; X64-NEXT: movq %r14, %rax
578 ; X64-NEXT: movq %rbx, %rdx
579 ; X64-NEXT: popq %rbx
580 ; X64-NEXT: popq %r12
581 ; X64-NEXT: popq %r13
582 ; X64-NEXT: popq %r14
583 ; X64-NEXT: popq %r15
585 %div = udiv i128 %x, %y
586 store i128 %div, ptr %divdst, align 4
587 %t1 = mul i128 %div, %y
588 %t2 = sub i128 %x, %t1
592 define <16 x i8> @vector_i128_i8(<16 x i8> %x, <16 x i8> %y, ptr %divdst) nounwind {
593 ; X86-LABEL: vector_i128_i8:
595 ; X86-NEXT: pushl %ebp
596 ; X86-NEXT: movl %esp, %ebp
597 ; X86-NEXT: pushl %ebx
598 ; X86-NEXT: pushl %edi
599 ; X86-NEXT: pushl %esi
600 ; X86-NEXT: andl $-16, %esp
601 ; X86-NEXT: subl $48, %esp
602 ; X86-NEXT: movdqa %xmm0, (%esp)
603 ; X86-NEXT: movdqa %xmm1, {{[0-9]+}}(%esp)
604 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
605 ; X86-NEXT: divb {{[0-9]+}}(%esp)
606 ; X86-NEXT: movzbl %al, %eax
607 ; X86-NEXT: movd %eax, %xmm2
608 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
609 ; X86-NEXT: divb {{[0-9]+}}(%esp)
610 ; X86-NEXT: movzbl %al, %eax
611 ; X86-NEXT: movd %eax, %xmm3
612 ; 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]
613 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
614 ; X86-NEXT: divb {{[0-9]+}}(%esp)
615 ; X86-NEXT: movzbl %al, %eax
616 ; X86-NEXT: movd %eax, %xmm4
617 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
618 ; X86-NEXT: divb {{[0-9]+}}(%esp)
619 ; X86-NEXT: movzbl %al, %eax
620 ; X86-NEXT: movd %eax, %xmm2
621 ; 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]
622 ; X86-NEXT: punpcklwd {{.*#+}} xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1],xmm2[2],xmm3[2],xmm2[3],xmm3[3]
623 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
624 ; X86-NEXT: divb {{[0-9]+}}(%esp)
625 ; X86-NEXT: movzbl %al, %eax
626 ; X86-NEXT: movd %eax, %xmm3
627 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
628 ; X86-NEXT: divb {{[0-9]+}}(%esp)
629 ; X86-NEXT: movzbl %al, %eax
630 ; X86-NEXT: movd %eax, %xmm4
631 ; 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]
632 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
633 ; X86-NEXT: divb {{[0-9]+}}(%esp)
634 ; X86-NEXT: movzbl %al, %eax
635 ; X86-NEXT: movd %eax, %xmm5
636 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
637 ; X86-NEXT: divb {{[0-9]+}}(%esp)
638 ; X86-NEXT: movzbl %al, %eax
639 ; X86-NEXT: movd %eax, %xmm3
640 ; 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]
641 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
642 ; X86-NEXT: divb {{[0-9]+}}(%esp)
643 ; X86-NEXT: movzbl %al, %eax
644 ; X86-NEXT: movd %eax, %xmm5
645 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
646 ; X86-NEXT: divb {{[0-9]+}}(%esp)
647 ; X86-NEXT: movzbl %al, %eax
648 ; X86-NEXT: movd %eax, %xmm6
649 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
650 ; X86-NEXT: divb {{[0-9]+}}(%esp)
651 ; X86-NEXT: movzbl %al, %edx
652 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
653 ; X86-NEXT: divb {{[0-9]+}}(%esp)
654 ; X86-NEXT: movzbl %al, %esi
655 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
656 ; X86-NEXT: divb {{[0-9]+}}(%esp)
657 ; X86-NEXT: movzbl %al, %edi
658 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
659 ; X86-NEXT: divb {{[0-9]+}}(%esp)
660 ; X86-NEXT: movzbl %al, %ebx
661 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
662 ; X86-NEXT: divb {{[0-9]+}}(%esp)
663 ; X86-NEXT: movl %eax, %ecx
664 ; X86-NEXT: movzbl (%esp), %eax
665 ; X86-NEXT: divb {{[0-9]+}}(%esp)
666 ; X86-NEXT: punpcklwd {{.*#+}} xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1],xmm3[2],xmm4[2],xmm3[3],xmm4[3]
667 ; X86-NEXT: movd %edx, %xmm7
668 ; X86-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
669 ; X86-NEXT: movd %esi, %xmm4
670 ; 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]
671 ; X86-NEXT: movd %edi, %xmm2
672 ; 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]
673 ; X86-NEXT: punpcklwd {{.*#+}} xmm4 = xmm4[0],xmm6[0],xmm4[1],xmm6[1],xmm4[2],xmm6[2],xmm4[3],xmm6[3]
674 ; X86-NEXT: movd %ebx, %xmm5
675 ; X86-NEXT: movzbl %cl, %ecx
676 ; X86-NEXT: movd %ecx, %xmm6
677 ; X86-NEXT: movl 8(%ebp), %ecx
678 ; 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]
679 ; X86-NEXT: movzbl %al, %eax
680 ; X86-NEXT: movd %eax, %xmm2
681 ; 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]
682 ; X86-NEXT: punpcklwd {{.*#+}} xmm2 = xmm2[0],xmm5[0],xmm2[1],xmm5[1],xmm2[2],xmm5[2],xmm2[3],xmm5[3]
683 ; X86-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
684 ; X86-NEXT: movdqa %xmm2, %xmm4
685 ; X86-NEXT: punpcklqdq {{.*#+}} xmm4 = xmm4[0],xmm3[0]
686 ; X86-NEXT: movdqa %xmm4, (%ecx)
687 ; X86-NEXT: punpcklbw {{.*#+}} xmm3 = xmm3[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
688 ; X86-NEXT: movdqa %xmm1, %xmm4
689 ; X86-NEXT: punpckhbw {{.*#+}} xmm4 = xmm4[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
690 ; X86-NEXT: pmullw %xmm3, %xmm4
691 ; X86-NEXT: movdqa {{.*#+}} xmm3 = [255,255,255,255,255,255,255,255]
692 ; X86-NEXT: pand %xmm3, %xmm4
693 ; X86-NEXT: punpcklbw {{.*#+}} xmm2 = xmm2[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
694 ; X86-NEXT: punpcklbw {{.*#+}} xmm1 = xmm1[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
695 ; X86-NEXT: pmullw %xmm2, %xmm1
696 ; X86-NEXT: pand %xmm3, %xmm1
697 ; X86-NEXT: packuswb %xmm4, %xmm1
698 ; X86-NEXT: psubb %xmm1, %xmm0
699 ; X86-NEXT: leal -12(%ebp), %esp
700 ; X86-NEXT: popl %esi
701 ; X86-NEXT: popl %edi
702 ; X86-NEXT: popl %ebx
703 ; X86-NEXT: popl %ebp
706 ; X64-LABEL: vector_i128_i8:
708 ; X64-NEXT: pushq %rbp
709 ; X64-NEXT: pushq %r15
710 ; X64-NEXT: pushq %r14
711 ; X64-NEXT: pushq %r13
712 ; X64-NEXT: pushq %r12
713 ; X64-NEXT: pushq %rbx
714 ; X64-NEXT: movq %rdi, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
715 ; X64-NEXT: movdqa %xmm0, -{{[0-9]+}}(%rsp)
716 ; X64-NEXT: movdqa %xmm1, -{{[0-9]+}}(%rsp)
717 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
718 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
719 ; X64-NEXT: movzbl %al, %eax
720 ; X64-NEXT: movd %eax, %xmm2
721 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
722 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
723 ; X64-NEXT: movzbl %al, %edi
724 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
725 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
726 ; X64-NEXT: movzbl %al, %esi
727 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
728 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
729 ; X64-NEXT: movzbl %al, %r8d
730 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
731 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
732 ; X64-NEXT: movzbl %al, %r9d
733 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
734 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
735 ; X64-NEXT: movzbl %al, %r10d
736 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
737 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
738 ; X64-NEXT: movzbl %al, %r11d
739 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
740 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
741 ; X64-NEXT: movzbl %al, %ebx
742 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
743 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
744 ; X64-NEXT: movzbl %al, %ebp
745 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
746 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
747 ; X64-NEXT: movzbl %al, %r14d
748 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
749 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
750 ; X64-NEXT: movzbl %al, %r15d
751 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
752 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
753 ; X64-NEXT: movzbl %al, %r12d
754 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
755 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
756 ; X64-NEXT: movzbl %al, %r13d
757 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
758 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
759 ; X64-NEXT: movzbl %al, %edx
760 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
761 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
762 ; X64-NEXT: movl %eax, %ecx
763 ; X64-NEXT: movzbl -{{[0-9]+}}(%rsp), %eax
764 ; X64-NEXT: divb -{{[0-9]+}}(%rsp)
765 ; X64-NEXT: movd %edi, %xmm3
766 ; X64-NEXT: movd %esi, %xmm4
767 ; X64-NEXT: movd %r8d, %xmm5
768 ; X64-NEXT: movd %r9d, %xmm6
769 ; 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]
770 ; X64-NEXT: movd %r10d, %xmm7
771 ; 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]
772 ; X64-NEXT: movd %r11d, %xmm4
773 ; X64-NEXT: punpcklwd {{.*#+}} xmm5 = xmm5[0],xmm3[0],xmm5[1],xmm3[1],xmm5[2],xmm3[2],xmm5[3],xmm3[3]
774 ; X64-NEXT: movd %ebx, %xmm2
775 ; 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]
776 ; X64-NEXT: movd %ebp, %xmm3
777 ; 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]
778 ; X64-NEXT: movd %r14d, %xmm4
779 ; X64-NEXT: punpcklwd {{.*#+}} xmm2 = xmm2[0],xmm7[0],xmm2[1],xmm7[1],xmm2[2],xmm7[2],xmm2[3],xmm7[3]
780 ; X64-NEXT: movd %r15d, %xmm6
781 ; X64-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm5[0],xmm2[1],xmm5[1]
782 ; X64-NEXT: movd %r12d, %xmm5
783 ; 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]
784 ; X64-NEXT: movd %r13d, %xmm3
785 ; 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]
786 ; X64-NEXT: movd %edx, %xmm6
787 ; X64-NEXT: punpcklwd {{.*#+}} xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1],xmm5[2],xmm4[2],xmm5[3],xmm4[3]
788 ; X64-NEXT: movzbl %cl, %ecx
789 ; X64-NEXT: movd %ecx, %xmm4
790 ; 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]
791 ; X64-NEXT: movzbl %al, %eax
792 ; X64-NEXT: movd %eax, %xmm3
793 ; 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]
794 ; X64-NEXT: punpcklwd {{.*#+}} xmm3 = xmm3[0],xmm6[0],xmm3[1],xmm6[1],xmm3[2],xmm6[2],xmm3[3],xmm6[3]
795 ; X64-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm5[0],xmm3[1],xmm5[1]
796 ; X64-NEXT: movdqa %xmm3, %xmm4
797 ; X64-NEXT: punpcklqdq {{.*#+}} xmm4 = xmm4[0],xmm2[0]
798 ; X64-NEXT: movq {{[-0-9]+}}(%r{{[sb]}}p), %rax # 8-byte Reload
799 ; X64-NEXT: movdqa %xmm4, (%rax)
800 ; X64-NEXT: punpcklbw {{.*#+}} xmm2 = xmm2[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
801 ; X64-NEXT: movdqa %xmm1, %xmm4
802 ; X64-NEXT: punpckhbw {{.*#+}} xmm4 = xmm4[8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15]
803 ; X64-NEXT: pmullw %xmm2, %xmm4
804 ; X64-NEXT: movdqa {{.*#+}} xmm2 = [255,255,255,255,255,255,255,255]
805 ; X64-NEXT: pand %xmm2, %xmm4
806 ; X64-NEXT: punpcklbw {{.*#+}} xmm3 = xmm3[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
807 ; X64-NEXT: punpcklbw {{.*#+}} xmm1 = xmm1[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7]
808 ; X64-NEXT: pmullw %xmm3, %xmm1
809 ; X64-NEXT: pand %xmm2, %xmm1
810 ; X64-NEXT: packuswb %xmm4, %xmm1
811 ; X64-NEXT: psubb %xmm1, %xmm0
812 ; X64-NEXT: popq %rbx
813 ; X64-NEXT: popq %r12
814 ; X64-NEXT: popq %r13
815 ; X64-NEXT: popq %r14
816 ; X64-NEXT: popq %r15
817 ; X64-NEXT: popq %rbp
819 %div = udiv <16 x i8> %x, %y
820 store <16 x i8> %div, ptr %divdst, align 16
821 %t1 = mul <16 x i8> %div, %y
822 %t2 = sub <16 x i8> %x, %t1
826 define <8 x i16> @vector_i128_i16(<8 x i16> %x, <8 x i16> %y, ptr %divdst) nounwind {
827 ; X86-LABEL: vector_i128_i16:
829 ; X86-NEXT: pushl %esi
830 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
831 ; X86-NEXT: pextrw $7, %xmm0, %eax
832 ; X86-NEXT: pextrw $7, %xmm1, %esi
833 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
834 ; X86-NEXT: xorl %edx, %edx
836 ; X86-NEXT: # kill: def $ax killed $ax def $eax
837 ; X86-NEXT: movd %eax, %xmm2
838 ; X86-NEXT: pextrw $6, %xmm0, %eax
839 ; X86-NEXT: pextrw $6, %xmm1, %esi
840 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
841 ; X86-NEXT: xorl %edx, %edx
843 ; X86-NEXT: # kill: def $ax killed $ax def $eax
844 ; X86-NEXT: movd %eax, %xmm3
845 ; X86-NEXT: punpcklwd {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1],xmm3[2],xmm2[2],xmm3[3],xmm2[3]
846 ; X86-NEXT: pextrw $5, %xmm0, %eax
847 ; X86-NEXT: pextrw $5, %xmm1, %esi
848 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
849 ; X86-NEXT: xorl %edx, %edx
851 ; X86-NEXT: # kill: def $ax killed $ax def $eax
852 ; X86-NEXT: movd %eax, %xmm4
853 ; X86-NEXT: pextrw $4, %xmm0, %eax
854 ; X86-NEXT: pextrw $4, %xmm1, %esi
855 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
856 ; X86-NEXT: xorl %edx, %edx
858 ; X86-NEXT: # kill: def $ax killed $ax def $eax
859 ; X86-NEXT: movd %eax, %xmm2
860 ; X86-NEXT: punpcklwd {{.*#+}} xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1],xmm2[2],xmm4[2],xmm2[3],xmm4[3]
861 ; X86-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
862 ; X86-NEXT: pextrw $3, %xmm0, %eax
863 ; X86-NEXT: pextrw $3, %xmm1, %esi
864 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
865 ; X86-NEXT: xorl %edx, %edx
867 ; X86-NEXT: # kill: def $ax killed $ax def $eax
868 ; X86-NEXT: movd %eax, %xmm4
869 ; X86-NEXT: pextrw $2, %xmm0, %eax
870 ; X86-NEXT: pextrw $2, %xmm1, %esi
871 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
872 ; X86-NEXT: xorl %edx, %edx
874 ; X86-NEXT: # kill: def $ax killed $ax def $eax
875 ; X86-NEXT: movd %eax, %xmm3
876 ; X86-NEXT: punpcklwd {{.*#+}} xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1],xmm3[2],xmm4[2],xmm3[3],xmm4[3]
877 ; X86-NEXT: pextrw $1, %xmm0, %eax
878 ; X86-NEXT: pextrw $1, %xmm1, %esi
879 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
880 ; X86-NEXT: xorl %edx, %edx
882 ; X86-NEXT: # kill: def $ax killed $ax def $eax
883 ; X86-NEXT: movd %eax, %xmm4
884 ; X86-NEXT: movd %xmm0, %eax
885 ; X86-NEXT: movd %xmm1, %esi
886 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
887 ; X86-NEXT: xorl %edx, %edx
889 ; X86-NEXT: # kill: def $ax killed $ax def $eax
890 ; X86-NEXT: movd %eax, %xmm5
891 ; X86-NEXT: punpcklwd {{.*#+}} xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1],xmm5[2],xmm4[2],xmm5[3],xmm4[3]
892 ; X86-NEXT: punpckldq {{.*#+}} xmm5 = xmm5[0],xmm3[0],xmm5[1],xmm3[1]
893 ; X86-NEXT: punpcklqdq {{.*#+}} xmm5 = xmm5[0],xmm2[0]
894 ; X86-NEXT: movdqa %xmm5, (%ecx)
895 ; X86-NEXT: pmullw %xmm1, %xmm5
896 ; X86-NEXT: psubw %xmm5, %xmm0
897 ; X86-NEXT: popl %esi
900 ; X64-LABEL: vector_i128_i16:
902 ; X64-NEXT: pextrw $7, %xmm0, %eax
903 ; X64-NEXT: pextrw $7, %xmm1, %ecx
904 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
905 ; X64-NEXT: xorl %edx, %edx
907 ; X64-NEXT: # kill: def $ax killed $ax def $eax
908 ; X64-NEXT: movd %eax, %xmm2
909 ; X64-NEXT: pextrw $6, %xmm0, %eax
910 ; X64-NEXT: pextrw $6, %xmm1, %ecx
911 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
912 ; X64-NEXT: xorl %edx, %edx
914 ; X64-NEXT: # kill: def $ax killed $ax def $eax
915 ; X64-NEXT: movd %eax, %xmm3
916 ; X64-NEXT: punpcklwd {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1],xmm3[2],xmm2[2],xmm3[3],xmm2[3]
917 ; X64-NEXT: pextrw $5, %xmm0, %eax
918 ; X64-NEXT: pextrw $5, %xmm1, %ecx
919 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
920 ; X64-NEXT: xorl %edx, %edx
922 ; X64-NEXT: # kill: def $ax killed $ax def $eax
923 ; X64-NEXT: movd %eax, %xmm4
924 ; X64-NEXT: pextrw $4, %xmm0, %eax
925 ; X64-NEXT: pextrw $4, %xmm1, %ecx
926 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
927 ; X64-NEXT: xorl %edx, %edx
929 ; X64-NEXT: # kill: def $ax killed $ax def $eax
930 ; X64-NEXT: movd %eax, %xmm2
931 ; X64-NEXT: punpcklwd {{.*#+}} xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1],xmm2[2],xmm4[2],xmm2[3],xmm4[3]
932 ; X64-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
933 ; X64-NEXT: pextrw $3, %xmm0, %eax
934 ; X64-NEXT: pextrw $3, %xmm1, %ecx
935 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
936 ; X64-NEXT: xorl %edx, %edx
938 ; X64-NEXT: # kill: def $ax killed $ax def $eax
939 ; X64-NEXT: movd %eax, %xmm3
940 ; X64-NEXT: pextrw $2, %xmm0, %eax
941 ; X64-NEXT: pextrw $2, %xmm1, %ecx
942 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
943 ; X64-NEXT: xorl %edx, %edx
945 ; X64-NEXT: # kill: def $ax killed $ax def $eax
946 ; X64-NEXT: movd %eax, %xmm4
947 ; X64-NEXT: punpcklwd {{.*#+}} xmm4 = xmm4[0],xmm3[0],xmm4[1],xmm3[1],xmm4[2],xmm3[2],xmm4[3],xmm3[3]
948 ; X64-NEXT: pextrw $1, %xmm0, %eax
949 ; X64-NEXT: pextrw $1, %xmm1, %ecx
950 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
951 ; X64-NEXT: xorl %edx, %edx
953 ; X64-NEXT: # kill: def $ax killed $ax def $eax
954 ; X64-NEXT: movd %eax, %xmm3
955 ; X64-NEXT: movd %xmm0, %eax
956 ; X64-NEXT: movd %xmm1, %ecx
957 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
958 ; X64-NEXT: xorl %edx, %edx
960 ; X64-NEXT: # kill: def $ax killed $ax def $eax
961 ; X64-NEXT: movd %eax, %xmm5
962 ; X64-NEXT: punpcklwd {{.*#+}} xmm5 = xmm5[0],xmm3[0],xmm5[1],xmm3[1],xmm5[2],xmm3[2],xmm5[3],xmm3[3]
963 ; X64-NEXT: punpckldq {{.*#+}} xmm5 = xmm5[0],xmm4[0],xmm5[1],xmm4[1]
964 ; X64-NEXT: punpcklqdq {{.*#+}} xmm5 = xmm5[0],xmm2[0]
965 ; X64-NEXT: movdqa %xmm5, (%rdi)
966 ; X64-NEXT: pmullw %xmm1, %xmm5
967 ; X64-NEXT: psubw %xmm5, %xmm0
969 %div = udiv <8 x i16> %x, %y
970 store <8 x i16> %div, ptr %divdst, align 16
971 %t1 = mul <8 x i16> %div, %y
972 %t2 = sub <8 x i16> %x, %t1
976 define <4 x i32> @vector_i128_i32(<4 x i32> %x, <4 x i32> %y, ptr %divdst) nounwind {
977 ; X86-LABEL: vector_i128_i32:
979 ; X86-NEXT: pushl %esi
980 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
981 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm0[3,3,3,3]
982 ; X86-NEXT: movd %xmm2, %eax
983 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm1[3,3,3,3]
984 ; X86-NEXT: movd %xmm2, %esi
985 ; X86-NEXT: xorl %edx, %edx
986 ; X86-NEXT: divl %esi
987 ; X86-NEXT: movd %eax, %xmm3
988 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm0[2,3,2,3]
989 ; X86-NEXT: movd %xmm2, %eax
990 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm1[2,3,2,3]
991 ; X86-NEXT: movd %xmm2, %esi
992 ; X86-NEXT: xorl %edx, %edx
993 ; X86-NEXT: divl %esi
994 ; X86-NEXT: movd %eax, %xmm2
995 ; X86-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
996 ; X86-NEXT: movd %xmm0, %eax
997 ; X86-NEXT: movd %xmm1, %esi
998 ; X86-NEXT: xorl %edx, %edx
999 ; X86-NEXT: divl %esi
1000 ; X86-NEXT: movd %eax, %xmm3
1001 ; X86-NEXT: pshufd {{.*#+}} xmm4 = xmm0[1,1,1,1]
1002 ; X86-NEXT: movd %xmm4, %eax
1003 ; X86-NEXT: pshufd {{.*#+}} xmm4 = xmm1[1,1,1,1]
1004 ; X86-NEXT: movd %xmm4, %esi
1005 ; X86-NEXT: xorl %edx, %edx
1006 ; X86-NEXT: divl %esi
1007 ; X86-NEXT: movd %eax, %xmm4
1008 ; X86-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm4[0],xmm3[1],xmm4[1]
1009 ; X86-NEXT: punpcklqdq {{.*#+}} xmm3 = xmm3[0],xmm2[0]
1010 ; X86-NEXT: movdqa %xmm3, (%ecx)
1011 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm3[1,1,3,3]
1012 ; X86-NEXT: pmuludq %xmm1, %xmm3
1013 ; X86-NEXT: pshufd {{.*#+}} xmm3 = xmm3[0,2,2,3]
1014 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
1015 ; X86-NEXT: pmuludq %xmm2, %xmm1
1016 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
1017 ; X86-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
1018 ; X86-NEXT: psubd %xmm3, %xmm0
1019 ; X86-NEXT: popl %esi
1022 ; X64-LABEL: vector_i128_i32:
1024 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm0[3,3,3,3]
1025 ; X64-NEXT: movd %xmm2, %eax
1026 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm1[3,3,3,3]
1027 ; X64-NEXT: movd %xmm2, %ecx
1028 ; X64-NEXT: xorl %edx, %edx
1029 ; X64-NEXT: divl %ecx
1030 ; X64-NEXT: movd %eax, %xmm2
1031 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm0[2,3,2,3]
1032 ; X64-NEXT: movd %xmm3, %eax
1033 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm1[2,3,2,3]
1034 ; X64-NEXT: movd %xmm3, %ecx
1035 ; X64-NEXT: xorl %edx, %edx
1036 ; X64-NEXT: divl %ecx
1037 ; X64-NEXT: movd %eax, %xmm3
1038 ; X64-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
1039 ; X64-NEXT: movd %xmm0, %eax
1040 ; X64-NEXT: movd %xmm1, %ecx
1041 ; X64-NEXT: xorl %edx, %edx
1042 ; X64-NEXT: divl %ecx
1043 ; X64-NEXT: movd %eax, %xmm2
1044 ; X64-NEXT: pshufd {{.*#+}} xmm4 = xmm0[1,1,1,1]
1045 ; X64-NEXT: movd %xmm4, %eax
1046 ; X64-NEXT: pshufd {{.*#+}} xmm4 = xmm1[1,1,1,1]
1047 ; X64-NEXT: movd %xmm4, %ecx
1048 ; X64-NEXT: xorl %edx, %edx
1049 ; X64-NEXT: divl %ecx
1050 ; X64-NEXT: movd %eax, %xmm4
1051 ; X64-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
1052 ; X64-NEXT: punpcklqdq {{.*#+}} xmm2 = xmm2[0],xmm3[0]
1053 ; X64-NEXT: movdqa %xmm2, (%rdi)
1054 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm2[1,1,3,3]
1055 ; X64-NEXT: pmuludq %xmm1, %xmm2
1056 ; X64-NEXT: pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3]
1057 ; X64-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
1058 ; X64-NEXT: pmuludq %xmm3, %xmm1
1059 ; X64-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
1060 ; X64-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]
1061 ; X64-NEXT: psubd %xmm2, %xmm0
1063 %div = udiv <4 x i32> %x, %y
1064 store <4 x i32> %div, ptr %divdst, align 16
1065 %t1 = mul <4 x i32> %div, %y
1066 %t2 = sub <4 x i32> %x, %t1
1070 define <2 x i64> @vector_i128_i64(<2 x i64> %x, <2 x i64> %y, ptr %divdst) nounwind {
1071 ; X86-LABEL: vector_i128_i64:
1073 ; X86-NEXT: pushl %esi
1074 ; X86-NEXT: subl $64, %esp
1075 ; X86-NEXT: movdqu %xmm1, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
1076 ; X86-NEXT: movdqu %xmm0, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
1077 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1078 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm1[3,3,3,3]
1079 ; X86-NEXT: movd %xmm2, {{[0-9]+}}(%esp)
1080 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm1[2,3,2,3]
1081 ; X86-NEXT: movd %xmm2, {{[0-9]+}}(%esp)
1082 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm0[3,3,3,3]
1083 ; X86-NEXT: movd %xmm1, {{[0-9]+}}(%esp)
1084 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm0[2,3,2,3]
1085 ; X86-NEXT: movd %xmm1, (%esp)
1086 ; X86-NEXT: calll __udivdi3
1087 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm1 # 16-byte Reload
1088 ; X86-NEXT: pshufd {{.*#+}} xmm0 = xmm1[1,1,1,1]
1089 ; X86-NEXT: movd %xmm0, {{[0-9]+}}(%esp)
1090 ; X86-NEXT: movd %xmm1, {{[0-9]+}}(%esp)
1091 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm1 # 16-byte Reload
1092 ; X86-NEXT: pshufd {{.*#+}} xmm0 = xmm1[1,1,1,1]
1093 ; X86-NEXT: movd %xmm0, {{[0-9]+}}(%esp)
1094 ; X86-NEXT: movd %xmm1, (%esp)
1095 ; X86-NEXT: movd %edx, %xmm0
1096 ; X86-NEXT: movd %eax, %xmm1
1097 ; X86-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
1098 ; X86-NEXT: movdqu %xmm1, {{[-0-9]+}}(%e{{[sb]}}p) # 16-byte Spill
1099 ; X86-NEXT: calll __udivdi3
1100 ; X86-NEXT: movd %edx, %xmm1
1101 ; X86-NEXT: movd %eax, %xmm3
1102 ; X86-NEXT: punpckldq {{.*#+}} xmm3 = xmm3[0],xmm1[0],xmm3[1],xmm1[1]
1103 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm0 # 16-byte Reload
1104 ; X86-NEXT: punpcklqdq {{.*#+}} xmm3 = xmm3[0],xmm0[0]
1105 ; X86-NEXT: movdqa %xmm3, (%esi)
1106 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm0 # 16-byte Reload
1107 ; X86-NEXT: movdqa %xmm0, %xmm1
1108 ; X86-NEXT: psrlq $32, %xmm1
1109 ; X86-NEXT: pmuludq %xmm3, %xmm1
1110 ; X86-NEXT: movdqa %xmm3, %xmm2
1111 ; X86-NEXT: psrlq $32, %xmm2
1112 ; X86-NEXT: pmuludq %xmm0, %xmm2
1113 ; X86-NEXT: paddq %xmm1, %xmm2
1114 ; X86-NEXT: psllq $32, %xmm2
1115 ; X86-NEXT: pmuludq %xmm0, %xmm3
1116 ; X86-NEXT: paddq %xmm2, %xmm3
1117 ; X86-NEXT: movdqu {{[-0-9]+}}(%e{{[sb]}}p), %xmm0 # 16-byte Reload
1118 ; X86-NEXT: psubq %xmm3, %xmm0
1119 ; X86-NEXT: addl $64, %esp
1120 ; X86-NEXT: popl %esi
1123 ; X64-LABEL: vector_i128_i64:
1125 ; X64-NEXT: movq %xmm0, %rax
1126 ; X64-NEXT: movq %xmm1, %rcx
1127 ; X64-NEXT: xorl %edx, %edx
1128 ; X64-NEXT: divq %rcx
1129 ; X64-NEXT: movq %rax, %xmm2
1130 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm0[2,3,2,3]
1131 ; X64-NEXT: movq %xmm3, %rax
1132 ; X64-NEXT: pshufd {{.*#+}} xmm3 = xmm1[2,3,2,3]
1133 ; X64-NEXT: movq %xmm3, %rcx
1134 ; X64-NEXT: xorl %edx, %edx
1135 ; X64-NEXT: divq %rcx
1136 ; X64-NEXT: movq %rax, %xmm3
1137 ; X64-NEXT: punpcklqdq {{.*#+}} xmm2 = xmm2[0],xmm3[0]
1138 ; X64-NEXT: movdqa %xmm2, (%rdi)
1139 ; X64-NEXT: movdqa %xmm1, %xmm3
1140 ; X64-NEXT: psrlq $32, %xmm3
1141 ; X64-NEXT: pmuludq %xmm2, %xmm3
1142 ; X64-NEXT: movdqa %xmm2, %xmm4
1143 ; X64-NEXT: psrlq $32, %xmm4
1144 ; X64-NEXT: pmuludq %xmm1, %xmm4
1145 ; X64-NEXT: paddq %xmm3, %xmm4
1146 ; X64-NEXT: psllq $32, %xmm4
1147 ; X64-NEXT: pmuludq %xmm1, %xmm2
1148 ; X64-NEXT: paddq %xmm4, %xmm2
1149 ; X64-NEXT: psubq %xmm2, %xmm0
1151 %div = udiv <2 x i64> %x, %y
1152 store <2 x i64> %div, ptr %divdst, align 16
1153 %t1 = mul <2 x i64> %div, %y
1154 %t2 = sub <2 x i64> %x, %t1
1160 define i32 @scalar_i32_commutative(i32 %x, ptr %ysrc, ptr %divdst) nounwind {
1161 ; X86-LABEL: scalar_i32_commutative:
1163 ; X86-NEXT: pushl %edi
1164 ; X86-NEXT: pushl %esi
1165 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1166 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1167 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1168 ; X86-NEXT: movl (%eax), %edi
1169 ; X86-NEXT: movl %ecx, %eax
1170 ; X86-NEXT: xorl %edx, %edx
1171 ; X86-NEXT: divl %edi
1172 ; X86-NEXT: movl %eax, (%esi)
1173 ; X86-NEXT: imull %eax, %edi
1174 ; X86-NEXT: subl %edi, %ecx
1175 ; X86-NEXT: movl %ecx, %eax
1176 ; X86-NEXT: popl %esi
1177 ; X86-NEXT: popl %edi
1180 ; X64-LABEL: scalar_i32_commutative:
1182 ; X64-NEXT: movq %rdx, %rcx
1183 ; X64-NEXT: movl (%rsi), %esi
1184 ; X64-NEXT: movl %edi, %eax
1185 ; X64-NEXT: xorl %edx, %edx
1186 ; X64-NEXT: divl %esi
1187 ; X64-NEXT: movl %eax, (%rcx)
1188 ; X64-NEXT: imull %eax, %esi
1189 ; X64-NEXT: subl %esi, %edi
1190 ; X64-NEXT: movl %edi, %eax
1192 %y = load i32, ptr %ysrc, align 4
1193 %div = udiv i32 %x, %y
1194 store i32 %div, ptr %divdst, align 4
1195 %t1 = mul i32 %y, %div ; commutative
1196 %t2 = sub i32 %x, %t1
1200 ; We do not care about extra uses.
1201 define i32 @extrause(i32 %x, i32 %y, ptr %divdst, ptr %t1dst) nounwind {
1202 ; X86-LABEL: extrause:
1204 ; X86-NEXT: pushl %ebx
1205 ; X86-NEXT: pushl %edi
1206 ; X86-NEXT: pushl %esi
1207 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1208 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
1209 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1210 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ebx
1211 ; X86-NEXT: movl %ecx, %eax
1212 ; X86-NEXT: xorl %edx, %edx
1213 ; X86-NEXT: divl %ebx
1214 ; X86-NEXT: movl %eax, (%edi)
1215 ; X86-NEXT: imull %ebx, %eax
1216 ; X86-NEXT: movl %eax, (%esi)
1217 ; X86-NEXT: subl %eax, %ecx
1218 ; X86-NEXT: movl %ecx, %eax
1219 ; X86-NEXT: popl %esi
1220 ; X86-NEXT: popl %edi
1221 ; X86-NEXT: popl %ebx
1224 ; X64-LABEL: extrause:
1226 ; X64-NEXT: movq %rdx, %r8
1227 ; X64-NEXT: movl %edi, %eax
1228 ; X64-NEXT: xorl %edx, %edx
1229 ; X64-NEXT: divl %esi
1230 ; X64-NEXT: movl %eax, (%r8)
1231 ; X64-NEXT: imull %esi, %eax
1232 ; X64-NEXT: movl %eax, (%rcx)
1233 ; X64-NEXT: subl %eax, %edi
1234 ; X64-NEXT: movl %edi, %eax
1236 %div = udiv i32 %x, %y
1237 store i32 %div, ptr %divdst, align 4
1238 %t1 = mul i32 %div, %y
1239 store i32 %t1, ptr %t1dst, align 4
1240 %t2 = sub i32 %x, %t1
1244 ; 'rem' should appear next to 'div'.
1245 define i32 @multiple_bb(i32 %x, i32 %y, ptr %divdst, i1 zeroext %store_urem, ptr %uremdst) nounwind {
1246 ; X86-LABEL: multiple_bb:
1248 ; X86-NEXT: pushl %ebx
1249 ; X86-NEXT: pushl %edi
1250 ; X86-NEXT: pushl %esi
1251 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1252 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1253 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ebx
1254 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
1255 ; X86-NEXT: movl %ecx, %eax
1256 ; X86-NEXT: xorl %edx, %edx
1257 ; X86-NEXT: divl %esi
1258 ; X86-NEXT: movl %eax, (%edi)
1259 ; X86-NEXT: testb %bl, %bl
1260 ; X86-NEXT: je .LBB11_2
1261 ; X86-NEXT: # %bb.1: # %do_urem
1262 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
1263 ; X86-NEXT: movl %eax, %edi
1264 ; X86-NEXT: imull %esi, %edi
1265 ; X86-NEXT: subl %edi, %ecx
1266 ; X86-NEXT: movl %ecx, (%edx)
1267 ; X86-NEXT: .LBB11_2: # %end
1268 ; X86-NEXT: popl %esi
1269 ; X86-NEXT: popl %edi
1270 ; X86-NEXT: popl %ebx
1273 ; X64-LABEL: multiple_bb:
1275 ; X64-NEXT: movq %rdx, %r9
1276 ; X64-NEXT: movl %edi, %eax
1277 ; X64-NEXT: xorl %edx, %edx
1278 ; X64-NEXT: divl %esi
1279 ; X64-NEXT: movl %eax, (%r9)
1280 ; X64-NEXT: testl %ecx, %ecx
1281 ; X64-NEXT: je .LBB11_2
1282 ; X64-NEXT: # %bb.1: # %do_urem
1283 ; X64-NEXT: movl %eax, %ecx
1284 ; X64-NEXT: imull %esi, %ecx
1285 ; X64-NEXT: subl %ecx, %edi
1286 ; X64-NEXT: movl %edi, (%r8)
1287 ; X64-NEXT: .LBB11_2: # %end
1289 %div = udiv i32 %x, %y
1290 store i32 %div, ptr %divdst, align 4
1291 br i1 %store_urem, label %do_urem, label %end
1293 %t1 = mul i32 %div, %y
1294 %t2 = sub i32 %x, %t1
1295 store i32 %t2, ptr %uremdst, align 4
1301 define i32 @negative_different_x(i32 %x0, i32 %x1, i32 %y, ptr %divdst) nounwind {
1302 ; X86-LABEL: negative_different_x:
1304 ; X86-NEXT: pushl %edi
1305 ; X86-NEXT: pushl %esi
1306 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1307 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1308 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1309 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
1310 ; X86-NEXT: xorl %edx, %edx
1311 ; X86-NEXT: divl %edi
1312 ; X86-NEXT: movl %eax, (%esi)
1313 ; X86-NEXT: imull %edi, %eax
1314 ; X86-NEXT: subl %eax, %ecx
1315 ; X86-NEXT: movl %ecx, %eax
1316 ; X86-NEXT: popl %esi
1317 ; X86-NEXT: popl %edi
1320 ; X64-LABEL: negative_different_x:
1322 ; X64-NEXT: movl %edx, %r8d
1323 ; X64-NEXT: movl %edi, %eax
1324 ; X64-NEXT: xorl %edx, %edx
1325 ; X64-NEXT: divl %r8d
1326 ; X64-NEXT: movl %eax, (%rcx)
1327 ; X64-NEXT: imull %r8d, %eax
1328 ; X64-NEXT: subl %eax, %esi
1329 ; X64-NEXT: movl %esi, %eax
1331 %div = udiv i32 %x0, %y ; not %x1
1332 store i32 %div, ptr %divdst, align 4
1333 %t1 = mul i32 %div, %y
1334 %t2 = sub i32 %x1, %t1 ; not %x0
1338 define i32 @negative_different_y(i32 %x0, i32 %x1, i32 %y, i32 %z, ptr %divdst) nounwind {
1339 ; X86-LABEL: negative_different_y:
1341 ; X86-NEXT: pushl %esi
1342 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1343 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1344 ; X86-NEXT: movl %ecx, %eax
1345 ; X86-NEXT: xorl %edx, %edx
1346 ; X86-NEXT: divl {{[0-9]+}}(%esp)
1347 ; X86-NEXT: movl %eax, (%esi)
1348 ; X86-NEXT: imull {{[0-9]+}}(%esp), %eax
1349 ; X86-NEXT: subl %eax, %ecx
1350 ; X86-NEXT: movl %ecx, %eax
1351 ; X86-NEXT: popl %esi
1354 ; X64-LABEL: negative_different_y:
1356 ; X64-NEXT: movl %edx, %edi
1357 ; X64-NEXT: movl %esi, %eax
1358 ; X64-NEXT: xorl %edx, %edx
1359 ; X64-NEXT: divl %ecx
1360 ; X64-NEXT: movl %eax, (%r8)
1361 ; X64-NEXT: imull %eax, %edi
1362 ; X64-NEXT: subl %edi, %esi
1363 ; X64-NEXT: movl %esi, %eax
1365 %div = udiv i32 %x1, %z ; not %x0
1366 store i32 %div, ptr %divdst, align 4
1367 %t1 = mul i32 %div, %y
1368 %t2 = sub i32 %x1, %t1
1372 define i32 @negative_inverted_division(i32 %x0, i32 %x1, i32 %y, ptr %divdst) nounwind {
1373 ; X86-LABEL: negative_inverted_division:
1375 ; X86-NEXT: pushl %esi
1376 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
1377 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
1378 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
1379 ; X86-NEXT: xorl %edx, %edx
1380 ; X86-NEXT: divl %ecx
1381 ; X86-NEXT: movl %eax, (%esi)
1382 ; X86-NEXT: imull %ecx, %eax
1383 ; X86-NEXT: subl %eax, %ecx
1384 ; X86-NEXT: movl %ecx, %eax
1385 ; X86-NEXT: popl %esi
1388 ; X64-LABEL: negative_inverted_division:
1390 ; X64-NEXT: movl %edi, %eax
1391 ; X64-NEXT: xorl %edx, %edx
1392 ; X64-NEXT: divl %esi
1393 ; X64-NEXT: movl %eax, (%rcx)
1394 ; X64-NEXT: imull %esi, %eax
1395 ; X64-NEXT: subl %eax, %esi
1396 ; X64-NEXT: movl %esi, %eax
1398 %div = udiv i32 %x0, %x1 ; inverted division
1399 store i32 %div, ptr %divdst, align 4
1400 %t1 = mul i32 %div, %x1
1401 %t2 = sub i32 %x1, %t1