1 /* Function expf vectorized with SSE4.
2 Copyright (C) 2014-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 #include "svml_s_expf_data.h"
23 ENTRY (_ZGVbN4v_expf_sse4)
25 ALGORITHM DESCRIPTION:
27 Argument representation:
28 M = rint(X*2^k/ln2) = 2^k*N+j
29 X = M*ln2/2^k + r = N*ln2 + ln2*(j/2^k) + r
30 then -ln2/2^(k+1) < r < ln2/2^(k+1)
36 exp(X) = exp(N*ln2 + ln2*(j/2^k) + r)
37 = 2^N * 2^(j/2^k) * exp(r)
38 2^N is calculated by bit manipulation
39 2^(j/2^k) is computed from table lookup
40 exp(r) is approximated by polynomial
42 The table lookup is skipped if k = 0.
43 For low accuracy approximation, exp(r) ~ 1 or 1+r. */
46 cfi_adjust_cfa_offset (8)
47 cfi_rel_offset (%rbp, 0)
49 cfi_def_cfa_register (%rbp)
53 movq __svml_sexp_data@GOTPCREL(%rip), %rax
54 movups __sInvLn2(%rax), %xmm0
56 /* m = x*2^k/ln2 + shifter */
58 movups __sShifter(%rax), %xmm6
59 movups __sLn2hi(%rax), %xmm4
62 /* n = m - shifter = rint(x*2^k/ln2) */
65 /* remove sign of x by "and" operation */
66 movdqu __iAbsMask(%rax), %xmm7
69 /* r = x-n*ln2_hi/2^k */
73 /* compare against threshold */
74 pcmpgtd __iDomainRange(%rax), %xmm7
75 movups __sLn2lo(%rax), %xmm1
77 /* set mask for overflow/underflow */
80 movups __sPC5(%rax), %xmm3
83 /* r = r-n*ln2_lo/2^k = x - n*ln2/2^k */
86 /* compute 2^N with "shift" */
87 movdqu __iBias(%rax), %xmm6
94 addps __sPC4(%rax), %xmm3
98 addps __sPC3(%rax), %xmm3
100 /* ((c5*r+c4)*r+c3)*r+c2 */
102 addps __sPC2(%rax), %xmm3
104 /* (((c5*r+c4)*r+c3)*r+c2)*r+c1 */
106 addps __sPC1(%rax), %xmm3
108 /* exp(r) = ((((c5*r+c4)*r+c3)*r+c2)*r+c1)*r+c0 */
110 addps __sPC0(%rax), %xmm7
120 cfi_def_cfa_register (%rsp)
122 cfi_adjust_cfa_offset (-8)
128 movups %xmm5, 192(%rsp)
129 movups %xmm0, 256(%rsp)
134 movups %xmm8, 112(%rsp)
135 movups %xmm9, 96(%rsp)
136 movups %xmm10, 80(%rsp)
137 movups %xmm11, 64(%rsp)
138 movups %xmm12, 48(%rsp)
139 movups %xmm13, 32(%rsp)
140 movups %xmm14, 16(%rsp)
141 movups %xmm15, (%rsp)
145 cfi_offset_rel_rsp (12, 168)
148 cfi_offset_rel_rsp (13, 160)
151 cfi_offset_rel_rsp (14, 152)
154 cfi_offset_rel_rsp (15, 144)
172 movups 112(%rsp), %xmm8
173 movups 96(%rsp), %xmm9
174 movups 80(%rsp), %xmm10
175 movups 64(%rsp), %xmm11
176 movups 48(%rsp), %xmm12
177 movups 32(%rsp), %xmm13
178 movups 16(%rsp), %xmm14
179 movups (%rsp), %xmm15
190 movups 256(%rsp), %xmm0
196 movss 196(%rsp,%r15,8), %xmm0
198 call JUMPTARGET(expf)
200 movss %xmm0, 260(%rsp,%r15,8)
205 movss 192(%rsp,%r15,8), %xmm0
207 call JUMPTARGET(expf)
209 movss %xmm0, 256(%rsp,%r15,8)
212 END (_ZGVbN4v_expf_sse4)