• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686 -mattr=cmov | FileCheck %s --check-prefix=X86
3; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s --check-prefix=X64
4
5declare i4 @llvm.sadd.sat.i4(i4, i4)
6declare i8 @llvm.sadd.sat.i8(i8, i8)
7declare i16 @llvm.sadd.sat.i16(i16, i16)
8declare i32 @llvm.sadd.sat.i32(i32, i32)
9declare i64 @llvm.sadd.sat.i64(i64, i64)
10declare <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32>, <4 x i32>)
11
12define i32 @func(i32 %x, i32 %y) nounwind {
13; X86-LABEL: func:
14; X86:       # %bb.0:
15; X86-NEXT:    pushl %esi
16; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
17; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
18; X86-NEXT:    xorl %ecx, %ecx
19; X86-NEXT:    movl %eax, %esi
20; X86-NEXT:    addl %edx, %esi
21; X86-NEXT:    setns %cl
22; X86-NEXT:    addl $2147483647, %ecx # imm = 0x7FFFFFFF
23; X86-NEXT:    addl %edx, %eax
24; X86-NEXT:    cmovol %ecx, %eax
25; X86-NEXT:    popl %esi
26; X86-NEXT:    retl
27;
28; X64-LABEL: func:
29; X64:       # %bb.0:
30; X64-NEXT:    xorl %eax, %eax
31; X64-NEXT:    movl %edi, %ecx
32; X64-NEXT:    addl %esi, %ecx
33; X64-NEXT:    setns %al
34; X64-NEXT:    addl $2147483647, %eax # imm = 0x7FFFFFFF
35; X64-NEXT:    addl %esi, %edi
36; X64-NEXT:    cmovnol %edi, %eax
37; X64-NEXT:    retq
38  %tmp = call i32 @llvm.sadd.sat.i32(i32 %x, i32 %y);
39  ret i32 %tmp;
40}
41
42define i64 @func2(i64 %x, i64 %y) nounwind {
43; X86-LABEL: func2:
44; X86:       # %bb.0:
45; X86-NEXT:    pushl %ebx
46; X86-NEXT:    pushl %esi
47; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
48; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
49; X86-NEXT:    addl {{[0-9]+}}(%esp), %ecx
50; X86-NEXT:    adcl {{[0-9]+}}(%esp), %esi
51; X86-NEXT:    seto %bl
52; X86-NEXT:    movl %esi, %eax
53; X86-NEXT:    sarl $31, %eax
54; X86-NEXT:    testb %bl, %bl
55; X86-NEXT:    cmovel %ecx, %eax
56; X86-NEXT:    xorl %edx, %edx
57; X86-NEXT:    testl %esi, %esi
58; X86-NEXT:    setns %dl
59; X86-NEXT:    addl $2147483647, %edx # imm = 0x7FFFFFFF
60; X86-NEXT:    testb %bl, %bl
61; X86-NEXT:    cmovel %esi, %edx
62; X86-NEXT:    popl %esi
63; X86-NEXT:    popl %ebx
64; X86-NEXT:    retl
65;
66; X64-LABEL: func2:
67; X64:       # %bb.0:
68; X64-NEXT:    xorl %ecx, %ecx
69; X64-NEXT:    movq %rdi, %rax
70; X64-NEXT:    addq %rsi, %rax
71; X64-NEXT:    setns %cl
72; X64-NEXT:    movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
73; X64-NEXT:    addq %rcx, %rax
74; X64-NEXT:    addq %rsi, %rdi
75; X64-NEXT:    cmovnoq %rdi, %rax
76; X64-NEXT:    retq
77  %tmp = call i64 @llvm.sadd.sat.i64(i64 %x, i64 %y);
78  ret i64 %tmp;
79}
80
81define signext i16 @func16(i16 signext %x, i16 signext %y) nounwind {
82; X86-LABEL: func16:
83; X86:       # %bb.0:
84; X86-NEXT:    pushl %esi
85; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
86; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %edx
87; X86-NEXT:    xorl %ecx, %ecx
88; X86-NEXT:    movl %eax, %esi
89; X86-NEXT:    addw %dx, %si
90; X86-NEXT:    setns %cl
91; X86-NEXT:    addl $32767, %ecx # imm = 0x7FFF
92; X86-NEXT:    addw %dx, %ax
93; X86-NEXT:    cmovol %ecx, %eax
94; X86-NEXT:    # kill: def $ax killed $ax killed $eax
95; X86-NEXT:    popl %esi
96; X86-NEXT:    retl
97;
98; X64-LABEL: func16:
99; X64:       # %bb.0:
100; X64-NEXT:    xorl %eax, %eax
101; X64-NEXT:    movl %edi, %ecx
102; X64-NEXT:    addw %si, %cx
103; X64-NEXT:    setns %al
104; X64-NEXT:    addl $32767, %eax # imm = 0x7FFF
105; X64-NEXT:    addw %si, %di
106; X64-NEXT:    cmovnol %edi, %eax
107; X64-NEXT:    # kill: def $ax killed $ax killed $eax
108; X64-NEXT:    retq
109  %tmp = call i16 @llvm.sadd.sat.i16(i16 %x, i16 %y)
110  ret i16 %tmp
111}
112
113define signext i8 @func8(i8 signext %x, i8 signext %y) nounwind {
114; X86-LABEL: func8:
115; X86:       # %bb.0:
116; X86-NEXT:    movb {{[0-9]+}}(%esp), %al
117; X86-NEXT:    movb {{[0-9]+}}(%esp), %dl
118; X86-NEXT:    xorl %ecx, %ecx
119; X86-NEXT:    movb %al, %ah
120; X86-NEXT:    addb %dl, %ah
121; X86-NEXT:    setns %cl
122; X86-NEXT:    addl $127, %ecx
123; X86-NEXT:    addb %dl, %al
124; X86-NEXT:    movzbl %al, %eax
125; X86-NEXT:    cmovol %ecx, %eax
126; X86-NEXT:    # kill: def $al killed $al killed $eax
127; X86-NEXT:    retl
128;
129; X64-LABEL: func8:
130; X64:       # %bb.0:
131; X64-NEXT:    xorl %ecx, %ecx
132; X64-NEXT:    movl %edi, %eax
133; X64-NEXT:    addb %sil, %al
134; X64-NEXT:    setns %cl
135; X64-NEXT:    addl $127, %ecx
136; X64-NEXT:    addb %sil, %dil
137; X64-NEXT:    movzbl %dil, %eax
138; X64-NEXT:    cmovol %ecx, %eax
139; X64-NEXT:    # kill: def $al killed $al killed $eax
140; X64-NEXT:    retq
141  %tmp = call i8 @llvm.sadd.sat.i8(i8 %x, i8 %y)
142  ret i8 %tmp
143}
144
145define signext i4 @func3(i4 signext %x, i4 signext %y) nounwind {
146; X86-LABEL: func3:
147; X86:       # %bb.0:
148; X86-NEXT:    movb {{[0-9]+}}(%esp), %al
149; X86-NEXT:    addb {{[0-9]+}}(%esp), %al
150; X86-NEXT:    movzbl %al, %ecx
151; X86-NEXT:    cmpb $7, %al
152; X86-NEXT:    movl $7, %eax
153; X86-NEXT:    cmovll %ecx, %eax
154; X86-NEXT:    cmpb $-8, %al
155; X86-NEXT:    movl $248, %ecx
156; X86-NEXT:    cmovgl %eax, %ecx
157; X86-NEXT:    movsbl %cl, %eax
158; X86-NEXT:    retl
159;
160; X64-LABEL: func3:
161; X64:       # %bb.0:
162; X64-NEXT:    addb %sil, %dil
163; X64-NEXT:    movzbl %dil, %eax
164; X64-NEXT:    cmpb $7, %al
165; X64-NEXT:    movl $7, %ecx
166; X64-NEXT:    cmovll %eax, %ecx
167; X64-NEXT:    cmpb $-8, %cl
168; X64-NEXT:    movl $248, %eax
169; X64-NEXT:    cmovgl %ecx, %eax
170; X64-NEXT:    movsbl %al, %eax
171; X64-NEXT:    retq
172  %tmp = call i4 @llvm.sadd.sat.i4(i4 %x, i4 %y);
173  ret i4 %tmp;
174}
175
176define <4 x i32> @vec(<4 x i32> %x, <4 x i32> %y) nounwind {
177; X86-LABEL: vec:
178; X86:       # %bb.0:
179; X86-NEXT:    pushl %ebp
180; X86-NEXT:    pushl %ebx
181; X86-NEXT:    pushl %edi
182; X86-NEXT:    pushl %esi
183; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx
184; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
185; X86-NEXT:    xorl %eax, %eax
186; X86-NEXT:    movl %ecx, %esi
187; X86-NEXT:    addl %edx, %esi
188; X86-NEXT:    setns %al
189; X86-NEXT:    addl $2147483647, %eax # imm = 0x7FFFFFFF
190; X86-NEXT:    addl %edx, %ecx
191; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
192; X86-NEXT:    cmovol %eax, %ecx
193; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
194; X86-NEXT:    xorl %eax, %eax
195; X86-NEXT:    movl %edx, %edi
196; X86-NEXT:    addl %esi, %edi
197; X86-NEXT:    setns %al
198; X86-NEXT:    addl $2147483647, %eax # imm = 0x7FFFFFFF
199; X86-NEXT:    addl %esi, %edx
200; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi
201; X86-NEXT:    cmovol %eax, %edx
202; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
203; X86-NEXT:    xorl %eax, %eax
204; X86-NEXT:    movl %esi, %ebx
205; X86-NEXT:    addl %edi, %ebx
206; X86-NEXT:    setns %al
207; X86-NEXT:    addl $2147483647, %eax # imm = 0x7FFFFFFF
208; X86-NEXT:    addl %edi, %esi
209; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi
210; X86-NEXT:    cmovol %eax, %esi
211; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
212; X86-NEXT:    xorl %ebx, %ebx
213; X86-NEXT:    movl %edi, %ebp
214; X86-NEXT:    addl %eax, %ebp
215; X86-NEXT:    setns %bl
216; X86-NEXT:    addl $2147483647, %ebx # imm = 0x7FFFFFFF
217; X86-NEXT:    addl %eax, %edi
218; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
219; X86-NEXT:    cmovol %ebx, %edi
220; X86-NEXT:    movl %ecx, 12(%eax)
221; X86-NEXT:    movl %edx, 8(%eax)
222; X86-NEXT:    movl %esi, 4(%eax)
223; X86-NEXT:    movl %edi, (%eax)
224; X86-NEXT:    popl %esi
225; X86-NEXT:    popl %edi
226; X86-NEXT:    popl %ebx
227; X86-NEXT:    popl %ebp
228; X86-NEXT:    retl $4
229;
230; X64-LABEL: vec:
231; X64:       # %bb.0:
232; X64-NEXT:    pxor %xmm2, %xmm2
233; X64-NEXT:    pxor %xmm3, %xmm3
234; X64-NEXT:    pcmpgtd %xmm1, %xmm3
235; X64-NEXT:    paddd %xmm0, %xmm1
236; X64-NEXT:    pcmpgtd %xmm1, %xmm0
237; X64-NEXT:    pxor %xmm3, %xmm0
238; X64-NEXT:    movdqa %xmm1, %xmm3
239; X64-NEXT:    pandn {{.*}}(%rip), %xmm3
240; X64-NEXT:    pcmpgtd %xmm1, %xmm2
241; X64-NEXT:    psrld $1, %xmm2
242; X64-NEXT:    por %xmm3, %xmm2
243; X64-NEXT:    pand %xmm0, %xmm2
244; X64-NEXT:    pandn %xmm1, %xmm0
245; X64-NEXT:    por %xmm2, %xmm0
246; X64-NEXT:    retq
247  %tmp = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %x, <4 x i32> %y);
248  ret <4 x i32> %tmp;
249}
250