• 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.smul.fix.sat.i4   (i4,  i4, i32)
6declare  i32 @llvm.smul.fix.sat.i32  (i32, i32, i32)
7declare  i64 @llvm.smul.fix.sat.i64  (i64, i64, i32)
8declare  <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32>, <4 x i32>, i32)
9
10define i32 @func(i32 %x, i32 %y) nounwind {
11; X64-LABEL: func:
12; X64:       # %bb.0:
13; X64-NEXT:    movslq %esi, %rax
14; X64-NEXT:    movslq %edi, %rcx
15; X64-NEXT:    imulq %rax, %rcx
16; X64-NEXT:    movq %rcx, %rax
17; X64-NEXT:    shrq $32, %rax
18; X64-NEXT:    shrdl $2, %eax, %ecx
19; X64-NEXT:    cmpl $1, %eax
20; X64-NEXT:    movl $2147483647, %edx # imm = 0x7FFFFFFF
21; X64-NEXT:    cmovlel %ecx, %edx
22; X64-NEXT:    cmpl $-2, %eax
23; X64-NEXT:    movl $-2147483648, %eax # imm = 0x80000000
24; X64-NEXT:    cmovgel %edx, %eax
25; X64-NEXT:    retq
26;
27; X86-LABEL: func:
28; X86:       # %bb.0:
29; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
30; X86-NEXT:    imull {{[0-9]+}}(%esp)
31; X86-NEXT:    shrdl $2, %edx, %eax
32; X86-NEXT:    cmpl $1, %edx
33; X86-NEXT:    movl $2147483647, %ecx # imm = 0x7FFFFFFF
34; X86-NEXT:    cmovgl %ecx, %eax
35; X86-NEXT:    cmpl $-2, %edx
36; X86-NEXT:    movl $-2147483648, %ecx # imm = 0x80000000
37; X86-NEXT:    cmovll %ecx, %eax
38; X86-NEXT:    retl
39  %tmp = call i32 @llvm.smul.fix.sat.i32(i32 %x, i32 %y, i32 2)
40  ret i32 %tmp
41}
42
43define i64 @func2(i64 %x, i64 %y) nounwind {
44; X64-LABEL: func2:
45; X64:       # %bb.0:
46; X64-NEXT:    movq %rdi, %rax
47; X64-NEXT:    imulq %rsi
48; X64-NEXT:    shrdq $2, %rdx, %rax
49; X64-NEXT:    cmpq $1, %rdx
50; X64-NEXT:    movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
51; X64-NEXT:    cmovgq %rcx, %rax
52; X64-NEXT:    cmpq $-2, %rdx
53; X64-NEXT:    movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
54; X64-NEXT:    cmovlq %rcx, %rax
55; X64-NEXT:    retq
56;
57; X86-LABEL: func2:
58; X86:       # %bb.0:
59; X86-NEXT:    pushl %ebp
60; X86-NEXT:    pushl %ebx
61; X86-NEXT:    pushl %edi
62; X86-NEXT:    pushl %esi
63; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
64; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
65; X86-NEXT:    movl %ecx, %eax
66; X86-NEXT:    mull %esi
67; X86-NEXT:    movl %edx, %edi
68; X86-NEXT:    movl %eax, %ebx
69; X86-NEXT:    movl %ecx, %eax
70; X86-NEXT:    mull {{[0-9]+}}(%esp)
71; X86-NEXT:    movl %eax, %ecx
72; X86-NEXT:    movl %edx, %ebp
73; X86-NEXT:    addl %ebx, %ebp
74; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
75; X86-NEXT:    adcl $0, %edi
76; X86-NEXT:    imull %esi
77; X86-NEXT:    movl %edx, %esi
78; X86-NEXT:    movl %eax, %ebx
79; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
80; X86-NEXT:    mull {{[0-9]+}}(%esp)
81; X86-NEXT:    addl %ebp, %eax
82; X86-NEXT:    adcl %edi, %edx
83; X86-NEXT:    adcl $0, %esi
84; X86-NEXT:    addl %ebx, %edx
85; X86-NEXT:    adcl $0, %esi
86; X86-NEXT:    movl %edx, %edi
87; X86-NEXT:    subl {{[0-9]+}}(%esp), %edi
88; X86-NEXT:    movl %esi, %ebx
89; X86-NEXT:    sbbl $0, %ebx
90; X86-NEXT:    cmpl $0, {{[0-9]+}}(%esp)
91; X86-NEXT:    cmovnsl %esi, %ebx
92; X86-NEXT:    cmovnsl %edx, %edi
93; X86-NEXT:    movl %edi, %ebp
94; X86-NEXT:    subl {{[0-9]+}}(%esp), %ebp
95; X86-NEXT:    movl %ebx, %esi
96; X86-NEXT:    sbbl $0, %esi
97; X86-NEXT:    cmpl $0, {{[0-9]+}}(%esp)
98; X86-NEXT:    cmovnsl %ebx, %esi
99; X86-NEXT:    cmovnsl %edi, %ebp
100; X86-NEXT:    testl %esi, %esi
101; X86-NEXT:    setg %bl
102; X86-NEXT:    sete %bh
103; X86-NEXT:    cmpl $1, %ebp
104; X86-NEXT:    seta %dl
105; X86-NEXT:    andb %bh, %dl
106; X86-NEXT:    orb %bl, %dl
107; X86-NEXT:    shrdl $2, %eax, %ecx
108; X86-NEXT:    shrdl $2, %ebp, %eax
109; X86-NEXT:    testb %dl, %dl
110; X86-NEXT:    movl $2147483647, %edi # imm = 0x7FFFFFFF
111; X86-NEXT:    cmovel %eax, %edi
112; X86-NEXT:    movl $-1, %eax
113; X86-NEXT:    cmovnel %eax, %ecx
114; X86-NEXT:    cmpl $-1, %esi
115; X86-NEXT:    setl %al
116; X86-NEXT:    sete %dl
117; X86-NEXT:    cmpl $-2, %ebp
118; X86-NEXT:    setb %ah
119; X86-NEXT:    andb %dl, %ah
120; X86-NEXT:    xorl %edx, %edx
121; X86-NEXT:    orb %al, %ah
122; X86-NEXT:    cmovnel %edx, %ecx
123; X86-NEXT:    movl $-2147483648, %edx # imm = 0x80000000
124; X86-NEXT:    cmovel %edi, %edx
125; X86-NEXT:    movl %ecx, %eax
126; X86-NEXT:    popl %esi
127; X86-NEXT:    popl %edi
128; X86-NEXT:    popl %ebx
129; X86-NEXT:    popl %ebp
130; X86-NEXT:    retl
131  %tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 2)
132  ret i64 %tmp
133}
134
135define i4 @func3(i4 %x, i4 %y) nounwind {
136; X64-LABEL: func3:
137; X64:       # %bb.0:
138; X64-NEXT:    shlb $4, %sil
139; X64-NEXT:    sarb $4, %sil
140; X64-NEXT:    shlb $4, %dil
141; X64-NEXT:    movsbl %dil, %eax
142; X64-NEXT:    movsbl %sil, %ecx
143; X64-NEXT:    imull %eax, %ecx
144; X64-NEXT:    movl %ecx, %eax
145; X64-NEXT:    shrb $2, %al
146; X64-NEXT:    shrl $8, %ecx
147; X64-NEXT:    movl %ecx, %edx
148; X64-NEXT:    shlb $6, %dl
149; X64-NEXT:    orb %al, %dl
150; X64-NEXT:    movzbl %dl, %eax
151; X64-NEXT:    cmpb $1, %cl
152; X64-NEXT:    movl $127, %edx
153; X64-NEXT:    cmovlel %eax, %edx
154; X64-NEXT:    cmpb $-2, %cl
155; X64-NEXT:    movl $128, %eax
156; X64-NEXT:    cmovgel %edx, %eax
157; X64-NEXT:    sarb $4, %al
158; X64-NEXT:    # kill: def $al killed $al killed $eax
159; X64-NEXT:    retq
160;
161; X86-LABEL: func3:
162; X86:       # %bb.0:
163; X86-NEXT:    movb {{[0-9]+}}(%esp), %al
164; X86-NEXT:    shlb $4, %al
165; X86-NEXT:    sarb $4, %al
166; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
167; X86-NEXT:    shlb $4, %cl
168; X86-NEXT:    movsbl %cl, %ecx
169; X86-NEXT:    movsbl %al, %eax
170; X86-NEXT:    imull %ecx, %eax
171; X86-NEXT:    movb %ah, %cl
172; X86-NEXT:    shlb $6, %cl
173; X86-NEXT:    shrb $2, %al
174; X86-NEXT:    orb %cl, %al
175; X86-NEXT:    movzbl %al, %ecx
176; X86-NEXT:    cmpb $1, %ah
177; X86-NEXT:    movl $127, %edx
178; X86-NEXT:    cmovlel %ecx, %edx
179; X86-NEXT:    cmpb $-2, %ah
180; X86-NEXT:    movl $128, %eax
181; X86-NEXT:    cmovgel %edx, %eax
182; X86-NEXT:    sarb $4, %al
183; X86-NEXT:    # kill: def $al killed $al killed $eax
184; X86-NEXT:    retl
185  %tmp = call i4 @llvm.smul.fix.sat.i4(i4 %x, i4 %y, i32 2)
186  ret i4 %tmp
187}
188
189define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
190; X64-LABEL: vec:
191; X64:       # %bb.0:
192; X64-NEXT:    pshufd {{.*#+}} xmm2 = xmm1[3,3,3,3]
193; X64-NEXT:    movd %xmm2, %eax
194; X64-NEXT:    cltq
195; X64-NEXT:    pshufd {{.*#+}} xmm2 = xmm0[3,3,3,3]
196; X64-NEXT:    movd %xmm2, %ecx
197; X64-NEXT:    movslq %ecx, %rdx
198; X64-NEXT:    imulq %rax, %rdx
199; X64-NEXT:    movq %rdx, %rcx
200; X64-NEXT:    shrq $32, %rcx
201; X64-NEXT:    shrdl $2, %ecx, %edx
202; X64-NEXT:    cmpl $1, %ecx
203; X64-NEXT:    movl $2147483647, %eax # imm = 0x7FFFFFFF
204; X64-NEXT:    cmovgl %eax, %edx
205; X64-NEXT:    cmpl $-2, %ecx
206; X64-NEXT:    movl $-2147483648, %ecx # imm = 0x80000000
207; X64-NEXT:    cmovll %ecx, %edx
208; X64-NEXT:    movd %edx, %xmm2
209; X64-NEXT:    pshufd {{.*#+}} xmm3 = xmm1[2,3,2,3]
210; X64-NEXT:    movd %xmm3, %edx
211; X64-NEXT:    movslq %edx, %rdx
212; X64-NEXT:    pshufd {{.*#+}} xmm3 = xmm0[2,3,2,3]
213; X64-NEXT:    movd %xmm3, %esi
214; X64-NEXT:    movslq %esi, %rsi
215; X64-NEXT:    imulq %rdx, %rsi
216; X64-NEXT:    movq %rsi, %rdx
217; X64-NEXT:    shrq $32, %rdx
218; X64-NEXT:    shrdl $2, %edx, %esi
219; X64-NEXT:    cmpl $1, %edx
220; X64-NEXT:    cmovgl %eax, %esi
221; X64-NEXT:    cmpl $-2, %edx
222; X64-NEXT:    cmovll %ecx, %esi
223; X64-NEXT:    movd %esi, %xmm3
224; X64-NEXT:    punpckldq {{.*#+}} xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
225; X64-NEXT:    movd %xmm1, %edx
226; X64-NEXT:    movslq %edx, %rdx
227; X64-NEXT:    movd %xmm0, %esi
228; X64-NEXT:    movslq %esi, %rsi
229; X64-NEXT:    imulq %rdx, %rsi
230; X64-NEXT:    movq %rsi, %rdx
231; X64-NEXT:    shrq $32, %rdx
232; X64-NEXT:    shrdl $2, %edx, %esi
233; X64-NEXT:    cmpl $1, %edx
234; X64-NEXT:    cmovgl %eax, %esi
235; X64-NEXT:    cmpl $-2, %edx
236; X64-NEXT:    cmovll %ecx, %esi
237; X64-NEXT:    movd %esi, %xmm2
238; X64-NEXT:    pshufd {{.*#+}} xmm1 = xmm1[1,1,1,1]
239; X64-NEXT:    movd %xmm1, %edx
240; X64-NEXT:    movslq %edx, %rdx
241; X64-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[1,1,1,1]
242; X64-NEXT:    movd %xmm0, %esi
243; X64-NEXT:    movslq %esi, %rsi
244; X64-NEXT:    imulq %rdx, %rsi
245; X64-NEXT:    movq %rsi, %rdx
246; X64-NEXT:    shrq $32, %rdx
247; X64-NEXT:    shrdl $2, %edx, %esi
248; X64-NEXT:    cmpl $1, %edx
249; X64-NEXT:    cmovgl %eax, %esi
250; X64-NEXT:    cmpl $-2, %edx
251; X64-NEXT:    cmovll %ecx, %esi
252; X64-NEXT:    movd %esi, %xmm0
253; X64-NEXT:    punpckldq {{.*#+}} xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
254; X64-NEXT:    punpcklqdq {{.*#+}} xmm2 = xmm2[0],xmm3[0]
255; X64-NEXT:    movdqa %xmm2, %xmm0
256; X64-NEXT:    retq
257;
258; X86-LABEL: vec:
259; X86:       # %bb.0:
260; X86-NEXT:    pushl %ebp
261; X86-NEXT:    pushl %ebx
262; X86-NEXT:    pushl %edi
263; X86-NEXT:    pushl %esi
264; X86-NEXT:    movl {{[0-9]+}}(%esp), %ebx
265; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
266; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
267; X86-NEXT:    imull {{[0-9]+}}(%esp)
268; X86-NEXT:    movl %eax, %ecx
269; X86-NEXT:    shrdl $2, %edx, %ecx
270; X86-NEXT:    cmpl $1, %edx
271; X86-NEXT:    movl $2147483647, %ebp # imm = 0x7FFFFFFF
272; X86-NEXT:    cmovgl %ebp, %ecx
273; X86-NEXT:    cmpl $-2, %edx
274; X86-NEXT:    movl $-2147483648, %esi # imm = 0x80000000
275; X86-NEXT:    cmovll %esi, %ecx
276; X86-NEXT:    movl %edi, %eax
277; X86-NEXT:    imull {{[0-9]+}}(%esp)
278; X86-NEXT:    movl %eax, %edi
279; X86-NEXT:    shrdl $2, %edx, %edi
280; X86-NEXT:    cmpl $1, %edx
281; X86-NEXT:    cmovgl %ebp, %edi
282; X86-NEXT:    cmpl $-2, %edx
283; X86-NEXT:    cmovll %esi, %edi
284; X86-NEXT:    movl %ebx, %eax
285; X86-NEXT:    imull {{[0-9]+}}(%esp)
286; X86-NEXT:    movl %eax, %ebx
287; X86-NEXT:    shrdl $2, %edx, %ebx
288; X86-NEXT:    cmpl $1, %edx
289; X86-NEXT:    cmovgl %ebp, %ebx
290; X86-NEXT:    cmpl $-2, %edx
291; X86-NEXT:    cmovll %esi, %ebx
292; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
293; X86-NEXT:    imull {{[0-9]+}}(%esp)
294; X86-NEXT:    shrdl $2, %edx, %eax
295; X86-NEXT:    cmpl $1, %edx
296; X86-NEXT:    cmovgl %ebp, %eax
297; X86-NEXT:    cmpl $-2, %edx
298; X86-NEXT:    cmovll %esi, %eax
299; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
300; X86-NEXT:    movl %eax, 12(%edx)
301; X86-NEXT:    movl %ebx, 8(%edx)
302; X86-NEXT:    movl %edi, 4(%edx)
303; X86-NEXT:    movl %ecx, (%edx)
304; X86-NEXT:    movl %edx, %eax
305; X86-NEXT:    popl %esi
306; X86-NEXT:    popl %edi
307; X86-NEXT:    popl %ebx
308; X86-NEXT:    popl %ebp
309; X86-NEXT:    retl $4
310  %tmp = call <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32> %x, <4 x i32> %y, i32 2)
311  ret <4 x i32> %tmp
312}
313
314; These result in regular integer multiplication
315define i32 @func4(i32 %x, i32 %y) nounwind {
316; X64-LABEL: func4:
317; X64:       # %bb.0:
318; X64-NEXT:    movl %edi, %ecx
319; X64-NEXT:    imull %esi, %ecx
320; X64-NEXT:    xorl %eax, %eax
321; X64-NEXT:    testl %ecx, %ecx
322; X64-NEXT:    setns %al
323; X64-NEXT:    addl $2147483647, %eax # imm = 0x7FFFFFFF
324; X64-NEXT:    imull %esi, %edi
325; X64-NEXT:    cmovnol %edi, %eax
326; X64-NEXT:    retq
327;
328; X86-LABEL: func4:
329; X86:       # %bb.0:
330; X86-NEXT:    pushl %esi
331; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
332; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
333; X86-NEXT:    movl %eax, %esi
334; X86-NEXT:    imull %edx, %esi
335; X86-NEXT:    xorl %ecx, %ecx
336; X86-NEXT:    testl %esi, %esi
337; X86-NEXT:    setns %cl
338; X86-NEXT:    addl $2147483647, %ecx # imm = 0x7FFFFFFF
339; X86-NEXT:    imull %edx, %eax
340; X86-NEXT:    cmovol %ecx, %eax
341; X86-NEXT:    popl %esi
342; X86-NEXT:    retl
343  %tmp = call i32 @llvm.smul.fix.sat.i32(i32 %x, i32 %y, i32 0)
344  ret i32 %tmp
345}
346
347define i64 @func5(i64 %x, i64 %y) {
348; X64-LABEL: func5:
349; X64:       # %bb.0:
350; X64-NEXT:    movq %rdi, %rax
351; X64-NEXT:    imulq %rsi, %rax
352; X64-NEXT:    xorl %ecx, %ecx
353; X64-NEXT:    testq %rax, %rax
354; X64-NEXT:    setns %cl
355; X64-NEXT:    movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
356; X64-NEXT:    addq %rcx, %rax
357; X64-NEXT:    imulq %rsi, %rdi
358; X64-NEXT:    cmovnoq %rdi, %rax
359; X64-NEXT:    retq
360;
361; X86-LABEL: func5:
362; X86:       # %bb.0:
363; X86-NEXT:    pushl %edi
364; X86-NEXT:    .cfi_def_cfa_offset 8
365; X86-NEXT:    pushl %esi
366; X86-NEXT:    .cfi_def_cfa_offset 12
367; X86-NEXT:    pushl %eax
368; X86-NEXT:    .cfi_def_cfa_offset 16
369; X86-NEXT:    .cfi_offset %esi, -12
370; X86-NEXT:    .cfi_offset %edi, -8
371; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
372; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
373; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
374; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
375; X86-NEXT:    movl $0, (%esp)
376; X86-NEXT:    movl %esp, %edi
377; X86-NEXT:    pushl %edi
378; X86-NEXT:    .cfi_adjust_cfa_offset 4
379; X86-NEXT:    pushl %esi
380; X86-NEXT:    .cfi_adjust_cfa_offset 4
381; X86-NEXT:    pushl %edx
382; X86-NEXT:    .cfi_adjust_cfa_offset 4
383; X86-NEXT:    pushl %ecx
384; X86-NEXT:    .cfi_adjust_cfa_offset 4
385; X86-NEXT:    pushl %eax
386; X86-NEXT:    .cfi_adjust_cfa_offset 4
387; X86-NEXT:    calll __mulodi4
388; X86-NEXT:    addl $20, %esp
389; X86-NEXT:    .cfi_adjust_cfa_offset -20
390; X86-NEXT:    xorl %ecx, %ecx
391; X86-NEXT:    testl %edx, %edx
392; X86-NEXT:    setns %cl
393; X86-NEXT:    addl $2147483647, %ecx # imm = 0x7FFFFFFF
394; X86-NEXT:    movl %edx, %esi
395; X86-NEXT:    sarl $31, %esi
396; X86-NEXT:    cmpl $0, (%esp)
397; X86-NEXT:    cmovnel %esi, %eax
398; X86-NEXT:    cmovnel %ecx, %edx
399; X86-NEXT:    addl $4, %esp
400; X86-NEXT:    .cfi_def_cfa_offset 12
401; X86-NEXT:    popl %esi
402; X86-NEXT:    .cfi_def_cfa_offset 8
403; X86-NEXT:    popl %edi
404; X86-NEXT:    .cfi_def_cfa_offset 4
405; X86-NEXT:    retl
406  %tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 0)
407  ret i64 %tmp
408}
409
410define i4 @func6(i4 %x, i4 %y) nounwind {
411; X64-LABEL: func6:
412; X64:       # %bb.0:
413; X64-NEXT:    movl %edi, %eax
414; X64-NEXT:    shlb $4, %sil
415; X64-NEXT:    sarb $4, %sil
416; X64-NEXT:    shlb $4, %al
417; X64-NEXT:    # kill: def $al killed $al killed $eax
418; X64-NEXT:    imulb %sil
419; X64-NEXT:    seto %cl
420; X64-NEXT:    xorl %edx, %edx
421; X64-NEXT:    testb %al, %al
422; X64-NEXT:    setns %dl
423; X64-NEXT:    addl $127, %edx
424; X64-NEXT:    movzbl %al, %eax
425; X64-NEXT:    testb %cl, %cl
426; X64-NEXT:    cmovnel %edx, %eax
427; X64-NEXT:    sarb $4, %al
428; X64-NEXT:    # kill: def $al killed $al killed $eax
429; X64-NEXT:    retq
430;
431; X86-LABEL: func6:
432; X86:       # %bb.0:
433; X86-NEXT:    movb {{[0-9]+}}(%esp), %cl
434; X86-NEXT:    shlb $4, %cl
435; X86-NEXT:    sarb $4, %cl
436; X86-NEXT:    movb {{[0-9]+}}(%esp), %al
437; X86-NEXT:    shlb $4, %al
438; X86-NEXT:    imulb %cl
439; X86-NEXT:    seto %dl
440; X86-NEXT:    xorl %ecx, %ecx
441; X86-NEXT:    testb %al, %al
442; X86-NEXT:    setns %cl
443; X86-NEXT:    addl $127, %ecx
444; X86-NEXT:    movzbl %al, %eax
445; X86-NEXT:    testb %dl, %dl
446; X86-NEXT:    cmovnel %ecx, %eax
447; X86-NEXT:    sarb $4, %al
448; X86-NEXT:    # kill: def $al killed $al killed $eax
449; X86-NEXT:    retl
450  %tmp = call i4 @llvm.smul.fix.sat.i4(i4 %x, i4 %y, i32 0)
451  ret i4 %tmp
452}
453
454define <4 x i32> @vec2(<4 x i32> %x, <4 x i32> %y) nounwind {
455; X64-LABEL: vec2:
456; X64:       # %bb.0:
457; X64-NEXT:    pshufd {{.*#+}} xmm2 = xmm1[1,1,1,1]
458; X64-NEXT:    movd %xmm2, %ecx
459; X64-NEXT:    pshufd {{.*#+}} xmm2 = xmm0[1,1,1,1]
460; X64-NEXT:    movd %xmm2, %r8d
461; X64-NEXT:    movl %r8d, %edx
462; X64-NEXT:    imull %ecx, %edx
463; X64-NEXT:    xorl %esi, %esi
464; X64-NEXT:    testl %edx, %edx
465; X64-NEXT:    setns %sil
466; X64-NEXT:    addl $2147483647, %esi # imm = 0x7FFFFFFF
467; X64-NEXT:    imull %ecx, %r8d
468; X64-NEXT:    cmovol %esi, %r8d
469; X64-NEXT:    movd %xmm1, %edx
470; X64-NEXT:    movd %xmm0, %ecx
471; X64-NEXT:    movl %ecx, %esi
472; X64-NEXT:    imull %edx, %esi
473; X64-NEXT:    xorl %edi, %edi
474; X64-NEXT:    testl %esi, %esi
475; X64-NEXT:    setns %dil
476; X64-NEXT:    addl $2147483647, %edi # imm = 0x7FFFFFFF
477; X64-NEXT:    imull %edx, %ecx
478; X64-NEXT:    cmovol %edi, %ecx
479; X64-NEXT:    pshufd {{.*#+}} xmm2 = xmm1[2,3,2,3]
480; X64-NEXT:    movd %xmm2, %edx
481; X64-NEXT:    pshufd {{.*#+}} xmm2 = xmm0[2,3,2,3]
482; X64-NEXT:    movd %xmm2, %esi
483; X64-NEXT:    movl %esi, %edi
484; X64-NEXT:    imull %edx, %edi
485; X64-NEXT:    xorl %eax, %eax
486; X64-NEXT:    testl %edi, %edi
487; X64-NEXT:    setns %al
488; X64-NEXT:    addl $2147483647, %eax # imm = 0x7FFFFFFF
489; X64-NEXT:    imull %edx, %esi
490; X64-NEXT:    cmovol %eax, %esi
491; X64-NEXT:    pshufd {{.*#+}} xmm1 = xmm1[3,3,3,3]
492; X64-NEXT:    movd %xmm1, %r9d
493; X64-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[3,3,3,3]
494; X64-NEXT:    movd %xmm0, %edx
495; X64-NEXT:    movl %edx, %edi
496; X64-NEXT:    imull %r9d, %edi
497; X64-NEXT:    xorl %eax, %eax
498; X64-NEXT:    testl %edi, %edi
499; X64-NEXT:    setns %al
500; X64-NEXT:    addl $2147483647, %eax # imm = 0x7FFFFFFF
501; X64-NEXT:    imull %r9d, %edx
502; X64-NEXT:    cmovol %eax, %edx
503; X64-NEXT:    movd %edx, %xmm0
504; X64-NEXT:    movd %esi, %xmm1
505; X64-NEXT:    punpckldq {{.*#+}} xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
506; X64-NEXT:    movd %ecx, %xmm0
507; X64-NEXT:    movd %r8d, %xmm2
508; X64-NEXT:    punpckldq {{.*#+}} xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
509; X64-NEXT:    punpcklqdq {{.*#+}} xmm0 = xmm0[0],xmm1[0]
510; X64-NEXT:    retq
511;
512; X86-LABEL: vec2:
513; X86:       # %bb.0:
514; X86-NEXT:    pushl %ebp
515; X86-NEXT:    pushl %ebx
516; X86-NEXT:    pushl %edi
517; X86-NEXT:    pushl %esi
518; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
519; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
520; X86-NEXT:    movl %ecx, %esi
521; X86-NEXT:    imull %edx, %esi
522; X86-NEXT:    xorl %eax, %eax
523; X86-NEXT:    testl %esi, %esi
524; X86-NEXT:    setns %al
525; X86-NEXT:    addl $2147483647, %eax # imm = 0x7FFFFFFF
526; X86-NEXT:    imull %edx, %ecx
527; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
528; X86-NEXT:    cmovol %eax, %ecx
529; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
530; X86-NEXT:    movl %edx, %edi
531; X86-NEXT:    imull %esi, %edi
532; X86-NEXT:    xorl %eax, %eax
533; X86-NEXT:    testl %edi, %edi
534; X86-NEXT:    setns %al
535; X86-NEXT:    addl $2147483647, %eax # imm = 0x7FFFFFFF
536; X86-NEXT:    imull %esi, %edx
537; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
538; X86-NEXT:    cmovol %eax, %edx
539; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
540; X86-NEXT:    movl %esi, %ebx
541; X86-NEXT:    imull %edi, %ebx
542; X86-NEXT:    xorl %eax, %eax
543; X86-NEXT:    testl %ebx, %ebx
544; X86-NEXT:    setns %al
545; X86-NEXT:    addl $2147483647, %eax # imm = 0x7FFFFFFF
546; X86-NEXT:    imull %edi, %esi
547; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
548; X86-NEXT:    cmovol %eax, %esi
549; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
550; X86-NEXT:    movl %edi, %ebp
551; X86-NEXT:    imull %eax, %ebp
552; X86-NEXT:    xorl %ebx, %ebx
553; X86-NEXT:    testl %ebp, %ebp
554; X86-NEXT:    setns %bl
555; X86-NEXT:    addl $2147483647, %ebx # imm = 0x7FFFFFFF
556; X86-NEXT:    imull %eax, %edi
557; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
558; X86-NEXT:    cmovol %ebx, %edi
559; X86-NEXT:    movl %ecx, 12(%eax)
560; X86-NEXT:    movl %edx, 8(%eax)
561; X86-NEXT:    movl %esi, 4(%eax)
562; X86-NEXT:    movl %edi, (%eax)
563; X86-NEXT:    popl %esi
564; X86-NEXT:    popl %edi
565; X86-NEXT:    popl %ebx
566; X86-NEXT:    popl %ebp
567; X86-NEXT:    retl $4
568  %tmp = call <4 x i32> @llvm.smul.fix.sat.v4i32(<4 x i32> %x, <4 x i32> %y, i32 0)
569  ret <4 x i32> %tmp
570}
571
572define i64 @func7(i64 %x, i64 %y) nounwind {
573; X64-LABEL: func7:
574; X64:       # %bb.0:
575; X64-NEXT:    movq %rdi, %rax
576; X64-NEXT:    imulq %rsi
577; X64-NEXT:    shrdq $32, %rdx, %rax
578; X64-NEXT:    cmpq $2147483647, %rdx # imm = 0x7FFFFFFF
579; X64-NEXT:    movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
580; X64-NEXT:    cmovgq %rcx, %rax
581; X64-NEXT:    cmpq $-2147483648, %rdx # imm = 0x80000000
582; X64-NEXT:    movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
583; X64-NEXT:    cmovlq %rcx, %rax
584; X64-NEXT:    retq
585;
586; X86-LABEL: func7:
587; X86:       # %bb.0:
588; X86-NEXT:    pushl %ebp
589; X86-NEXT:    pushl %ebx
590; X86-NEXT:    pushl %edi
591; X86-NEXT:    pushl %esi
592; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
593; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
594; X86-NEXT:    movl %ecx, %eax
595; X86-NEXT:    mull {{[0-9]+}}(%esp)
596; X86-NEXT:    movl %edx, %edi
597; X86-NEXT:    movl %eax, %ebx
598; X86-NEXT:    movl %ecx, %eax
599; X86-NEXT:    mull {{[0-9]+}}(%esp)
600; X86-NEXT:    addl %edx, %ebx
601; X86-NEXT:    adcl $0, %edi
602; X86-NEXT:    movl %esi, %eax
603; X86-NEXT:    imull {{[0-9]+}}(%esp)
604; X86-NEXT:    movl %edx, %ebp
605; X86-NEXT:    movl %eax, %ecx
606; X86-NEXT:    movl %esi, %eax
607; X86-NEXT:    mull {{[0-9]+}}(%esp)
608; X86-NEXT:    addl %ebx, %eax
609; X86-NEXT:    adcl %edi, %edx
610; X86-NEXT:    adcl $0, %ebp
611; X86-NEXT:    addl %ecx, %edx
612; X86-NEXT:    adcl $0, %ebp
613; X86-NEXT:    movl %edx, %ecx
614; X86-NEXT:    subl {{[0-9]+}}(%esp), %ecx
615; X86-NEXT:    movl %ebp, %esi
616; X86-NEXT:    sbbl $0, %esi
617; X86-NEXT:    cmpl $0, {{[0-9]+}}(%esp)
618; X86-NEXT:    cmovnsl %ebp, %esi
619; X86-NEXT:    cmovnsl %edx, %ecx
620; X86-NEXT:    movl %ecx, %edx
621; X86-NEXT:    subl {{[0-9]+}}(%esp), %edx
622; X86-NEXT:    movl %esi, %edi
623; X86-NEXT:    sbbl $0, %edi
624; X86-NEXT:    cmpl $0, {{[0-9]+}}(%esp)
625; X86-NEXT:    cmovnsl %esi, %edi
626; X86-NEXT:    cmovnsl %ecx, %edx
627; X86-NEXT:    testl %edx, %edx
628; X86-NEXT:    setns %cl
629; X86-NEXT:    sets %ch
630; X86-NEXT:    testl %edi, %edi
631; X86-NEXT:    setg %bl
632; X86-NEXT:    sete %bh
633; X86-NEXT:    andb %ch, %bh
634; X86-NEXT:    orb %bl, %bh
635; X86-NEXT:    movl $2147483647, %esi # imm = 0x7FFFFFFF
636; X86-NEXT:    cmovnel %esi, %edx
637; X86-NEXT:    movl $-1, %esi
638; X86-NEXT:    cmovnel %esi, %eax
639; X86-NEXT:    cmpl $-1, %edi
640; X86-NEXT:    setl %ch
641; X86-NEXT:    sete %bl
642; X86-NEXT:    andb %cl, %bl
643; X86-NEXT:    xorl %esi, %esi
644; X86-NEXT:    orb %ch, %bl
645; X86-NEXT:    cmovnel %esi, %eax
646; X86-NEXT:    movl $-2147483648, %ecx # imm = 0x80000000
647; X86-NEXT:    cmovnel %ecx, %edx
648; X86-NEXT:    popl %esi
649; X86-NEXT:    popl %edi
650; X86-NEXT:    popl %ebx
651; X86-NEXT:    popl %ebp
652; X86-NEXT:    retl
653  %tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 32)
654  ret i64 %tmp
655}
656
657define i64 @func8(i64 %x, i64 %y) nounwind {
658; X64-LABEL: func8:
659; X64:       # %bb.0:
660; X64-NEXT:    movq %rdi, %rax
661; X64-NEXT:    imulq %rsi
662; X64-NEXT:    shrdq $63, %rdx, %rax
663; X64-NEXT:    movabsq $4611686018427387903, %rcx # imm = 0x3FFFFFFFFFFFFFFF
664; X64-NEXT:    cmpq %rcx, %rdx
665; X64-NEXT:    movabsq $9223372036854775807, %rcx # imm = 0x7FFFFFFFFFFFFFFF
666; X64-NEXT:    cmovgq %rcx, %rax
667; X64-NEXT:    movabsq $-4611686018427387904, %rcx # imm = 0xC000000000000000
668; X64-NEXT:    cmpq %rcx, %rdx
669; X64-NEXT:    movabsq $-9223372036854775808, %rcx # imm = 0x8000000000000000
670; X64-NEXT:    cmovlq %rcx, %rax
671; X64-NEXT:    retq
672;
673; X86-LABEL: func8:
674; X86:       # %bb.0:
675; X86-NEXT:    pushl %ebp
676; X86-NEXT:    pushl %ebx
677; X86-NEXT:    pushl %edi
678; X86-NEXT:    pushl %esi
679; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
680; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
681; X86-NEXT:    movl %ecx, %eax
682; X86-NEXT:    mull {{[0-9]+}}(%esp)
683; X86-NEXT:    movl %edx, %edi
684; X86-NEXT:    movl %eax, %ebx
685; X86-NEXT:    movl %ecx, %eax
686; X86-NEXT:    mull {{[0-9]+}}(%esp)
687; X86-NEXT:    addl %edx, %ebx
688; X86-NEXT:    adcl $0, %edi
689; X86-NEXT:    movl %esi, %eax
690; X86-NEXT:    imull {{[0-9]+}}(%esp)
691; X86-NEXT:    movl %edx, %ebp
692; X86-NEXT:    movl %eax, %ecx
693; X86-NEXT:    movl %esi, %eax
694; X86-NEXT:    mull {{[0-9]+}}(%esp)
695; X86-NEXT:    addl %ebx, %eax
696; X86-NEXT:    adcl %edi, %edx
697; X86-NEXT:    adcl $0, %ebp
698; X86-NEXT:    addl %ecx, %edx
699; X86-NEXT:    adcl $0, %ebp
700; X86-NEXT:    movl %edx, %ecx
701; X86-NEXT:    subl {{[0-9]+}}(%esp), %ecx
702; X86-NEXT:    movl %ebp, %esi
703; X86-NEXT:    sbbl $0, %esi
704; X86-NEXT:    cmpl $0, {{[0-9]+}}(%esp)
705; X86-NEXT:    cmovnsl %ebp, %esi
706; X86-NEXT:    cmovnsl %edx, %ecx
707; X86-NEXT:    movl %ecx, %edx
708; X86-NEXT:    subl {{[0-9]+}}(%esp), %edx
709; X86-NEXT:    movl %esi, %edi
710; X86-NEXT:    sbbl $0, %edi
711; X86-NEXT:    cmpl $0, {{[0-9]+}}(%esp)
712; X86-NEXT:    cmovnsl %esi, %edi
713; X86-NEXT:    cmovnsl %ecx, %edx
714; X86-NEXT:    shrdl $31, %edx, %eax
715; X86-NEXT:    shrdl $31, %edi, %edx
716; X86-NEXT:    cmpl $1073741823, %edi # imm = 0x3FFFFFFF
717; X86-NEXT:    movl $2147483647, %ecx # imm = 0x7FFFFFFF
718; X86-NEXT:    cmovgl %ecx, %edx
719; X86-NEXT:    movl $-1, %ecx
720; X86-NEXT:    cmovgl %ecx, %eax
721; X86-NEXT:    xorl %ecx, %ecx
722; X86-NEXT:    cmpl $-1073741824, %edi # imm = 0xC0000000
723; X86-NEXT:    cmovll %ecx, %eax
724; X86-NEXT:    movl $-2147483648, %ecx # imm = 0x80000000
725; X86-NEXT:    cmovll %ecx, %edx
726; X86-NEXT:    popl %esi
727; X86-NEXT:    popl %edi
728; X86-NEXT:    popl %ebx
729; X86-NEXT:    popl %ebp
730; X86-NEXT:    retl
731  %tmp = call i64 @llvm.smul.fix.sat.i64(i64 %x, i64 %y, i32 63)
732  ret i64 %tmp
733}
734