1 /* Function logf vectorized with AVX-512. KNL and SKX versions.
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"
21 #include "svml_s_wrapper_impl.h"
24 ENTRY (_ZGVeN16v_logf_knl)
25 #ifndef HAVE_AVX512_ASM_SUPPORT
26 WRAPPER_IMPL_AVX512 _ZGVdN8v_logf
29 ALGORITHM DESCRIPTION:
31 log(x) = exponent_x*log(2) + log(mantissa_x), if mantissa_x<4/3
32 log(x) = (exponent_x+1)*log(2) + log(0.5*mantissa_x), if mantissa_x>4/3
34 R = mantissa_x - 1, if mantissa_x<4/3
35 R = 0.5*mantissa_x - 1, if mantissa_x>4/3
38 log(1+R) is approximated as a polynomial: degree 9 for 1-ulp,
39 degree 7 for 4-ulp, degree 3 for half-precision. */
42 cfi_adjust_cfa_offset (8)
43 cfi_rel_offset (%rbp, 0)
45 cfi_def_cfa_register (%rbp)
48 movq __svml_slog_data@GOTPCREL(%rip), %rax
51 /* reduction: compute r,n */
52 vpsubd _iBrkValue(%rax), %zmm0, %zmm2
53 vmovups _sPoly_7(%rax), %zmm7
54 vpandd _iOffExpoMask(%rax), %zmm2, %zmm3
56 /* exponent_x (mantissa_x<4/3) or exponent_x+1 (mantissa_x>4/3) */
57 vpsrad $23, %zmm2, %zmm4
59 /* check for working range,
60 set special argument mask (denormals/zero/Inf/NaN)
62 vpaddd _iHiDelta(%rax), %zmm0, %zmm1
64 /* mantissa_x (mantissa_x<4/3), or 0.5*mantissa_x (mantissa_x>4/3) */
65 vpaddd _iBrkValue(%rax), %zmm3, %zmm6
66 vpcmpd $1, _iLoRange(%rax), %zmm1, %k1
67 vcvtdq2ps {rn-sae}, %zmm4, %zmm1
69 /* reduced argument R */
70 vsubps _sOne(%rax), %zmm6, %zmm8
71 vpbroadcastd %ecx, %zmm5{%k1}{z}
73 /* polynomial evaluation starts here */
74 vfmadd213ps _sPoly_6(%rax), %zmm8, %zmm7
75 vptestmd %zmm5, %zmm5, %k0
77 vfmadd213ps _sPoly_5(%rax), %zmm8, %zmm7
78 vfmadd213ps _sPoly_4(%rax), %zmm8, %zmm7
79 vfmadd213ps _sPoly_3(%rax), %zmm8, %zmm7
80 vfmadd213ps _sPoly_2(%rax), %zmm8, %zmm7
81 vfmadd213ps _sPoly_1(%rax), %zmm8, %zmm7
82 vmulps %zmm8, %zmm7, %zmm9
84 /* polynomial evaluation end */
85 vfmadd213ps %zmm8, %zmm8, %zmm9
89 add exponent_value*log2 to polynomial result
91 vfmadd132ps _sLn2(%rax), %zmm9, %zmm1
99 cfi_def_cfa_register (%rsp)
101 cfi_adjust_cfa_offset (-8)
107 vmovups %zmm0, 1152(%rsp)
108 vmovups %zmm1, 1216(%rsp)
112 kmovw %k4, 1048(%rsp)
114 kmovw %k5, 1040(%rsp)
115 kmovw %k6, 1032(%rsp)
116 kmovw %k7, 1024(%rsp)
117 vmovups %zmm16, 960(%rsp)
118 vmovups %zmm17, 896(%rsp)
119 vmovups %zmm18, 832(%rsp)
120 vmovups %zmm19, 768(%rsp)
121 vmovups %zmm20, 704(%rsp)
122 vmovups %zmm21, 640(%rsp)
123 vmovups %zmm22, 576(%rsp)
124 vmovups %zmm23, 512(%rsp)
125 vmovups %zmm24, 448(%rsp)
126 vmovups %zmm25, 384(%rsp)
127 vmovups %zmm26, 320(%rsp)
128 vmovups %zmm27, 256(%rsp)
129 vmovups %zmm28, 192(%rsp)
130 vmovups %zmm29, 128(%rsp)
131 vmovups %zmm30, 64(%rsp)
132 vmovups %zmm31, (%rsp)
133 movq %rsi, 1064(%rsp)
134 movq %rdi, 1056(%rsp)
135 movq %r12, 1096(%rsp)
136 cfi_offset_rel_rsp (12, 1096)
138 movq %r13, 1088(%rsp)
139 cfi_offset_rel_rsp (13, 1088)
141 movq %r14, 1080(%rsp)
142 cfi_offset_rel_rsp (14, 1080)
144 movq %r15, 1072(%rsp)
145 cfi_offset_rel_rsp (15, 1072)
163 kmovw 1048(%rsp), %k4
164 movq 1064(%rsp), %rsi
165 kmovw 1040(%rsp), %k5
166 movq 1056(%rsp), %rdi
167 kmovw 1032(%rsp), %k6
168 movq 1096(%rsp), %r12
170 movq 1088(%rsp), %r13
172 kmovw 1024(%rsp), %k7
173 vmovups 960(%rsp), %zmm16
174 vmovups 896(%rsp), %zmm17
175 vmovups 832(%rsp), %zmm18
176 vmovups 768(%rsp), %zmm19
177 vmovups 704(%rsp), %zmm20
178 vmovups 640(%rsp), %zmm21
179 vmovups 576(%rsp), %zmm22
180 vmovups 512(%rsp), %zmm23
181 vmovups 448(%rsp), %zmm24
182 vmovups 384(%rsp), %zmm25
183 vmovups 320(%rsp), %zmm26
184 vmovups 256(%rsp), %zmm27
185 vmovups 192(%rsp), %zmm28
186 vmovups 128(%rsp), %zmm29
187 vmovups 64(%rsp), %zmm30
188 vmovups (%rsp), %zmm31
189 movq 1080(%rsp), %r14
191 movq 1072(%rsp), %r15
193 vmovups 1216(%rsp), %zmm1
199 vmovss 1156(%rsp,%r15,8), %xmm0
201 vmovss %xmm0, 1220(%rsp,%r15,8)
206 vmovss 1152(%rsp,%r15,8), %xmm0
208 vmovss %xmm0, 1216(%rsp,%r15,8)
211 END (_ZGVeN16v_logf_knl)
213 ENTRY (_ZGVeN16v_logf_skx)
214 #ifndef HAVE_AVX512_ASM_SUPPORT
215 WRAPPER_IMPL_AVX512 _ZGVdN8v_logf
218 ALGORITHM DESCRIPTION:
220 log(x) = exponent_x*log(2) + log(mantissa_x), if mantissa_x<4/3
221 log(x) = (exponent_x+1)*log(2) + log(0.5*mantissa_x), if mantissa_x>4/3
223 R = mantissa_x - 1, if mantissa_x<4/3
224 R = 0.5*mantissa_x - 1, if mantissa_x>4/3
227 log(1+R) is approximated as a polynomial: degree 9 for 1-ulp,
228 degree 7 for 4-ulp, degree 3 for half-precision. */
231 cfi_adjust_cfa_offset (8)
232 cfi_rel_offset (%rbp, 0)
234 cfi_def_cfa_register (%rbp)
237 movq __svml_slog_data@GOTPCREL(%rip), %rax
238 vmovups .L_2il0floatpacket.7(%rip), %zmm6
239 vmovups _iBrkValue(%rax), %zmm4
240 vmovups _sPoly_7(%rax), %zmm8
243 check for working range,
244 set special argument mask (denormals/zero/Inf/NaN)
246 vpaddd _iHiDelta(%rax), %zmm0, %zmm1
248 /* reduction: compute r,n */
249 vpsubd %zmm4, %zmm0, %zmm2
250 vpcmpd $5, _iLoRange(%rax), %zmm1, %k1
252 /* exponent_x (mantissa_x<4/3) or exponent_x+1 (mantissa_x>4/3) */
253 vpsrad $23, %zmm2, %zmm5
254 vpandd _iOffExpoMask(%rax), %zmm2, %zmm3
256 /* mantissa_x (mantissa_x<4/3), or 0.5*mantissa_x (mantissa_x>4/3) */
257 vpaddd %zmm4, %zmm3, %zmm7
259 /* reduced argument R */
260 vsubps _sOne(%rax), %zmm7, %zmm9
262 /* polynomial evaluation starts here */
263 vfmadd213ps _sPoly_6(%rax), %zmm9, %zmm8
264 vfmadd213ps _sPoly_5(%rax), %zmm9, %zmm8
265 vfmadd213ps _sPoly_4(%rax), %zmm9, %zmm8
266 vfmadd213ps _sPoly_3(%rax), %zmm9, %zmm8
267 vfmadd213ps _sPoly_2(%rax), %zmm9, %zmm8
268 vfmadd213ps _sPoly_1(%rax), %zmm9, %zmm8
269 vmulps %zmm9, %zmm8, %zmm10
271 /* polynomial evaluation end */
272 vfmadd213ps %zmm9, %zmm9, %zmm10
273 vpandnd %zmm1, %zmm1, %zmm6{%k1}
274 vptestmd %zmm6, %zmm6, %k0
275 vcvtdq2ps {rn-sae}, %zmm5, %zmm1
279 final reconstruction:
280 add exponent_value*log2 to polynomial result
282 vfmadd132ps _sLn2(%rax), %zmm10, %zmm1
290 cfi_def_cfa_register (%rsp)
292 cfi_adjust_cfa_offset (-8)
298 vmovups %zmm0, 1152(%rsp)
299 vmovups %zmm1, 1216(%rsp)
304 kmovw %k4, 1048(%rsp)
305 kmovw %k5, 1040(%rsp)
306 kmovw %k6, 1032(%rsp)
307 kmovw %k7, 1024(%rsp)
308 vmovups %zmm16, 960(%rsp)
309 vmovups %zmm17, 896(%rsp)
310 vmovups %zmm18, 832(%rsp)
311 vmovups %zmm19, 768(%rsp)
312 vmovups %zmm20, 704(%rsp)
313 vmovups %zmm21, 640(%rsp)
314 vmovups %zmm22, 576(%rsp)
315 vmovups %zmm23, 512(%rsp)
316 vmovups %zmm24, 448(%rsp)
317 vmovups %zmm25, 384(%rsp)
318 vmovups %zmm26, 320(%rsp)
319 vmovups %zmm27, 256(%rsp)
320 vmovups %zmm28, 192(%rsp)
321 vmovups %zmm29, 128(%rsp)
322 vmovups %zmm30, 64(%rsp)
323 vmovups %zmm31, (%rsp)
324 movq %rsi, 1064(%rsp)
325 movq %rdi, 1056(%rsp)
326 movq %r12, 1096(%rsp)
327 cfi_offset_rel_rsp (12, 1096)
329 movq %r13, 1088(%rsp)
330 cfi_offset_rel_rsp (13, 1088)
332 movq %r14, 1080(%rsp)
333 cfi_offset_rel_rsp (14, 1080)
335 movq %r15, 1072(%rsp)
336 cfi_offset_rel_rsp (15, 1072)
354 kmovw 1048(%rsp), %k4
355 kmovw 1040(%rsp), %k5
356 kmovw 1032(%rsp), %k6
357 kmovw 1024(%rsp), %k7
358 vmovups 960(%rsp), %zmm16
359 vmovups 896(%rsp), %zmm17
360 vmovups 832(%rsp), %zmm18
361 vmovups 768(%rsp), %zmm19
362 vmovups 704(%rsp), %zmm20
363 vmovups 640(%rsp), %zmm21
364 vmovups 576(%rsp), %zmm22
365 vmovups 512(%rsp), %zmm23
366 vmovups 448(%rsp), %zmm24
367 vmovups 384(%rsp), %zmm25
368 vmovups 320(%rsp), %zmm26
369 vmovups 256(%rsp), %zmm27
370 vmovups 192(%rsp), %zmm28
371 vmovups 128(%rsp), %zmm29
372 vmovups 64(%rsp), %zmm30
373 vmovups (%rsp), %zmm31
374 vmovups 1216(%rsp), %zmm1
375 movq 1064(%rsp), %rsi
376 movq 1056(%rsp), %rdi
377 movq 1096(%rsp), %r12
379 movq 1088(%rsp), %r13
381 movq 1080(%rsp), %r14
383 movq 1072(%rsp), %r15
390 vmovss 1156(%rsp,%r15,8), %xmm0
392 vmovss 1156(%rsp,%r15,8), %xmm0
396 vmovss %xmm0, 1220(%rsp,%r15,8)
401 vmovss 1152(%rsp,%r15,8), %xmm0
403 vmovss 1152(%rsp,%r15,8), %xmm0
407 vmovss %xmm0, 1216(%rsp,%r15,8)
411 END (_ZGVeN16v_logf_skx)
413 .section .rodata, "a"
414 .L_2il0floatpacket.7:
415 .long 0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff,0xffffffff
416 .type .L_2il0floatpacket.7,@object