1 /* Function logf vectorized with AVX2.
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_s_logf_data.h"
23 ENTRY(_ZGVdN8v_logf_avx2)
25 ALGORITHM DESCRIPTION:
27 log(x) = exponent_x*log(2) + log(mantissa_x), if mantissa_x<4/3
28 log(x) = (exponent_x+1)*log(2) + log(0.5*mantissa_x), if mantissa_x>4/3
30 R = mantissa_x - 1, if mantissa_x<4/3
31 R = 0.5*mantissa_x - 1, if mantissa_x>4/3
34 log(1+R) is approximated as a polynomial: degree 9 for 1-ulp,
35 degree 7 for 4-ulp, degree 3 for half-precision. */
38 cfi_adjust_cfa_offset (8)
39 cfi_rel_offset (%rbp, 0)
41 cfi_def_cfa_register (%rbp)
44 movq __svml_slog_data@GOTPCREL(%rip), %rax
46 vmovups _iBrkValue(%rax), %ymm6
47 vmovups _iLoRange(%rax), %ymm1
48 /* check for working range,
49 set special argument mask (denormals/zero/Inf/NaN) */
50 vpaddd _iHiDelta(%rax), %ymm2, %ymm7
52 /* reduction: compute r,n */
53 vpsubd %ymm6, %ymm2, %ymm4
55 /* exponent_x (mantissa_x<4/3) or exponent_x+1 (mantissa_x>4/3) */
56 vpsrad $23, %ymm4, %ymm3
57 vpand _iOffExpoMask(%rax), %ymm4, %ymm5
58 vmovups _sPoly_7(%rax), %ymm4
59 vcvtdq2ps %ymm3, %ymm0
61 /* mantissa_x (mantissa_x<4/3), or 0.5*mantissa_x (mantissa_x>4/3) */
62 vpaddd %ymm6, %ymm5, %ymm3
64 /* reduced argument R */
65 vsubps _sOne(%rax), %ymm3, %ymm5
67 /* polynomial evaluation starts here */
68 vfmadd213ps _sPoly_6(%rax), %ymm5, %ymm4
69 vfmadd213ps _sPoly_5(%rax), %ymm5, %ymm4
70 vfmadd213ps _sPoly_4(%rax), %ymm5, %ymm4
71 vfmadd213ps _sPoly_3(%rax), %ymm5, %ymm4
72 vfmadd213ps _sPoly_2(%rax), %ymm5, %ymm4
73 vfmadd213ps _sPoly_1(%rax), %ymm5, %ymm4
74 vmulps %ymm5, %ymm4, %ymm6
76 /* polynomial evaluation end */
77 vfmadd213ps %ymm5, %ymm5, %ymm6
78 vpcmpgtd %ymm7, %ymm1, %ymm1
81 /* final reconstruction:
82 add exponent_value*log2 to polynomial result */
83 vfmadd132ps _sLn2(%rax), %ymm6, %ymm0
90 cfi_def_cfa_register (%rsp)
92 cfi_adjust_cfa_offset (-8)
98 vmovups %ymm2, 320(%rsp)
99 vmovups %ymm0, 384(%rsp)
104 vmovups %ymm8, 224(%rsp)
105 vmovups %ymm9, 192(%rsp)
106 vmovups %ymm10, 160(%rsp)
107 vmovups %ymm11, 128(%rsp)
108 vmovups %ymm12, 96(%rsp)
109 vmovups %ymm13, 64(%rsp)
110 vmovups %ymm14, 32(%rsp)
111 vmovups %ymm15, (%rsp)
115 cfi_offset_rel_rsp (12, 296)
118 cfi_offset_rel_rsp (13, 288)
121 cfi_offset_rel_rsp (14, 280)
124 cfi_offset_rel_rsp (15, 272)
142 vmovups 224(%rsp), %ymm8
143 vmovups 192(%rsp), %ymm9
144 vmovups 160(%rsp), %ymm10
145 vmovups 128(%rsp), %ymm11
146 vmovups 96(%rsp), %ymm12
147 vmovups 64(%rsp), %ymm13
148 vmovups 32(%rsp), %ymm14
149 vmovups (%rsp), %ymm15
150 vmovups 384(%rsp), %ymm0
166 vmovss 324(%rsp,%r15,8), %xmm0
171 vmovss %xmm0, 388(%rsp,%r15,8)
176 vmovss 320(%rsp,%r15,8), %xmm0
181 vmovss %xmm0, 384(%rsp,%r15,8)
184 END(_ZGVdN8v_logf_avx2)