1 /* Function asin vectorized with SSE4.
2 Copyright (C) 2021 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
42 .section .text.sse4,"ax",@progbits
43 ENTRY(_ZGVbN2v_asin_sse4)
45 cfi_def_cfa_offset(80)
47 movups __svml_dasin_data_internal(%rip), %xmm3
48 movups OneHalf+__svml_dasin_data_internal(%rip), %xmm8
65 cvtpd2ps %xmm14, %xmm9
70 cmpltpd SmallNorm+__svml_dasin_data_internal(%rip), %xmm15
72 cvtps2pd %xmm10, %xmm11
81 subpd Two+__svml_dasin_data_internal(%rip), %xmm14
84 movups poly_coeff+__svml_dasin_data_internal(%rip), %xmm6
88 addpd poly_coeff+16+__svml_dasin_data_internal(%rip), %xmm6
89 movups One+__svml_dasin_data_internal(%rip), %xmm7
94 movups poly_coeff+32+__svml_dasin_data_internal(%rip), %xmm9
96 movups poly_coeff+64+__svml_dasin_data_internal(%rip), %xmm7
99 addpd poly_coeff+48+__svml_dasin_data_internal(%rip), %xmm9
100 addpd poly_coeff+80+__svml_dasin_data_internal(%rip), %xmm7
106 movups poly_coeff+96+__svml_dasin_data_internal(%rip), %xmm10
108 movups sqrt_coeff+__svml_dasin_data_internal(%rip), %xmm13
110 addpd poly_coeff+112+__svml_dasin_data_internal(%rip), %xmm10
111 addpd sqrt_coeff+16+__svml_dasin_data_internal(%rip), %xmm13
115 addpd sqrt_coeff+32+__svml_dasin_data_internal(%rip), %xmm13
118 movups poly_coeff+128+__svml_dasin_data_internal(%rip), %xmm11
120 addpd sqrt_coeff+48+__svml_dasin_data_internal(%rip), %xmm14
121 addpd poly_coeff+144+__svml_dasin_data_internal(%rip), %xmm11
126 movups poly_coeff+160+__svml_dasin_data_internal(%rip), %xmm13
129 addpd poly_coeff+176+__svml_dasin_data_internal(%rip), %xmm13
137 movups Pi2H+__svml_dasin_data_internal(%rip), %xmm0
143 /* Go to special inputs processing branch */
144 jne L(SPECIAL_VALUES_BRANCH)
145 # LOE rbx rbp r12 r13 r14 r15 edx xmm0 xmm5
148 * and exit the function
153 cfi_def_cfa_offset(8)
155 cfi_def_cfa_offset(80)
161 L(SPECIAL_VALUES_BRANCH):
162 movups %xmm5, 32(%rsp)
163 movups %xmm0, 48(%rsp)
164 # LOE rbx rbp r12 r13 r14 r15 edx
175 # LOE rbx rbp r15 r12d r13d
184 /* Call scalar math function */
185 jc L(SCALAR_MATH_CALL)
186 # LOE rbx rbp r15 r12d r13d
192 L(SPECIAL_VALUES_LOOP):
196 /* Check bits in range mask */
197 jl L(RANGEMASK_CHECK)
198 # LOE rbx rbp r15 r12d r13d
206 movups 48(%rsp), %xmm0
213 # LOE rbx rbp r12 r13 r14 r15 xmm0
215 /* Scalar math fucntion call
216 * to process special input
221 movsd 32(%rsp,%r14,8), %xmm0
223 # LOE rbx rbp r14 r15 r12d r13d xmm0
225 movsd %xmm0, 48(%rsp,%r14,8)
227 /* Process special inputs in loop */
228 jmp L(SPECIAL_VALUES_LOOP)
229 # LOE rbx rbp r15 r12d r13d
230 END(_ZGVbN2v_asin_sse4)
232 .section .rodata, "a"
235 #ifdef __svml_dasin_data_internal_typedef
236 typedef unsigned int VUINT32;
238 __declspec(align(16)) VUINT32 AbsMask[2][2];
239 __declspec(align(16)) VUINT32 OneHalf[2][2];
240 __declspec(align(16)) VUINT32 SmallNorm[2][2];
241 __declspec(align(16)) VUINT32 One[2][2];
242 __declspec(align(16)) VUINT32 Two[2][2];
243 __declspec(align(16)) VUINT32 sqrt_coeff[4][2][2];
244 __declspec(align(16)) VUINT32 poly_coeff[12][2][2];
245 __declspec(align(16)) VUINT32 Pi2H[2][2];
246 } __svml_dasin_data_internal;
248 __svml_dasin_data_internal:
250 .quad 0x7fffffffffffffff, 0x7fffffffffffffff
253 .quad 0x3fe0000000000000, 0x3fe0000000000000
256 .quad 0x3000000000000000, 0x3000000000000000
259 .quad 0x3ff0000000000000, 0x3ff0000000000000
262 .quad 0x4000000000000000, 0x4000000000000000
263 /*== sqrt_coeff[4] ==*/
265 .quad 0xbf918000993B24C3, 0xbf918000993B24C3 /* sqrt_coeff4 */
266 .quad 0x3fa400006F70D42D, 0x3fa400006F70D42D /* sqrt_coeff3 */
267 .quad 0xbfb7FFFFFFFFFE97, 0xbfb7FFFFFFFFFE97 /* sqrt_coeff2 */
268 .quad 0x3fcFFFFFFFFFFF9D, 0x3fcFFFFFFFFFFF9D /* sqrt_coeff1 */
269 /*== poly_coeff[12] ==*/
271 .quad 0x3fa07520C70EB909, 0x3fa07520C70EB909 /* poly_coeff12 */
272 .quad 0xbf90FB17F7DBB0ED, 0xbf90FB17F7DBB0ED /* poly_coeff11 */
273 .quad 0x3f943F44BFBC3BAE, 0x3f943F44BFBC3BAE /* poly_coeff10 */
274 .quad 0x3f7A583395D45ED5, 0x3f7A583395D45ED5 /* poly_coeff9 */
275 .quad 0x3f88F8DC2AFCCAD6, 0x3f88F8DC2AFCCAD6 /* poly_coeff8 */
276 .quad 0x3f8C6DBBCB88BD57, 0x3f8C6DBBCB88BD57 /* poly_coeff7 */
277 .quad 0x3f91C6DCF538AD2E, 0x3f91C6DCF538AD2E /* poly_coeff6 */
278 .quad 0x3f96E89CEBDEFadd, 0x3f96E89CEBDEFadd /* poly_coeff5 */
279 .quad 0x3f9F1C72E13AD8BE, 0x3f9F1C72E13AD8BE /* poly_coeff4 */
280 .quad 0x3fa6DB6DB3B445F8, 0x3fa6DB6DB3B445F8 /* poly_coeff3 */
281 .quad 0x3fb333333337E0DE, 0x3fb333333337E0DE /* poly_coeff2 */
282 .quad 0x3fc555555555529C, 0x3fc555555555529C /* poly_coeff1 */
285 .quad 0x3ff921fb54442d18, 0x3ff921fb54442d18
287 .type __svml_dasin_data_internal,@object
288 .size __svml_dasin_data_internal,.-__svml_dasin_data_internal