1 /* Function asin vectorized with SSE4.
2 Copyright (C) 2021-2022 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 https://www.gnu.org/licenses/. */
20 * ALGORITHM DESCRIPTION:
22 * SelMask = (|x| >= 0.5) ? 1 : 0;
23 * R = SelMask ? sqrt(0.5 - 0.5*|x|) : |x|
24 * asin(x) = (SelMask ? (Pi/2 - 2*Poly(R)) : Poly(R))*(-1)^sign(x)
28 /* Offsets for data table __svml_dasin_data_internal
36 #define poly_coeff 144
41 .section .text.sse4, "ax", @progbits
42 ENTRY(_ZGVbN2v_asin_sse4)
44 cfi_def_cfa_offset(80)
46 movups __svml_dasin_data_internal(%rip), %xmm3
47 movups OneHalf+__svml_dasin_data_internal(%rip), %xmm8
64 cvtpd2ps %xmm14, %xmm9
69 cmpltpd SmallNorm+__svml_dasin_data_internal(%rip), %xmm15
71 cvtps2pd %xmm10, %xmm11
80 subpd Two+__svml_dasin_data_internal(%rip), %xmm14
83 movups poly_coeff+__svml_dasin_data_internal(%rip), %xmm6
87 addpd poly_coeff+16+__svml_dasin_data_internal(%rip), %xmm6
88 movups One+__svml_dasin_data_internal(%rip), %xmm7
93 movups poly_coeff+32+__svml_dasin_data_internal(%rip), %xmm9
95 movups poly_coeff+64+__svml_dasin_data_internal(%rip), %xmm7
98 addpd poly_coeff+48+__svml_dasin_data_internal(%rip), %xmm9
99 addpd poly_coeff+80+__svml_dasin_data_internal(%rip), %xmm7
105 movups poly_coeff+96+__svml_dasin_data_internal(%rip), %xmm10
107 movups sqrt_coeff+__svml_dasin_data_internal(%rip), %xmm13
109 addpd poly_coeff+112+__svml_dasin_data_internal(%rip), %xmm10
110 addpd sqrt_coeff+16+__svml_dasin_data_internal(%rip), %xmm13
114 addpd sqrt_coeff+32+__svml_dasin_data_internal(%rip), %xmm13
117 movups poly_coeff+128+__svml_dasin_data_internal(%rip), %xmm11
119 addpd sqrt_coeff+48+__svml_dasin_data_internal(%rip), %xmm14
120 addpd poly_coeff+144+__svml_dasin_data_internal(%rip), %xmm11
125 movups poly_coeff+160+__svml_dasin_data_internal(%rip), %xmm13
128 addpd poly_coeff+176+__svml_dasin_data_internal(%rip), %xmm13
136 movups Pi2H+__svml_dasin_data_internal(%rip), %xmm0
142 /* Go to special inputs processing branch */
143 jne L(SPECIAL_VALUES_BRANCH)
144 # LOE rbx rbp r12 r13 r14 r15 edx xmm0 xmm5
147 * and exit the function
152 cfi_def_cfa_offset(8)
154 cfi_def_cfa_offset(80)
160 L(SPECIAL_VALUES_BRANCH):
161 movups %xmm5, 32(%rsp)
162 movups %xmm0, 48(%rsp)
163 # LOE rbx rbp r12 r13 r14 r15 edx
174 # LOE rbx rbp r15 r12d r13d
183 /* Call scalar math function */
184 jc L(SCALAR_MATH_CALL)
185 # LOE rbx rbp r15 r12d r13d
191 L(SPECIAL_VALUES_LOOP):
195 /* Check bits in range mask */
196 jl L(RANGEMASK_CHECK)
197 # LOE rbx rbp r15 r12d r13d
205 movups 48(%rsp), %xmm0
212 # LOE rbx rbp r12 r13 r14 r15 xmm0
214 /* Scalar math fucntion call
215 * to process special input
220 movsd 32(%rsp, %r14, 8), %xmm0
222 # LOE rbx rbp r14 r15 r12d r13d xmm0
224 movsd %xmm0, 48(%rsp, %r14, 8)
226 /* Process special inputs in loop */
227 jmp L(SPECIAL_VALUES_LOOP)
228 # LOE rbx rbp r15 r12d r13d
229 END(_ZGVbN2v_asin_sse4)
231 .section .rodata, "a"
234 #ifdef __svml_dasin_data_internal_typedef
235 typedef unsigned int VUINT32;
237 __declspec(align(16)) VUINT32 AbsMask[2][2];
238 __declspec(align(16)) VUINT32 OneHalf[2][2];
239 __declspec(align(16)) VUINT32 SmallNorm[2][2];
240 __declspec(align(16)) VUINT32 One[2][2];
241 __declspec(align(16)) VUINT32 Two[2][2];
242 __declspec(align(16)) VUINT32 sqrt_coeff[4][2][2];
243 __declspec(align(16)) VUINT32 poly_coeff[12][2][2];
244 __declspec(align(16)) VUINT32 Pi2H[2][2];
245 } __svml_dasin_data_internal;
247 __svml_dasin_data_internal:
249 .quad 0x7fffffffffffffff, 0x7fffffffffffffff
252 .quad 0x3fe0000000000000, 0x3fe0000000000000
255 .quad 0x3000000000000000, 0x3000000000000000
258 .quad 0x3ff0000000000000, 0x3ff0000000000000
261 .quad 0x4000000000000000, 0x4000000000000000
264 .quad 0xbf918000993B24C3, 0xbf918000993B24C3 /* sqrt_coeff4 */
265 .quad 0x3fa400006F70D42D, 0x3fa400006F70D42D /* sqrt_coeff3 */
266 .quad 0xbfb7FFFFFFFFFE97, 0xbfb7FFFFFFFFFE97 /* sqrt_coeff2 */
267 .quad 0x3fcFFFFFFFFFFF9D, 0x3fcFFFFFFFFFFF9D /* sqrt_coeff1 */
270 .quad 0x3fa07520C70EB909, 0x3fa07520C70EB909 /* poly_coeff12 */
271 .quad 0xbf90FB17F7DBB0ED, 0xbf90FB17F7DBB0ED /* poly_coeff11 */
272 .quad 0x3f943F44BFBC3BAE, 0x3f943F44BFBC3BAE /* poly_coeff10 */
273 .quad 0x3f7A583395D45ED5, 0x3f7A583395D45ED5 /* poly_coeff9 */
274 .quad 0x3f88F8DC2AFCCAD6, 0x3f88F8DC2AFCCAD6 /* poly_coeff8 */
275 .quad 0x3f8C6DBBCB88BD57, 0x3f8C6DBBCB88BD57 /* poly_coeff7 */
276 .quad 0x3f91C6DCF538AD2E, 0x3f91C6DCF538AD2E /* poly_coeff6 */
277 .quad 0x3f96E89CEBDEFadd, 0x3f96E89CEBDEFadd /* poly_coeff5 */
278 .quad 0x3f9F1C72E13AD8BE, 0x3f9F1C72E13AD8BE /* poly_coeff4 */
279 .quad 0x3fa6DB6DB3B445F8, 0x3fa6DB6DB3B445F8 /* poly_coeff3 */
280 .quad 0x3fb333333337E0DE, 0x3fb333333337E0DE /* poly_coeff2 */
281 .quad 0x3fc555555555529C, 0x3fc555555555529C /* poly_coeff1 */
284 .quad 0x3ff921fb54442d18, 0x3ff921fb54442d18
286 .type __svml_dasin_data_internal, @object
287 .size __svml_dasin_data_internal, .-__svml_dasin_data_internal