1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-- | FileCheck %s -check-prefix=X87
3 ; RUN: llc < %s -mtriple=i686-- -mattr=-x87 | FileCheck %s -check-prefixes=NOX87,NOSSE-NOX87
4 ; RUN: llc < %s -mtriple=i686-- -mattr=-x87,-sse2 | FileCheck %s -check-prefixes=NOX87,NOSSE-NOX87
5 ; RUN: llc < %s -mtriple=i686-- -mattr=-x87,+sse2 | FileCheck %s -check-prefixes=NOX87,SSE-NOX87
7 define float @f1(float %a, float %b) nounwind {
9 ; X87: # %bb.0: # %entry
10 ; X87-NEXT: flds {{[0-9]+}}(%esp)
13 ; NOSSE-NOX87-LABEL: f1:
14 ; NOSSE-NOX87: # %bb.0: # %entry
15 ; NOSSE-NOX87-NEXT: movl {{[0-9]+}}(%esp), %eax
16 ; NOSSE-NOX87-NEXT: retl
18 ; SSE-NOX87-LABEL: f1:
19 ; SSE-NOX87: # %bb.0: # %entry
20 ; SSE-NOX87-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
21 ; SSE-NOX87-NEXT: movd %xmm0, %eax
22 ; SSE-NOX87-NEXT: retl
27 define double @f2(double %a, double %b) nounwind {
29 ; X87: # %bb.0: # %entry
30 ; X87-NEXT: fldl {{[0-9]+}}(%esp)
34 ; NOX87: # %bb.0: # %entry
35 ; NOX87-NEXT: movl {{[0-9]+}}(%esp), %eax
36 ; NOX87-NEXT: movl {{[0-9]+}}(%esp), %edx
42 define x86_fp80 @f3(x86_fp80 %a, x86_fp80 %b) nounwind {
44 ; X87: # %bb.0: # %entry
45 ; X87-NEXT: fldt {{[0-9]+}}(%esp)
49 ; NOX87: # %bb.0: # %entry
50 ; NOX87-NEXT: movl {{[0-9]+}}(%esp), %eax
51 ; NOX87-NEXT: movl {{[0-9]+}}(%esp), %edx
52 ; NOX87-NEXT: movl {{[0-9]+}}(%esp), %ecx
58 define float @f4(float %a, float %b) nounwind {
60 ; X87: # %bb.0: # %entry
61 ; X87-NEXT: flds {{[0-9]+}}(%esp)
62 ; X87-NEXT: fadds {{[0-9]+}}(%esp)
65 ; NOSSE-NOX87-LABEL: f4:
66 ; NOSSE-NOX87: # %bb.0: # %entry
67 ; NOSSE-NOX87-NEXT: pushl {{[0-9]+}}(%esp)
68 ; NOSSE-NOX87-NEXT: pushl {{[0-9]+}}(%esp)
69 ; NOSSE-NOX87-NEXT: calll __addsf3
70 ; NOSSE-NOX87-NEXT: addl $8, %esp
71 ; NOSSE-NOX87-NEXT: retl
73 ; SSE-NOX87-LABEL: f4:
74 ; SSE-NOX87: # %bb.0: # %entry
75 ; SSE-NOX87-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
76 ; SSE-NOX87-NEXT: addss {{[0-9]+}}(%esp), %xmm0
77 ; SSE-NOX87-NEXT: movd %xmm0, %eax
78 ; SSE-NOX87-NEXT: retl
80 %0 = fadd float %a, %b
84 define double @f5(double %a, double %b) nounwind {
86 ; X87: # %bb.0: # %entry
87 ; X87-NEXT: fldl {{[0-9]+}}(%esp)
88 ; X87-NEXT: faddl {{[0-9]+}}(%esp)
91 ; NOSSE-NOX87-LABEL: f5:
92 ; NOSSE-NOX87: # %bb.0: # %entry
93 ; NOSSE-NOX87-NEXT: pushl {{[0-9]+}}(%esp)
94 ; NOSSE-NOX87-NEXT: pushl {{[0-9]+}}(%esp)
95 ; NOSSE-NOX87-NEXT: pushl {{[0-9]+}}(%esp)
96 ; NOSSE-NOX87-NEXT: pushl {{[0-9]+}}(%esp)
97 ; NOSSE-NOX87-NEXT: calll __adddf3
98 ; NOSSE-NOX87-NEXT: addl $16, %esp
99 ; NOSSE-NOX87-NEXT: retl
101 ; SSE-NOX87-LABEL: f5:
102 ; SSE-NOX87: # %bb.0: # %entry
103 ; SSE-NOX87-NEXT: pushl %ebp
104 ; SSE-NOX87-NEXT: movl %esp, %ebp
105 ; SSE-NOX87-NEXT: andl $-8, %esp
106 ; SSE-NOX87-NEXT: subl $8, %esp
107 ; SSE-NOX87-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
108 ; SSE-NOX87-NEXT: addsd 16(%ebp), %xmm0
109 ; SSE-NOX87-NEXT: movsd %xmm0, (%esp)
110 ; SSE-NOX87-NEXT: movl (%esp), %eax
111 ; SSE-NOX87-NEXT: movl {{[0-9]+}}(%esp), %edx
112 ; SSE-NOX87-NEXT: movl %ebp, %esp
113 ; SSE-NOX87-NEXT: popl %ebp
114 ; SSE-NOX87-NEXT: retl
116 %0 = fadd double %a, %b
120 define x86_fp80 @f6(x86_fp80 %a, x86_fp80 %b) nounwind {
122 ; X87: # %bb.0: # %entry
123 ; X87-NEXT: fldt {{[0-9]+}}(%esp)
124 ; X87-NEXT: fldt {{[0-9]+}}(%esp)
125 ; X87-NEXT: faddp %st, %st(1)
129 ; NOX87: # %bb.0: # %entry
130 ; NOX87-NEXT: movzwl {{[0-9]+}}(%esp), %eax
131 ; NOX87-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
132 ; NOX87-NEXT: pushl %ecx
133 ; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
134 ; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
135 ; NOX87-NEXT: pushl %eax
136 ; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
137 ; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
138 ; NOX87-NEXT: calll __addxf3
139 ; NOX87-NEXT: addl $24, %esp
140 ; NOX87-NEXT: movzwl %cx, %ecx
143 %0 = fadd x86_fp80 %a, %b
147 define {float, float, float} @f7(float %a, float %b) nounwind {
149 ; X87: # %bb.0: # %entry
150 ; X87-NEXT: movl {{[0-9]+}}(%esp), %eax
151 ; X87-NEXT: flds {{[0-9]+}}(%esp)
152 ; X87-NEXT: flds {{[0-9]+}}(%esp)
153 ; X87-NEXT: fstps 8(%eax)
154 ; X87-NEXT: fsts 4(%eax)
155 ; X87-NEXT: fstps (%eax)
158 ; NOSSE-NOX87-LABEL: f7:
159 ; NOSSE-NOX87: # %bb.0: # %entry
160 ; NOSSE-NOX87-NEXT: movl {{[0-9]+}}(%esp), %eax
161 ; NOSSE-NOX87-NEXT: movl {{[0-9]+}}(%esp), %ecx
162 ; NOSSE-NOX87-NEXT: movl %eax, %edx
163 ; NOSSE-NOX87-NEXT: retl
165 ; SSE-NOX87-LABEL: f7:
166 ; SSE-NOX87: # %bb.0: # %entry
167 ; SSE-NOX87-NEXT: movd {{.*#+}} xmm0 = mem[0],zero,zero,zero
168 ; SSE-NOX87-NEXT: movd {{.*#+}} xmm1 = mem[0],zero,zero,zero
169 ; SSE-NOX87-NEXT: movd %xmm0, %eax
170 ; SSE-NOX87-NEXT: movd %xmm0, %edx
171 ; SSE-NOX87-NEXT: movd %xmm1, %ecx
172 ; SSE-NOX87-NEXT: retl
174 %0 = insertvalue {float, float, float} undef, float %a, 0
175 %1 = insertvalue {float, float, float} %0, float %a, 1
176 %2 = insertvalue {float, float, float} %1, float %b, 2
177 ret {float, float, float} %2
180 define x86_fp80 @f8(i64 %a) nounwind {
182 ; X87: # %bb.0: # %entry
183 ; X87-NEXT: fildll {{[0-9]+}}(%esp)
187 ; NOX87: # %bb.0: # %entry
188 ; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
189 ; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
190 ; NOX87-NEXT: calll __floatdixf
191 ; NOX87-NEXT: addl $8, %esp
192 ; NOX87-NEXT: movzwl %cx, %ecx
195 %0 = sitofp i64 %a to x86_fp80
199 define i32 @f9(x86_fp80 %a) nounwind {
201 ; X87: # %bb.0: # %entry
202 ; X87-NEXT: subl $8, %esp
203 ; X87-NEXT: fldt {{[0-9]+}}(%esp)
204 ; X87-NEXT: fnstcw (%esp)
205 ; X87-NEXT: movzwl (%esp), %eax
206 ; X87-NEXT: orl $3072, %eax # imm = 0xC00
207 ; X87-NEXT: movw %ax, {{[0-9]+}}(%esp)
208 ; X87-NEXT: fldcw {{[0-9]+}}(%esp)
209 ; X87-NEXT: fistpl {{[0-9]+}}(%esp)
210 ; X87-NEXT: fldcw (%esp)
211 ; X87-NEXT: movl {{[0-9]+}}(%esp), %eax
212 ; X87-NEXT: addl $8, %esp
216 ; NOX87: # %bb.0: # %entry
217 ; NOX87-NEXT: movzwl {{[0-9]+}}(%esp), %eax
218 ; NOX87-NEXT: pushl %eax
219 ; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
220 ; NOX87-NEXT: pushl {{[0-9]+}}(%esp)
221 ; NOX87-NEXT: calll __fixxfsi
222 ; NOX87-NEXT: addl $12, %esp
225 %0 = fptosi x86_fp80 %a to i32