1 /* Function sin vectorized with SSE4.
2 Copyright (C) 2014-2015 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
20 #include "svml_d_sin_data.h"
23 ENTRY (_ZGVbN2v_sin_sse4)
24 /* ALGORITHM DESCRIPTION:
26 ( low accuracy ( < 4ulp ) or enhanced performance
27 ( half of correct mantissa ) implementation )
29 Argument representation:
33 sin(arg) = sin(N*Pi + R) = (-1)^N * sin(R)
34 sin(R) is approximated by corresponding polynomial
37 cfi_adjust_cfa_offset (8)
38 cfi_rel_offset (%rbp, 0)
40 cfi_def_cfa_register (%rbp)
44 movq __svml_dsin_data@GOTPCREL(%rip), %rax
45 movups __dAbsMask(%rax), %xmm3
47 * ARGUMENT RANGE REDUCTION:
52 /* SignX - sign bit of X */
54 movups __dInvPI(%rax), %xmm2
57 /* Y = X'*InvPi + RS : right shifter add */
59 movups __dRShifter(%rax), %xmm6
64 cmpnlepd __dRangeVal(%rax), %xmm4
66 /* N = Y - RS : right shifter sub */
69 /* SignRes = Y<<63 : shift LSB to MSB place for result sign */
73 movups __dPI1(%rax), %xmm7
75 movups __dPI2(%rax), %xmm6
80 movups __dPI3(%rax), %xmm7
85 movups __dPI4(%rax), %xmm6
93 * POLYNOMIAL APPROXIMATION:
99 /* R = R^SignRes : update sign of reduced argument */
101 movups __dC7(%rax), %xmm2
103 addpd __dC6(%rax), %xmm2
105 addpd __dC5(%rax), %xmm2
107 addpd __dC4(%rax), %xmm2
109 /* Poly = C3+R2*(C4+R2*(C5+R2*(C6+R2*C7))) */
111 addpd __dC3(%rax), %xmm2
113 /* Poly = R2*(C1+R2*(C2+R2*Poly)) */
115 addpd __dC2(%rax), %xmm2
117 addpd __dC1(%rax), %xmm2
120 /* Poly = Poly*R + R */
126 * Final sign setting: Res = Poly^SignX
135 cfi_def_cfa_register (%rsp)
137 cfi_adjust_cfa_offset (-8)
143 movups %xmm5, 192(%rsp)
144 movups %xmm0, 256(%rsp)
149 movups %xmm8, 112(%rsp)
150 movups %xmm9, 96(%rsp)
151 movups %xmm10, 80(%rsp)
152 movups %xmm11, 64(%rsp)
153 movups %xmm12, 48(%rsp)
154 movups %xmm13, 32(%rsp)
155 movups %xmm14, 16(%rsp)
156 movups %xmm15, (%rsp)
160 cfi_offset_rel_rsp (12, 168)
163 cfi_offset_rel_rsp (13, 160)
166 cfi_offset_rel_rsp (14, 152)
169 cfi_offset_rel_rsp (15, 144)
187 movups 112(%rsp), %xmm8
188 movups 96(%rsp), %xmm9
189 movups 80(%rsp), %xmm10
190 movups 64(%rsp), %xmm11
191 movups 48(%rsp), %xmm12
192 movups 32(%rsp), %xmm13
193 movups 16(%rsp), %xmm14
194 movups (%rsp), %xmm15
205 movups 256(%rsp), %xmm0
212 movsd 200(%rsp,%r15), %xmm0
216 movsd %xmm0, 264(%rsp,%r15)
222 movsd 192(%rsp,%r15), %xmm0
226 movsd %xmm0, 256(%rsp,%r15)
229 END (_ZGVbN2v_sin_sse4)