1 /* Function acos 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 * acos(|x|) = SelMask ? 2*Poly(R) : (Pi/2 - Poly(R))
25 * acos(x) = sign(x) ? (Pi - acos(|x|)) : acos(|x|)
29 /* Offsets for data table __svml_dacos_data_internal
37 #define poly_coeff 144
43 .section .text.sse4, "ax", @progbits
44 ENTRY(_ZGVbN2v_acos_sse4)
46 cfi_def_cfa_offset(80)
48 movups __svml_dacos_data_internal(%rip), %xmm3
49 movups OneHalf+__svml_dacos_data_internal(%rip), %xmm6
55 /* Y = 0.5 + 0.5*(-x) */
68 cvtps2pd %xmm10, %xmm11
72 cmpltpd SmallNorm+__svml_dacos_data_internal(%rip), %xmm1
83 subpd Two+__svml_dacos_data_internal(%rip), %xmm6
84 movups sqrt_coeff+__svml_dacos_data_internal(%rip), %xmm13
88 addpd sqrt_coeff+16+__svml_dacos_data_internal(%rip), %xmm13
90 addpd sqrt_coeff+32+__svml_dacos_data_internal(%rip), %xmm13
94 movups poly_coeff+__svml_dacos_data_internal(%rip), %xmm15
97 addpd sqrt_coeff+48+__svml_dacos_data_internal(%rip), %xmm6
98 addpd poly_coeff+16+__svml_dacos_data_internal(%rip), %xmm15
103 movups MOne+__svml_dacos_data_internal(%rip), %xmm8
106 /* NaN processed in special branch (so wind test passed) */
107 cmpnlepd %xmm4, %xmm8
112 movups poly_coeff+32+__svml_dacos_data_internal(%rip), %xmm8
114 movups poly_coeff+64+__svml_dacos_data_internal(%rip), %xmm6
117 addpd poly_coeff+48+__svml_dacos_data_internal(%rip), %xmm8
118 addpd poly_coeff+80+__svml_dacos_data_internal(%rip), %xmm6
119 cmpltpd %xmm0, %xmm12
123 movups poly_coeff+96+__svml_dacos_data_internal(%rip), %xmm9
125 addpd poly_coeff+112+__svml_dacos_data_internal(%rip), %xmm9
127 movups poly_coeff+128+__svml_dacos_data_internal(%rip), %xmm10
131 addpd poly_coeff+144+__svml_dacos_data_internal(%rip), %xmm10
133 movups poly_coeff+160+__svml_dacos_data_internal(%rip), %xmm14
138 addpd poly_coeff+176+__svml_dacos_data_internal(%rip), %xmm14
144 movups PiH+__svml_dacos_data_internal(%rip), %xmm0
146 andnps Pi2H+__svml_dacos_data_internal(%rip), %xmm13
153 /* Go to special inputs processing branch */
154 jne L(SPECIAL_VALUES_BRANCH)
155 # LOE rbx rbp r12 r13 r14 r15 edx xmm0 xmm5
158 * and exit the function
163 cfi_def_cfa_offset(8)
165 cfi_def_cfa_offset(80)
171 L(SPECIAL_VALUES_BRANCH):
172 movups %xmm5, 32(%rsp)
173 movups %xmm0, 48(%rsp)
174 # LOE rbx rbp r12 r13 r14 r15 edx
185 # LOE rbx rbp r15 r12d r13d
194 /* Call scalar math function */
195 jc L(SCALAR_MATH_CALL)
196 # LOE rbx rbp r15 r12d r13d
202 L(SPECIAL_VALUES_LOOP):
206 /* Check bits in range mask */
207 jl L(RANGEMASK_CHECK)
208 # LOE rbx rbp r15 r12d r13d
216 movups 48(%rsp), %xmm0
223 # LOE rbx rbp r12 r13 r14 r15 xmm0
225 /* Scalar math fucntion call
226 * to process special input
231 movsd 32(%rsp, %r14, 8), %xmm0
233 # LOE rbx rbp r14 r15 r12d r13d xmm0
235 movsd %xmm0, 48(%rsp, %r14, 8)
237 /* Process special inputs in loop */
238 jmp L(SPECIAL_VALUES_LOOP)
239 # LOE rbx rbp r15 r12d r13d
240 END(_ZGVbN2v_acos_sse4)
242 .section .rodata, "a"
245 #ifdef __svml_dacos_data_internal_typedef
246 typedef unsigned int VUINT32;
248 __declspec(align(16)) VUINT32 SgnBit[2][2];
249 __declspec(align(16)) VUINT32 OneHalf[2][2];
250 __declspec(align(16)) VUINT32 SmallNorm[2][2];
251 __declspec(align(16)) VUINT32 MOne[2][2];
252 __declspec(align(16)) VUINT32 Two[2][2];
253 __declspec(align(16)) VUINT32 sqrt_coeff[4][2][2];
254 __declspec(align(16)) VUINT32 poly_coeff[12][2][2];
255 __declspec(align(16)) VUINT32 PiH[2][2];
256 __declspec(align(16)) VUINT32 Pi2H[2][2];
257 } __svml_dacos_data_internal;
259 __svml_dacos_data_internal:
261 .quad 0x8000000000000000, 0x8000000000000000
264 .quad 0x3fe0000000000000, 0x3fe0000000000000
267 .quad 0x3000000000000000, 0x3000000000000000
270 .quad 0xbff0000000000000, 0xbff0000000000000
273 .quad 0x4000000000000000, 0x4000000000000000
276 .quad 0xbf918000993B24C3, 0xbf918000993B24C3 /* sqrt_coeff4 */
277 .quad 0x3fa400006F70D42D, 0x3fa400006F70D42D /* sqrt_coeff3 */
278 .quad 0xbfb7FFFFFFFFFE97, 0xbfb7FFFFFFFFFE97 /* sqrt_coeff2 */
279 .quad 0x3fcFFFFFFFFFFF9D, 0x3fcFFFFFFFFFFF9D /* sqrt_coeff1 */
282 .quad 0x3fa07520C70EB909, 0x3fa07520C70EB909 /* poly_coeff12 */
283 .quad 0xbf90FB17F7DBB0ED, 0xbf90FB17F7DBB0ED /* poly_coeff11 */
284 .quad 0x3f943F44BFBC3BAE, 0x3f943F44BFBC3BAE /* poly_coeff10 */
285 .quad 0x3f7A583395D45ED5, 0x3f7A583395D45ED5 /* poly_coeff9 */
286 .quad 0x3f88F8DC2AFCCAD6, 0x3f88F8DC2AFCCAD6 /* poly_coeff8 */
287 .quad 0x3f8C6DBBCB88BD57, 0x3f8C6DBBCB88BD57 /* poly_coeff7 */
288 .quad 0x3f91C6DCF538AD2E, 0x3f91C6DCF538AD2E /* poly_coeff6 */
289 .quad 0x3f96E89CEBDEFadd, 0x3f96E89CEBDEFadd /* poly_coeff5 */
290 .quad 0x3f9F1C72E13AD8BE, 0x3f9F1C72E13AD8BE /* poly_coeff4 */
291 .quad 0x3fa6DB6DB3B445F8, 0x3fa6DB6DB3B445F8 /* poly_coeff3 */
292 .quad 0x3fb333333337E0DE, 0x3fb333333337E0DE /* poly_coeff2 */
293 .quad 0x3fc555555555529C, 0x3fc555555555529C /* poly_coeff1 */
296 .quad 0x400921fb54442d18, 0x400921fb54442d18
299 .quad 0x3ff921fb54442d18, 0x3ff921fb54442d18
301 .type __svml_dacos_data_internal, @object
302 .size __svml_dacos_data_internal, .-__svml_dacos_data_internal