• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=X64
3; RUN: llc < %s -mtriple=i686 -mattr=cmov | FileCheck %s --check-prefix=X86
4
5declare  i4  @llvm.udiv.fix.i4   (i4,  i4,  i32)
6declare  i15 @llvm.udiv.fix.i15  (i15, i15, i32)
7declare  i16 @llvm.udiv.fix.i16  (i16, i16, i32)
8declare  i18 @llvm.udiv.fix.i18  (i18, i18, i32)
9declare  i64 @llvm.udiv.fix.i64  (i64, i64, i32)
10declare  <4 x i32> @llvm.udiv.fix.v4i32(<4 x i32>, <4 x i32>, i32)
11
12define i16 @func(i16 %x, i16 %y) nounwind {
13; X64-LABEL: func:
14; X64:       # %bb.0:
15; X64-NEXT:    movzwl %si, %ecx
16; X64-NEXT:    movzwl %di, %eax
17; X64-NEXT:    shll $7, %eax
18; X64-NEXT:    xorl %edx, %edx
19; X64-NEXT:    divl %ecx
20; X64-NEXT:    # kill: def $ax killed $ax killed $eax
21; X64-NEXT:    retq
22;
23; X86-LABEL: func:
24; X86:       # %bb.0:
25; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %ecx
26; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
27; X86-NEXT:    shll $7, %eax
28; X86-NEXT:    xorl %edx, %edx
29; X86-NEXT:    divl %ecx
30; X86-NEXT:    # kill: def $ax killed $ax killed $eax
31; X86-NEXT:    retl
32  %tmp = call i16 @llvm.udiv.fix.i16(i16 %x, i16 %y, i32 7)
33  ret i16 %tmp
34}
35
36define i16 @func2(i8 %x, i8 %y) nounwind {
37; X64-LABEL: func2:
38; X64:       # %bb.0:
39; X64-NEXT:    movsbl %dil, %eax
40; X64-NEXT:    andl $32767, %eax # imm = 0x7FFF
41; X64-NEXT:    movsbl %sil, %ecx
42; X64-NEXT:    andl $32767, %ecx # imm = 0x7FFF
43; X64-NEXT:    shll $14, %eax
44; X64-NEXT:    xorl %edx, %edx
45; X64-NEXT:    divl %ecx
46; X64-NEXT:    addl %eax, %eax
47; X64-NEXT:    cwtl
48; X64-NEXT:    shrl %eax
49; X64-NEXT:    # kill: def $ax killed $ax killed $eax
50; X64-NEXT:    retq
51;
52; X86-LABEL: func2:
53; X86:       # %bb.0:
54; X86-NEXT:    movsbl {{[0-9]+}}(%esp), %ecx
55; X86-NEXT:    andl $32767, %ecx # imm = 0x7FFF
56; X86-NEXT:    movsbl {{[0-9]+}}(%esp), %eax
57; X86-NEXT:    andl $32767, %eax # imm = 0x7FFF
58; X86-NEXT:    shll $14, %eax
59; X86-NEXT:    xorl %edx, %edx
60; X86-NEXT:    divl %ecx
61; X86-NEXT:    addl %eax, %eax
62; X86-NEXT:    cwtl
63; X86-NEXT:    shrl %eax
64; X86-NEXT:    # kill: def $ax killed $ax killed $eax
65; X86-NEXT:    retl
66  %x2 = sext i8 %x to i15
67  %y2 = sext i8 %y to i15
68  %tmp = call i15 @llvm.udiv.fix.i15(i15 %x2, i15 %y2, i32 14)
69  %tmp2 = sext i15 %tmp to i16
70  ret i16 %tmp2
71}
72
73define i16 @func3(i15 %x, i8 %y) nounwind {
74; X64-LABEL: func3:
75; X64:       # %bb.0:
76; X64-NEXT:    # kill: def $edi killed $edi def $rdi
77; X64-NEXT:    leal (%rdi,%rdi), %eax
78; X64-NEXT:    movzbl %sil, %ecx
79; X64-NEXT:    shll $4, %ecx
80; X64-NEXT:    # kill: def $ax killed $ax killed $eax
81; X64-NEXT:    xorl %edx, %edx
82; X64-NEXT:    divw %cx
83; X64-NEXT:    # kill: def $ax killed $ax def $eax
84; X64-NEXT:    addl %eax, %eax
85; X64-NEXT:    cwtl
86; X64-NEXT:    shrl %eax
87; X64-NEXT:    # kill: def $ax killed $ax killed $eax
88; X64-NEXT:    retq
89;
90; X86-LABEL: func3:
91; X86:       # %bb.0:
92; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
93; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
94; X86-NEXT:    addl %eax, %eax
95; X86-NEXT:    movzbl %cl, %ecx
96; X86-NEXT:    shll $4, %ecx
97; X86-NEXT:    # kill: def $ax killed $ax killed $eax
98; X86-NEXT:    xorl %edx, %edx
99; X86-NEXT:    divw %cx
100; X86-NEXT:    # kill: def $ax killed $ax def $eax
101; X86-NEXT:    addl %eax, %eax
102; X86-NEXT:    cwtl
103; X86-NEXT:    shrl %eax
104; X86-NEXT:    # kill: def $ax killed $ax killed $eax
105; X86-NEXT:    retl
106  %y2 = sext i8 %y to i15
107  %y3 = shl i15 %y2, 7
108  %tmp = call i15 @llvm.udiv.fix.i15(i15 %x, i15 %y3, i32 4)
109  %tmp2 = sext i15 %tmp to i16
110  ret i16 %tmp2
111}
112
113define i4 @func4(i4 %x, i4 %y) nounwind {
114; X64-LABEL: func4:
115; X64:       # %bb.0:
116; X64-NEXT:    andb $15, %sil
117; X64-NEXT:    andb $15, %dil
118; X64-NEXT:    shlb $2, %dil
119; X64-NEXT:    movzbl %dil, %eax
120; X64-NEXT:    divb %sil
121; X64-NEXT:    retq
122;
123; X86-LABEL: func4:
124; X86:       # %bb.0:
125; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
126; X86-NEXT:    andb $15, %cl
127; X86-NEXT:    movb {{[0-9]+}}(%esp), %al
128; X86-NEXT:    andb $15, %al
129; X86-NEXT:    shlb $2, %al
130; X86-NEXT:    movzbl %al, %eax
131; X86-NEXT:    divb %cl
132; X86-NEXT:    retl
133  %tmp = call i4 @llvm.udiv.fix.i4(i4 %x, i4 %y, i32 2)
134  ret i4 %tmp
135}
136
137define i64 @func5(i64 %x, i64 %y) nounwind {
138; X64-LABEL: func5:
139; X64:       # %bb.0:
140; X64-NEXT:    pushq %rax
141; X64-NEXT:    movq %rsi, %rdx
142; X64-NEXT:    movq %rdi, %rsi
143; X64-NEXT:    shlq $31, %rdi
144; X64-NEXT:    shrq $33, %rsi
145; X64-NEXT:    xorl %ecx, %ecx
146; X64-NEXT:    callq __udivti3
147; X64-NEXT:    popq %rcx
148; X64-NEXT:    retq
149;
150; X86-LABEL: func5:
151; X86:       # %bb.0:
152; X86-NEXT:    pushl %ebp
153; X86-NEXT:    movl %esp, %ebp
154; X86-NEXT:    pushl %esi
155; X86-NEXT:    andl $-8, %esp
156; X86-NEXT:    subl $24, %esp
157; X86-NEXT:    movl 8(%ebp), %eax
158; X86-NEXT:    movl 12(%ebp), %ecx
159; X86-NEXT:    movl %ecx, %edx
160; X86-NEXT:    shrl %edx
161; X86-NEXT:    shldl $31, %eax, %ecx
162; X86-NEXT:    shll $31, %eax
163; X86-NEXT:    movl %esp, %esi
164; X86-NEXT:    pushl $0
165; X86-NEXT:    pushl $0
166; X86-NEXT:    pushl 20(%ebp)
167; X86-NEXT:    pushl 16(%ebp)
168; X86-NEXT:    pushl $0
169; X86-NEXT:    pushl %edx
170; X86-NEXT:    pushl %ecx
171; X86-NEXT:    pushl %eax
172; X86-NEXT:    pushl %esi
173; X86-NEXT:    calll __udivti3
174; X86-NEXT:    addl $32, %esp
175; X86-NEXT:    movl (%esp), %eax
176; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
177; X86-NEXT:    leal -4(%ebp), %esp
178; X86-NEXT:    popl %esi
179; X86-NEXT:    popl %ebp
180; X86-NEXT:    retl
181  %tmp = call i64 @llvm.udiv.fix.i64(i64 %x, i64 %y, i32 31)
182  ret i64 %tmp
183}
184
185define i18 @func6(i16 %x, i16 %y) nounwind {
186; X64-LABEL: func6:
187; X64:       # %bb.0:
188; X64-NEXT:    movswl %di, %eax
189; X64-NEXT:    andl $262143, %eax # imm = 0x3FFFF
190; X64-NEXT:    movswl %si, %ecx
191; X64-NEXT:    andl $262143, %ecx # imm = 0x3FFFF
192; X64-NEXT:    shll $7, %eax
193; X64-NEXT:    xorl %edx, %edx
194; X64-NEXT:    divl %ecx
195; X64-NEXT:    retq
196;
197; X86-LABEL: func6:
198; X86:       # %bb.0:
199; X86-NEXT:    movswl {{[0-9]+}}(%esp), %ecx
200; X86-NEXT:    andl $262143, %ecx # imm = 0x3FFFF
201; X86-NEXT:    movswl {{[0-9]+}}(%esp), %eax
202; X86-NEXT:    andl $262143, %eax # imm = 0x3FFFF
203; X86-NEXT:    shll $7, %eax
204; X86-NEXT:    xorl %edx, %edx
205; X86-NEXT:    divl %ecx
206; X86-NEXT:    retl
207  %x2 = sext i16 %x to i18
208  %y2 = sext i16 %y to i18
209  %tmp = call i18 @llvm.udiv.fix.i18(i18 %x2, i18 %y2, i32 7)
210  ret i18 %tmp
211}
212
213define i16 @func7(i16 %x, i16 %y) nounwind {
214; X64-LABEL: func7:
215; X64:       # %bb.0:
216; X64-NEXT:    movl %edi, %eax
217; X64-NEXT:    shll $16, %eax
218; X64-NEXT:    movzwl %si, %ecx
219; X64-NEXT:    xorl %edx, %edx
220; X64-NEXT:    divl %ecx
221; X64-NEXT:    # kill: def $ax killed $ax killed $eax
222; X64-NEXT:    retq
223;
224; X86-LABEL: func7:
225; X86:       # %bb.0:
226; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %ecx
227; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
228; X86-NEXT:    shll $16, %eax
229; X86-NEXT:    xorl %edx, %edx
230; X86-NEXT:    divl %ecx
231; X86-NEXT:    # kill: def $ax killed $ax killed $eax
232; X86-NEXT:    retl
233  %tmp = call i16 @llvm.udiv.fix.i16(i16 %x, i16 %y, i32 16)
234  ret i16 %tmp
235}
236
237define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
238; X64-LABEL: vec:
239; X64:       # %bb.0:
240; X64-NEXT:    pxor %xmm2, %xmm2
241; X64-NEXT:    movdqa %xmm1, %xmm3
242; X64-NEXT:    punpckhdq {{.*#+}} xmm3 = xmm3[2],xmm2[2],xmm3[3],xmm2[3]
243; X64-NEXT:    movq %xmm3, %rcx
244; X64-NEXT:    movdqa %xmm0, %xmm4
245; X64-NEXT:    punpckhdq {{.*#+}} xmm4 = xmm4[2],xmm2[2],xmm4[3],xmm2[3]
246; X64-NEXT:    psllq $31, %xmm4
247; X64-NEXT:    movq %xmm4, %rax
248; X64-NEXT:    xorl %edx, %edx
249; X64-NEXT:    divq %rcx
250; X64-NEXT:    movq %rax, %xmm3
251; X64-NEXT:    pshufd {{.*#+}} xmm4 = xmm4[2,3,2,3]
252; X64-NEXT:    movq %xmm4, %rax
253; X64-NEXT:    movdqa %xmm1, %xmm4
254; X64-NEXT:    psrldq {{.*#+}} xmm4 = xmm4[12,13,14,15],zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero
255; X64-NEXT:    movq %xmm4, %rcx
256; X64-NEXT:    xorl %edx, %edx
257; X64-NEXT:    divq %rcx
258; X64-NEXT:    movq %rax, %xmm4
259; X64-NEXT:    punpcklqdq {{.*#+}} xmm3 = xmm3[0],xmm4[0]
260; X64-NEXT:    punpckldq {{.*#+}} xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
261; X64-NEXT:    movss {{.*#+}} xmm2 = xmm1[0],xmm2[1,2,3]
262; X64-NEXT:    movq %xmm2, %rcx
263; X64-NEXT:    psllq $31, %xmm0
264; X64-NEXT:    movq %xmm0, %rax
265; X64-NEXT:    xorl %edx, %edx
266; X64-NEXT:    divq %rcx
267; X64-NEXT:    movq %rax, %xmm2
268; X64-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[2,3,2,3]
269; X64-NEXT:    movq %xmm0, %rax
270; X64-NEXT:    psrlq $32, %xmm1
271; X64-NEXT:    movq %xmm1, %rcx
272; X64-NEXT:    xorl %edx, %edx
273; X64-NEXT:    divq %rcx
274; X64-NEXT:    movq %rax, %xmm0
275; X64-NEXT:    punpcklqdq {{.*#+}} xmm2 = xmm2[0],xmm0[0]
276; X64-NEXT:    shufps {{.*#+}} xmm2 = xmm2[0,2],xmm3[0,2]
277; X64-NEXT:    movaps %xmm2, %xmm0
278; X64-NEXT:    retq
279;
280; X86-LABEL: vec:
281; X86:       # %bb.0:
282; X86-NEXT:    pushl %ebp
283; X86-NEXT:    pushl %ebx
284; X86-NEXT:    pushl %edi
285; X86-NEXT:    pushl %esi
286; X86-NEXT:    pushl %eax
287; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
288; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
289; X86-NEXT:    movl {{[0-9]+}}(%esp), %ebp
290; X86-NEXT:    movl {{[0-9]+}}(%esp), %ebx
291; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
292; X86-NEXT:    movl %eax, %ecx
293; X86-NEXT:    shrl %ecx
294; X86-NEXT:    shll $31, %eax
295; X86-NEXT:    pushl $0
296; X86-NEXT:    pushl {{[0-9]+}}(%esp)
297; X86-NEXT:    pushl %ecx
298; X86-NEXT:    pushl %eax
299; X86-NEXT:    calll __udivdi3
300; X86-NEXT:    addl $16, %esp
301; X86-NEXT:    movl %eax, (%esp) # 4-byte Spill
302; X86-NEXT:    movl %ebx, %eax
303; X86-NEXT:    shrl %eax
304; X86-NEXT:    shll $31, %ebx
305; X86-NEXT:    pushl $0
306; X86-NEXT:    pushl {{[0-9]+}}(%esp)
307; X86-NEXT:    pushl %eax
308; X86-NEXT:    pushl %ebx
309; X86-NEXT:    calll __udivdi3
310; X86-NEXT:    addl $16, %esp
311; X86-NEXT:    movl %eax, %ebx
312; X86-NEXT:    movl %ebp, %eax
313; X86-NEXT:    shrl %eax
314; X86-NEXT:    shll $31, %ebp
315; X86-NEXT:    pushl $0
316; X86-NEXT:    pushl {{[0-9]+}}(%esp)
317; X86-NEXT:    pushl %eax
318; X86-NEXT:    pushl %ebp
319; X86-NEXT:    calll __udivdi3
320; X86-NEXT:    addl $16, %esp
321; X86-NEXT:    movl %eax, %ebp
322; X86-NEXT:    movl %edi, %eax
323; X86-NEXT:    shrl %eax
324; X86-NEXT:    shll $31, %edi
325; X86-NEXT:    pushl $0
326; X86-NEXT:    pushl {{[0-9]+}}(%esp)
327; X86-NEXT:    pushl %eax
328; X86-NEXT:    pushl %edi
329; X86-NEXT:    calll __udivdi3
330; X86-NEXT:    addl $16, %esp
331; X86-NEXT:    movl %eax, 12(%esi)
332; X86-NEXT:    movl %ebp, 8(%esi)
333; X86-NEXT:    movl %ebx, 4(%esi)
334; X86-NEXT:    movl (%esp), %eax # 4-byte Reload
335; X86-NEXT:    movl %eax, (%esi)
336; X86-NEXT:    movl %esi, %eax
337; X86-NEXT:    addl $4, %esp
338; X86-NEXT:    popl %esi
339; X86-NEXT:    popl %edi
340; X86-NEXT:    popl %ebx
341; X86-NEXT:    popl %ebp
342; X86-NEXT:    retl $4
343  %tmp = call <4 x i32> @llvm.udiv.fix.v4i32(<4 x i32> %x, <4 x i32> %y, i32 31)
344  ret <4 x i32> %tmp
345}
346