1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
9 define float @tst1(float %a, float %b) nounwind {
12 ; X86-NEXT: subl $8, %esp
13 ; X86-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
14 ; X86-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
15 ; X86-NEXT: movss %xmm1, {{[0-9]+}}(%esp)
16 ; X86-NEXT: movss %xmm0, (%esp)
17 ; X86-NEXT: calll copysignf
18 ; X86-NEXT: addl $8, %esp
23 ; X64-NEXT: movaps %xmm0, %xmm2
24 ; X64-NEXT: movaps %xmm1, %xmm0
25 ; X64-NEXT: movaps %xmm2, %xmm1
26 ; X64-NEXT: jmp copysignf # TAILCALL
27 %tmp = tail call float @copysignf( float %b, float %a )
31 define double @tst2(double %a, float %b, float %c) nounwind {
34 ; X86-NEXT: subl $16, %esp
35 ; X86-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
36 ; X86-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
37 ; X86-NEXT: addss {{[0-9]+}}(%esp), %xmm1
38 ; X86-NEXT: cvtss2sd %xmm1, %xmm1
39 ; X86-NEXT: movsd %xmm0, (%esp)
40 ; X86-NEXT: movsd %xmm1, {{[0-9]+}}(%esp)
41 ; X86-NEXT: calll copysign
42 ; X86-NEXT: addl $16, %esp
47 ; X64-NEXT: addss %xmm2, %xmm1
48 ; X64-NEXT: cvtss2sd %xmm1, %xmm1
49 ; X64-NEXT: jmp copysign # TAILCALL
50 %tmp1 = fadd float %b, %c
51 %tmp2 = fpext float %tmp1 to double
52 %tmp = tail call double @copysign( double %a, double %tmp2 )
56 define x86_fp80 @tst3(x86_fp80 %a, x86_fp80 %b) nounwind {
59 ; X86-NEXT: subl $24, %esp
60 ; X86-NEXT: fldt {{[0-9]+}}(%esp)
61 ; X86-NEXT: fldt {{[0-9]+}}(%esp)
62 ; X86-NEXT: fstpt {{[0-9]+}}(%esp)
63 ; X86-NEXT: fstpt (%esp)
64 ; X86-NEXT: calll copysignl
65 ; X86-NEXT: addl $24, %esp
70 ; X64-NEXT: subq $40, %rsp
71 ; X64-NEXT: fldt {{[0-9]+}}(%rsp)
72 ; X64-NEXT: fldt {{[0-9]+}}(%rsp)
73 ; X64-NEXT: fstpt {{[0-9]+}}(%rsp)
74 ; X64-NEXT: fstpt (%rsp)
75 ; X64-NEXT: callq copysignl
76 ; X64-NEXT: addq $40, %rsp
78 %tmp = tail call x86_fp80 @copysignl( x86_fp80 %b, x86_fp80 %a )
82 declare dso_local float @copysignf(float, float)
83 declare dso_local double @copysign(double, double)
84 declare dso_local x86_fp80 @copysignl(x86_fp80, x86_fp80)
90 define float @int1(float %a, float %b) nounwind {
93 ; X86-NEXT: pushl %eax
94 ; X86-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
95 ; X86-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
96 ; X86-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
97 ; X86-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
98 ; X86-NEXT: orps %xmm0, %xmm1
99 ; X86-NEXT: movss %xmm1, (%esp)
100 ; X86-NEXT: flds (%esp)
101 ; X86-NEXT: popl %eax
106 ; X64-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
107 ; X64-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
108 ; X64-NEXT: orps %xmm1, %xmm0
110 %tmp = tail call float @llvm.copysign.f32( float %b, float %a )
114 define double @int2(double %a, float %b, float %c) nounwind {
117 ; X86-NEXT: pushl %ebp
118 ; X86-NEXT: movl %esp, %ebp
119 ; X86-NEXT: andl $-8, %esp
120 ; X86-NEXT: subl $8, %esp
121 ; X86-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
122 ; X86-NEXT: addss 20(%ebp), %xmm0
123 ; X86-NEXT: movsd {{.*#+}} xmm1 = mem[0],zero
124 ; X86-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
125 ; X86-NEXT: cvtss2sd %xmm0, %xmm0
126 ; X86-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
127 ; X86-NEXT: orps %xmm1, %xmm0
128 ; X86-NEXT: movlps %xmm0, (%esp)
129 ; X86-NEXT: fldl (%esp)
130 ; X86-NEXT: movl %ebp, %esp
131 ; X86-NEXT: popl %ebp
136 ; X64-NEXT: addss %xmm2, %xmm1
137 ; X64-NEXT: cvtss2sd %xmm1, %xmm1
138 ; X64-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
139 ; X64-NEXT: andps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
140 ; X64-NEXT: orps %xmm1, %xmm0
142 %tmp1 = fadd float %b, %c
143 %tmp2 = fpext float %tmp1 to double
144 %tmp = tail call double @llvm.copysign.f64( double %a, double %tmp2 )
148 define x86_fp80 @int3(x86_fp80 %a, x86_fp80 %b) nounwind {
151 ; X86-NEXT: subl $12, %esp
152 ; X86-NEXT: fldt {{[0-9]+}}(%esp)
153 ; X86-NEXT: fldt {{[0-9]+}}(%esp)
154 ; X86-NEXT: fstpt (%esp)
156 ; X86-NEXT: fld %st(0)
158 ; X86-NEXT: testb $-128, {{[0-9]+}}(%esp)
159 ; X86-NEXT: fxch %st(1)
160 ; X86-NEXT: fcmovne %st(1), %st
161 ; X86-NEXT: fstp %st(1)
162 ; X86-NEXT: addl $12, %esp
167 ; X64-NEXT: fldt {{[0-9]+}}(%rsp)
168 ; X64-NEXT: fldt {{[0-9]+}}(%rsp)
169 ; X64-NEXT: fstpt -{{[0-9]+}}(%rsp)
171 ; X64-NEXT: fld %st(0)
173 ; X64-NEXT: testb $-128, -{{[0-9]+}}(%rsp)
174 ; X64-NEXT: fxch %st(1)
175 ; X64-NEXT: fcmovne %st(1), %st
176 ; X64-NEXT: fstp %st(1)
178 %tmp = tail call x86_fp80 @llvm.copysign.f80( x86_fp80 %b, x86_fp80 %a )
182 define float @cst1() nounwind {
191 ; X64-NEXT: movss {{.*#+}} xmm0 = [-1.0E+0,0.0E+0,0.0E+0,0.0E+0]
193 %tmp = tail call float @llvm.copysign.f32( float 1.0, float -2.0 )
197 define double @cst2() nounwind {
206 ; X64-NEXT: movsd {{.*#+}} xmm0 = [-0.0E+0,0.0E+0]
208 %tmp1 = fadd float -1.0, -1.0
209 %tmp2 = fpext float %tmp1 to double
210 %tmp = tail call double @llvm.copysign.f64( double 0.0, double %tmp2 )
214 define x86_fp80 @cst3() nounwind {
226 %tmp1 = fadd float -1.0, -1.0
227 %tmp2 = fpext float %tmp1 to x86_fp80
228 %tmp = tail call x86_fp80 @llvm.copysign.f80( x86_fp80 zeroinitializer, x86_fp80 %tmp2 )
232 define void @PR41749() {
233 ; X86-LABEL: PR41749:
235 ; X86-NEXT: subl $12, %esp
236 ; X86-NEXT: .cfi_def_cfa_offset 16
238 ; X86-NEXT: fld %st(0)
239 ; X86-NEXT: fstpt (%esp)
240 ; X86-NEXT: testb $-128, {{[0-9]+}}(%esp)
241 ; X86-NEXT: fld %st(0)
243 ; X86-NEXT: fxch %st(1)
244 ; X86-NEXT: fcmovne %st(1), %st
245 ; X86-NEXT: fstp %st(1)
246 ; X86-NEXT: fstpt (%eax)
247 ; X86-NEXT: addl $12, %esp
248 ; X86-NEXT: .cfi_def_cfa_offset 4
251 ; X64-LABEL: PR41749:
254 ; X64-NEXT: fld %st(0)
255 ; X64-NEXT: fstpt -{{[0-9]+}}(%rsp)
256 ; X64-NEXT: testb $-128, -{{[0-9]+}}(%rsp)
257 ; X64-NEXT: fld %st(0)
259 ; X64-NEXT: fxch %st(1)
260 ; X64-NEXT: fcmovne %st(1), %st
261 ; X64-NEXT: fstp %st(1)
262 ; X64-NEXT: fstpt (%rax)
264 %1 = call x86_fp80 @llvm.copysign.f80(x86_fp80 0xK00000000000000000000, x86_fp80 undef)
265 store x86_fp80 %1, ptr undef, align 16
269 declare dso_local float @llvm.copysign.f32(float %Mag, float %Sgn)
270 declare dso_local double @llvm.copysign.f64(double %Mag, double %Sgn)
271 declare dso_local x86_fp80 @llvm.copysign.f80(x86_fp80 %Mag, x86_fp80 %Sgn)