Vector pow for x86_64 and tests.

Here is implementation of vectorized pow containing SSE, AVX,
AVX2 and AVX512 versions according to Vector ABI
<https://groups.google.com/forum/#!topic/x86-64-abi/LmppCfN1rZ4>.

  * bits/libm-simd-decl-stubs.h: Added stubs for pow.
    * math/bits/mathcalls.h: Added pow declaration with __MATHCALL_VEC.
    * sysdeps/unix/sysv/linux/x86_64/libmvec.abilist: New versions added.
    * sysdeps/x86/fpu/bits/math-vector.h: Added SIMD declaration and asm
    redirections for pow.
    * sysdeps/x86_64/fpu/Makefile (libmvec-support): Added new files.
    * sysdeps/x86_64/fpu/Versions: New versions added.
    * sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.
    * sysdeps/x86_64/fpu/multiarch/Makefile (libmvec-sysdep_routines): Added
    build of SSE, AVX2 and AVX512 IFUNC versions.
    * sysdeps/x86_64/fpu/svml_d_wrapper_impl.h: Added 2 argument wrappers.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow2_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow2_core_sse4.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow4_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow4_core_avx2.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow8_core.S: New file.
    * sysdeps/x86_64/fpu/multiarch/svml_d_pow8_core_avx512.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow2_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow4_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow4_core_avx.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow8_core.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow_data.S: New file.
    * sysdeps/x86_64/fpu/svml_d_pow_data.h: New file.
    * sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c: Added vector pow test.
    * sysdeps/x86_64/fpu/test-double-vlen2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-avx2.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen4.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8-wrappers.c: Likewise.
    * sysdeps/x86_64/fpu/test-double-vlen8.c: Likewise.
    * NEWS: Mention addition of x86_64 vector pow.
This commit is contained in:
Andrew Senkevich 2015-06-17 16:22:26 +03:00
parent 1663be053d
commit c10b9b13f7
31 changed files with 6934 additions and 4 deletions

View File

@ -1,5 +1,38 @@
2015-06-17 Andrew Senkevich <andrew.senkevich@intel.com>
* bits/libm-simd-decl-stubs.h: Added stubs for pow.
* math/bits/mathcalls.h: Added pow declaration with __MATHCALL_VEC.
* sysdeps/unix/sysv/linux/x86_64/libmvec.abilist: New versions added.
* sysdeps/x86/fpu/bits/math-vector.h: Added SIMD declaration and asm
redirections for pow.
* sysdeps/x86_64/fpu/Makefile (libmvec-support): Added new files.
* sysdeps/x86_64/fpu/Versions: New versions added.
* sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.
* sysdeps/x86_64/fpu/multiarch/Makefile (libmvec-sysdep_routines): Added
build of SSE, AVX2 and AVX512 IFUNC versions.
* sysdeps/x86_64/fpu/svml_d_wrapper_impl.h: Added 2 argument wrappers.
* sysdeps/x86_64/fpu/multiarch/svml_d_pow2_core.S: New file.
* sysdeps/x86_64/fpu/multiarch/svml_d_pow2_core_sse4.S: New file.
* sysdeps/x86_64/fpu/multiarch/svml_d_pow4_core.S: New file.
* sysdeps/x86_64/fpu/multiarch/svml_d_pow4_core_avx2.S: New file.
* sysdeps/x86_64/fpu/multiarch/svml_d_pow8_core.S: New file.
* sysdeps/x86_64/fpu/multiarch/svml_d_pow8_core_avx512.S: New file.
* sysdeps/x86_64/fpu/svml_d_pow2_core.S: New file.
* sysdeps/x86_64/fpu/svml_d_pow4_core.S: New file.
* sysdeps/x86_64/fpu/svml_d_pow4_core_avx.S: New file.
* sysdeps/x86_64/fpu/svml_d_pow8_core.S: New file.
* sysdeps/x86_64/fpu/svml_d_pow_data.S: New file.
* sysdeps/x86_64/fpu/svml_d_pow_data.h: New file.
* sysdeps/x86_64/fpu/test-double-vlen2-wrappers.c: Added vector pow test.
* sysdeps/x86_64/fpu/test-double-vlen2.c: Likewise.
* sysdeps/x86_64/fpu/test-double-vlen4-avx2-wrappers.c: Likewise.
* sysdeps/x86_64/fpu/test-double-vlen4-avx2.c: Likewise.
* sysdeps/x86_64/fpu/test-double-vlen4-wrappers.c: Likewise.
* sysdeps/x86_64/fpu/test-double-vlen4.c: Likewise.
* sysdeps/x86_64/fpu/test-double-vlen8-wrappers.c: Likewise.
* sysdeps/x86_64/fpu/test-double-vlen8.c: Likewise.
* NEWS: Mention addition of x86_64 vector pow.
* sysdeps/unix/sysv/linux/x86_64/libmvec.abilist: New symbols added.
* sysdeps/x86/fpu/bits/math-vector.h: Added SIMD declaration and asm
redirections for expf.

2
NEWS
View File

@ -53,7 +53,7 @@ Version 2.22
condition in some applications.
* Added vector math library named libmvec with the following vectorized x86_64
implementations: cos, cosf, sin, sinf, log, logf, exp, expf.
implementations: cos, cosf, sin, sinf, log, logf, exp, expf, pow.
The library can be disabled with --disable-mathvec. Use of the functions is
enabled with -fopenmp -ffast-math starting from -O1 for GCC version >= 4.9.0.
The library is linked in as needed when using -lm (no need to specify -lmvec

View File

@ -49,4 +49,7 @@
#define __DECL_SIMD_expf
#define __DECL_SIMD_expl
#define __DECL_SIMD_pow
#define __DECL_SIMD_powf
#define __DECL_SIMD_powl
#endif

View File

@ -150,7 +150,7 @@ __END_NAMESPACE_C99
_Mdouble_BEGIN_NAMESPACE
/* Return X to the Y power. */
__MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
__MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
/* Return the square root of X. */
__MATHCALL (sqrt,, (_Mdouble_ __x));

View File

@ -4,6 +4,7 @@ GLIBC_2.22
_ZGVbN2v_exp F
_ZGVbN2v_log F
_ZGVbN2v_sin F
_ZGVbN2vv_pow F
_ZGVbN4v_cosf F
_ZGVbN4v_expf F
_ZGVbN4v_logf F
@ -12,6 +13,7 @@ GLIBC_2.22
_ZGVcN4v_exp F
_ZGVcN4v_log F
_ZGVcN4v_sin F
_ZGVcN4vv_pow F
_ZGVcN8v_cosf F
_ZGVcN8v_expf F
_ZGVcN8v_logf F
@ -20,6 +22,7 @@ GLIBC_2.22
_ZGVdN4v_exp F
_ZGVdN4v_log F
_ZGVdN4v_sin F
_ZGVdN4vv_pow F
_ZGVdN8v_cosf F
_ZGVdN8v_expf F
_ZGVdN8v_logf F
@ -32,3 +35,4 @@ GLIBC_2.22
_ZGVeN8v_exp F
_ZGVeN8v_log F
_ZGVeN8v_sin F
_ZGVeN8vv_pow F

View File

@ -44,6 +44,8 @@
# define __DECL_SIMD_exp __DECL_SIMD_x86_64
# undef __DECL_SIMD_expf
# define __DECL_SIMD_expf __DECL_SIMD_x86_64
# undef __DECL_SIMD_pow
# define __DECL_SIMD_pow __DECL_SIMD_x86_64
/* Workaround to exclude unnecessary symbol aliases in libmvec
while GCC creates the vector names based on scalar asm name.
@ -65,6 +67,10 @@ __asm__ ("_ZGVbN4v___expf_finite = _ZGVbN4v_expf");
__asm__ ("_ZGVcN8v___expf_finite = _ZGVcN8v_expf");
__asm__ ("_ZGVdN8v___expf_finite = _ZGVdN8v_expf");
__asm__ ("_ZGVeN16v___expf_finite = _ZGVeN16v_expf");
__asm__ ("_ZGVbN2vv___pow_finite = _ZGVbN2vv_pow");
__asm__ ("_ZGVcN4vv___pow_finite = _ZGVcN4vv_pow");
__asm__ ("_ZGVdN4vv___pow_finite = _ZGVdN4vv_pow");
__asm__ ("_ZGVeN8vv___pow_finite = _ZGVeN8vv_pow");
# endif
#endif

View File

@ -13,7 +13,9 @@ libmvec-support += svml_d_cos2_core svml_d_cos4_core_avx \
svml_s_logf_data svml_d_exp2_core svml_d_exp4_core_avx \
svml_d_exp4_core svml_d_exp8_core svml_d_exp_data \
svml_s_expf4_core svml_s_expf8_core_avx svml_s_expf8_core \
svml_s_expf16_core svml_s_expf_data \
svml_s_expf16_core svml_s_expf_data svml_d_pow2_core \
svml_d_pow4_core_avx svml_d_pow4_core svml_d_pow8_core \
svml_d_pow_data \
init-arch
endif

View File

@ -4,6 +4,7 @@ libmvec {
_ZGVbN2v_sin; _ZGVcN4v_sin; _ZGVdN4v_sin; _ZGVeN8v_sin;
_ZGVbN2v_log; _ZGVcN4v_log; _ZGVdN4v_log; _ZGVeN8v_log;
_ZGVbN2v_exp; _ZGVcN4v_exp; _ZGVdN4v_exp; _ZGVeN8v_exp;
_ZGVbN2vv_pow; _ZGVcN4vv_pow; _ZGVdN4vv_pow; _ZGVeN8vv_pow;
_ZGVbN4v_cosf; _ZGVcN8v_cosf; _ZGVdN8v_cosf; _ZGVeN16v_cosf;
_ZGVbN4v_sinf; _ZGVcN8v_sinf; _ZGVdN8v_sinf; _ZGVeN16v_sinf;
_ZGVbN4v_logf; _ZGVcN8v_logf; _ZGVdN8v_logf; _ZGVeN16v_logf;

View File

@ -1947,6 +1947,18 @@ ifloat: 4
ildouble: 2
ldouble: 2
Function: "pow_vlen2":
double: 1
Function: "pow_vlen4":
double: 1
Function: "pow_vlen4_avx2":
double: 1
Function: "pow_vlen8":
double: 1
Function: "sin":
ildouble: 1
ldouble: 1

View File

@ -65,5 +65,6 @@ libmvec-sysdep_routines += svml_d_cos2_core_sse4 svml_d_cos4_core_avx2 \
svml_s_logf16_core_avx512 svml_d_exp2_core_sse4 \
svml_d_exp4_core_avx2 svml_d_exp8_core_avx512 \
svml_s_expf4_core_sse4 svml_s_expf8_core_avx2 \
svml_s_expf16_core_avx512
svml_s_expf16_core_avx512 svml_d_pow2_core_sse4 \
svml_d_pow4_core_avx2 svml_d_pow8_core_avx512
endif

View File

@ -0,0 +1,38 @@
/* Multiple versions of vectorized pow.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <init-arch.h>
.text
ENTRY (_ZGVbN2vv_pow)
.type _ZGVbN2vv_pow, @gnu_indirect_function
cmpl $0, KIND_OFFSET+__cpu_features(%rip)
jne 1f
call __init_cpu_features
1: leaq _ZGVbN2vv_pow_sse4(%rip), %rax
testl $bit_SSE4_1, __cpu_features+CPUID_OFFSET+index_SSE4_1(%rip)
jz 2f
ret
2: leaq _ZGVbN2vv_pow_sse2(%rip), %rax
ret
END (_ZGVbN2vv_pow)
libmvec_hidden_def (_ZGVbN2vv_pow)
#define _ZGVbN2vv_pow _ZGVbN2vv_pow_sse2
#include "../svml_d_pow2_core.S"

View File

@ -0,0 +1,432 @@
/* Function pow vectorized with SSE4.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include "svml_d_pow_data.h"
.text
ENTRY (_ZGVbN2vv_pow_sse4)
/*
ALGORITHM DESCRIPTION:
1) Calculating log2|x|
Here we use the following formula.
Let |x|=2^k1*X1, where k1 is integer, 1<=X1<2.
Let C ~= 1/ln(2),
Rcp1 ~= 1/X1, X2=Rcp1*X1,
Rcp2 ~= 1/X2, X3=Rcp2*X2,
Rcp3 ~= 1/X3, Rcp3C ~= C/X3.
Then
log2|x| = k1 + log2(1/Rcp1) + log2(1/Rcp2) + log2(C/Rcp3C) +
log2(X1*Rcp1*Rcp2*Rcp3C/C),
where X1*Rcp1*Rcp2*Rcp3C = C*(1+q), q is very small.
The values of Rcp1, log2(1/Rcp1), Rcp2, log2(1/Rcp2),
Rcp3C, log2(C/Rcp3C) are taken from tables.
Values of Rcp1, Rcp2, Rcp3C are such that RcpC=Rcp1*Rcp2*Rcp3C
is exactly represented in target precision.
log2(X1*Rcp1*Rcp2*Rcp3C/C) = log2(1+q) = ln(1+q)/ln2 =
= 1/(ln2)*q - 1/(2ln2)*q^2 + 1/(3ln2)*q^3 - ... =
= 1/(C*ln2)*cq - 1/(2*C^2*ln2)*cq^2 + 1/(3*C^3*ln2)*cq^3 - ... =
= (1 + a1)*cq + a2*cq^2 + a3*cq^3 + ...,
where cq = X1*Rcp1*Rcp2*Rcp3C-C,
a1=1/(C*ln(2))-1 is small,
a2=1/(2*C^2*ln2),
a3=1/(3*C^3*ln2),
...
We get 3 parts of log2 result: HH+HL+HLL ~= log2|x|.
2) Calculation of y*(HH+HL+HLL).
Split y into YHi+YLo.
Get high PH and medium PL parts of y*log2|x|.
Get low PLL part of y*log2|x|.
Now we have PH+PL+PLL ~= y*log2|x|.
3) Calculation of 2^(PH+PL+PLL).
Mathematical idea of computing 2^(PH+PL+PLL) is the following.
Let's represent PH+PL+PLL in the form N + j/2^expK + Z,
where expK=7 in this implementation, N and j are integers,
0<=j<=2^expK-1, |Z|<2^(-expK-1).
Hence 2^(PH+PL+PLL) ~= 2^N * 2^(j/2^expK) * 2^Z,
where 2^(j/2^expK) is stored in a table, and
2^Z ~= 1 + B1*Z + B2*Z^2 ... + B5*Z^5.
We compute 2^(PH+PL+PLL) as follows.
Break PH into PHH + PHL, where PHH = N + j/2^expK.
Z = PHL + PL + PLL
Exp2Poly = B1*Z + B2*Z^2 ... + B5*Z^5
Get 2^(j/2^expK) from table in the form THI+TLO.
Now we have 2^(PH+PL+PLL) ~= 2^N * (THI + TLO) * (1 + Exp2Poly).
Get significand of 2^(PH+PL+PLL) in the form ResHi+ResLo:
ResHi := THI
ResLo := THI * Exp2Poly + TLO
Get exponent ERes of the result:
Res := ResHi + ResLo:
Result := ex(Res) + N. */
pushq %rbp
cfi_adjust_cfa_offset (8)
cfi_rel_offset (%rbp, 0)
movq %rsp, %rbp
cfi_def_cfa_register (%rbp)
andq $-64, %rsp
subq $256, %rsp
movq __svml_dpow_data@GOTPCREL(%rip), %rdx
movups %xmm14, 80(%rsp)
movups %xmm9, 176(%rsp)
movaps %xmm1, %xmm9
pshufd $221, %xmm0, %xmm1
movq _iIndexMask(%rdx), %xmm14
movq _iIndexAdd(%rdx), %xmm6
/* i = (((Hi(x) & 0x000ffe00) + 0x00000200) >> 10); -> i = (b1..b11 + 1) / 2 */
pand %xmm1, %xmm14
paddd %xmm6, %xmm14
psrld $10, %xmm14
movups %xmm13, 96(%rsp)
/* Index for reciprocal table */
movdqa %xmm14, %xmm13
pslld $3, %xmm13
/* Index for log2 table */
pslld $4, %xmm14
movd %xmm13, %eax
movups %xmm10, 160(%rsp)
movups _iMantissaMask(%rdx), %xmm10
movslq %eax, %rax
/* x1 = x; Hi(x1) = (Hi(x1)&0x000fffff)|0x3ff00000 */
andps %xmm0, %xmm10
pextrd $1, %xmm13, %ecx
movslq %ecx, %rcx
movups %xmm0, (%rsp)
movdqa %xmm1, %xmm0
/* k = Hi(x); k = k - 0x3fe7fe00; k = k >> 20 */
movq _i3fe7fe00(%rdx), %xmm6
psubd %xmm6, %xmm0
movups _iHighMask(%rdx), %xmm6
psrad $20, %xmm0
movups %xmm15, 48(%rsp)
movups %xmm12, 112(%rsp)
orps _dbOne(%rdx), %xmm10
movsd 11712(%rdx,%rax), %xmm12
movd %xmm14, %r8d
movq _i2p20_2p19(%rdx), %xmm15
movhpd 11712(%rdx,%rcx), %xmm12
paddd %xmm15, %xmm0
pextrd $1, %xmm14, %r9d
/* x1Hi=x1; Lo(x1Hi)&=0xf8000000; x1Lo = x1-x1Hi */
movaps %xmm6, %xmm14
andps %xmm10, %xmm14
movaps %xmm10, %xmm15
subpd %xmm14, %xmm15
/* r1 = x1*rcp1 */
mulpd %xmm12, %xmm10
/* E = -r1+__fence(x1Hi*rcp1) */
mulpd %xmm12, %xmm14
/* E=E+x1Lo*rcp1 */
mulpd %xmm15, %xmm12
subpd %xmm10, %xmm14
pshufd $80, %xmm0, %xmm0
movslq %r8d, %r8
andps _iffffffff00000000(%rdx), %xmm0
subpd _db2p20_2p19(%rdx), %xmm0
addpd %xmm12, %xmm14
movslq %r9d, %r9
/* T_Rh_Eh = T_Rh + E */
movaps %xmm14, %xmm15
movups %xmm8, 208(%rsp)
movups 19968(%rdx,%r8), %xmm8
movups %xmm11, 144(%rsp)
movaps %xmm8, %xmm11
/* cq = c+r1 */
movups _LHN(%rdx), %xmm13
movhpd 19968(%rdx,%r9), %xmm11
addpd %xmm10, %xmm13
/* T = k + L1hi */
addpd %xmm0, %xmm11
/* T_Rh = T + cq */
movaps %xmm13, %xmm12
addpd %xmm11, %xmm12
addpd %xmm12, %xmm15
/* Rl = T-T_Rh; -> -Rh */
subpd %xmm12, %xmm11
/* HLL = T_Rh - T_Rh_Eh; -> -Eh */
subpd %xmm15, %xmm12
/* Rl=Rl+cq; */
addpd %xmm13, %xmm11
/* cq = cq + E */
addpd %xmm14, %xmm13
/* HLL+=E; -> El */
addpd %xmm14, %xmm12
/* HLL+=Rl */
addpd %xmm12, %xmm11
unpckhpd 19968(%rdx,%r9), %xmm8
/* T_Rh_Eh_HLLhi = T_Rh_Eh + HLL */
movaps %xmm15, %xmm14
/* HLL+=L1lo; */
addpd %xmm11, %xmm8
movups _clv_2(%rdx), %xmm11
/* HH = T_Rh_Eh_HLLhi; Lo(HH)&=0xf8000000 */
movaps %xmm6, %xmm12
/* HLL = HLL + (((((((a7)*cq+a6)*cq+a5)*cq+a4)*cq+a3)*cq+a2)*cq+a1)*cq */
mulpd %xmm13, %xmm11
addpd _clv_3(%rdx), %xmm11
mulpd %xmm13, %xmm11
addpd _clv_4(%rdx), %xmm11
mulpd %xmm13, %xmm11
addpd _clv_5(%rdx), %xmm11
mulpd %xmm13, %xmm11
addpd _clv_6(%rdx), %xmm11
mulpd %xmm13, %xmm11
addpd _clv_7(%rdx), %xmm11
mulpd %xmm11, %xmm13
addpd %xmm13, %xmm8
addpd %xmm8, %xmm14
/*
2^(y*(HH+HL+HLL)) starts here:
yH = y; Lo(yH)&=0xf8000000
*/
andps %xmm9, %xmm6
/* yL = y-yH; */
movaps %xmm9, %xmm11
subpd %xmm6, %xmm11
andps %xmm14, %xmm12
/* HLLhi = T_Rh_Eh_HLLhi - T_Rh_Eh */
movaps %xmm14, %xmm10
/* HL = T_Rh_Eh_HLLhi-HH; */
subpd %xmm12, %xmm14
subpd %xmm15, %xmm10
movq _HIDELTA(%rdx), %xmm2
/* pH = yH*HH; */
movaps %xmm6, %xmm13
movq _LORANGE(%rdx), %xmm3
paddd %xmm2, %xmm1
pcmpgtd %xmm1, %xmm3
/* pL=yL*HL+yH*HL; pL+=yL*HH; */
movaps %xmm11, %xmm1
mulpd %xmm14, %xmm1
mulpd %xmm14, %xmm6
mulpd %xmm12, %xmm13
mulpd %xmm11, %xmm12
addpd %xmm6, %xmm1
/* HLL = HLL - HLLhi */
subpd %xmm10, %xmm8
addpd %xmm12, %xmm1
/* pLL = y*HLL */
mulpd %xmm9, %xmm8
movups _db2p45_2p44(%rdx), %xmm11
/* pHH = pH + *(double*)&db2p45_2p44 */
movaps %xmm11, %xmm12
addpd %xmm13, %xmm12
/* t=pL+pLL; t+=pHL */
addpd %xmm8, %xmm1
movq _ABSMASK(%rdx), %xmm5
pshufd $221, %xmm9, %xmm4
pand %xmm5, %xmm4
movq _INF(%rdx), %xmm7
movdqa %xmm4, %xmm2
pcmpgtd %xmm7, %xmm2
pcmpeqd %xmm7, %xmm4
pshufd $136, %xmm12, %xmm7
por %xmm4, %xmm2
/* pHH = pHH - *(double*)&db2p45_2p44 */
subpd %xmm11, %xmm12
pshufd $221, %xmm13, %xmm10
por %xmm2, %xmm3
/* pHL = pH - pHH; */
subpd %xmm12, %xmm13
pand %xmm5, %xmm10
movq _DOMAINRANGE(%rdx), %xmm5
movdqa %xmm10, %xmm4
addpd %xmm1, %xmm13
pcmpgtd %xmm5, %xmm4
pcmpeqd %xmm5, %xmm10
por %xmm10, %xmm4
movq _jIndexMask(%rdx), %xmm6
por %xmm4, %xmm3
movmskps %xmm3, %eax
/* j = Lo(pHH)&0x0000007f */
pand %xmm7, %xmm6
movq _iOne(%rdx), %xmm3
/* _n = Lo(pHH);
_n = _n & 0xffffff80;
_n = _n >> 7;
Hi(_2n) = (0x3ff+_n)<<20; Lo(_2n) = 0; -> 2^n
*/
pslld $13, %xmm7
paddd %xmm3, %xmm7
pslld $4, %xmm6
movups _cev_1(%rdx), %xmm3
movaps %xmm13, %xmm4
mulpd %xmm13, %xmm3
/* T1 = ((double*)exp2_tbl)[ 2*j ] */
movd %xmm6, %r10d
pshufd $80, %xmm7, %xmm0
andps _ifff0000000000000(%rdx), %xmm0
addpd _cev_2(%rdx), %xmm3
mulpd %xmm13, %xmm3
addpd _cev_3(%rdx), %xmm3
mulpd %xmm13, %xmm3
movslq %r10d, %r10
andl $3, %eax
pextrd $1, %xmm6, %r11d
movslq %r11d, %r11
addpd _cev_4(%rdx), %xmm3
movsd 36416(%rdx,%r10), %xmm2
movhpd 36416(%rdx,%r11), %xmm2
mulpd %xmm2, %xmm0
mulpd %xmm3, %xmm13
mulpd %xmm0, %xmm4
addpd _cev_5(%rdx), %xmm13
mulpd %xmm4, %xmm13
addpd %xmm13, %xmm0
jne .LBL_1_3
.LBL_1_2:
cfi_remember_state
movups 208(%rsp), %xmm8
movups 176(%rsp), %xmm9
movups 160(%rsp), %xmm10
movups 144(%rsp), %xmm11
movups 112(%rsp), %xmm12
movups 96(%rsp), %xmm13
movups 80(%rsp), %xmm14
movups 48(%rsp), %xmm15
movq %rbp, %rsp
cfi_def_cfa_register (%rsp)
popq %rbp
cfi_adjust_cfa_offset (-8)
cfi_restore (%rbp)
ret
.LBL_1_3:
cfi_restore_state
movups (%rsp), %xmm1
movups %xmm1, 64(%rsp)
movups %xmm9, 128(%rsp)
movups %xmm0, 192(%rsp)
je .LBL_1_2
xorb %cl, %cl
xorl %edx, %edx
movq %rsi, 8(%rsp)
movq %rdi, (%rsp)
movq %r12, 40(%rsp)
cfi_offset_rel_rsp (12, 40)
movb %cl, %r12b
movq %r13, 32(%rsp)
cfi_offset_rel_rsp (13, 32)
movl %eax, %r13d
movq %r14, 24(%rsp)
cfi_offset_rel_rsp (14, 24)
movl %edx, %r14d
movq %r15, 16(%rsp)
cfi_offset_rel_rsp (15, 16)
cfi_remember_state
.LBL_1_6:
btl %r14d, %r13d
jc .LBL_1_12
.LBL_1_7:
lea 1(%r14), %esi
btl %esi, %r13d
jc .LBL_1_10
.LBL_1_8:
incb %r12b
addl $2, %r14d
cmpb $16, %r12b
jb .LBL_1_6
movq 8(%rsp), %rsi
movq (%rsp), %rdi
movq 40(%rsp), %r12
cfi_restore (%r12)
movq 32(%rsp), %r13
cfi_restore (%r13)
movq 24(%rsp), %r14
cfi_restore (%r14)
movq 16(%rsp), %r15
cfi_restore (%r15)
movups 192(%rsp), %xmm0
jmp .LBL_1_2
.LBL_1_10:
cfi_restore_state
movzbl %r12b, %r15d
shlq $4, %r15
movsd 72(%rsp,%r15), %xmm0
movsd 136(%rsp,%r15), %xmm1
call pow@PLT
movsd %xmm0, 200(%rsp,%r15)
jmp .LBL_1_8
.LBL_1_12:
movzbl %r12b, %r15d
shlq $4, %r15
movsd 64(%rsp,%r15), %xmm0
movsd 128(%rsp,%r15), %xmm1
call pow@PLT
movsd %xmm0, 192(%rsp,%r15)
jmp .LBL_1_7
END (_ZGVbN2vv_pow_sse4)

View File

@ -0,0 +1,38 @@
/* Multiple versions of vectorized pow.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <init-arch.h>
.text
ENTRY (_ZGVdN4vv_pow)
.type _ZGVdN4vv_pow, @gnu_indirect_function
cmpl $0, KIND_OFFSET+__cpu_features(%rip)
jne 1f
call __init_cpu_features
1: leaq _ZGVdN4vv_pow_avx2(%rip), %rax
testl $bit_AVX2_Usable, __cpu_features+FEATURE_OFFSET+index_AVX2_Usable(%rip)
jz 2f
ret
2: leaq _ZGVdN4vv_pow_sse_wrapper(%rip), %rax
ret
END (_ZGVdN4vv_pow)
libmvec_hidden_def (_ZGVdN4vv_pow)
#define _ZGVdN4vv_pow _ZGVdN4vv_pow_sse_wrapper
#include "../svml_d_pow4_core.S"

View File

@ -0,0 +1,387 @@
/* Function pow vectorized with AVX2.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include "svml_d_pow_data.h"
.text
ENTRY (_ZGVdN4vv_pow_avx2)
/*
ALGORITHM DESCRIPTION:
1) Calculating log2|x|
Here we use the following formula.
Let |x|=2^k1*X1, where k1 is integer, 1<=X1<2.
Let C ~= 1/ln(2),
Rcp1 ~= 1/X1, X2=Rcp1*X1,
Rcp2 ~= 1/X2, X3=Rcp2*X2,
Rcp3 ~= 1/X3, Rcp3C ~= C/X3.
Then
log2|x| = k1 + log2(1/Rcp1) + log2(1/Rcp2) + log2(C/Rcp3C) +
log2(X1*Rcp1*Rcp2*Rcp3C/C),
where X1*Rcp1*Rcp2*Rcp3C = C*(1+q), q is very small.
The values of Rcp1, log2(1/Rcp1), Rcp2, log2(1/Rcp2),
Rcp3C, log2(C/Rcp3C) are taken from tables.
Values of Rcp1, Rcp2, Rcp3C are such that RcpC=Rcp1*Rcp2*Rcp3C
is exactly represented in target precision.
log2(X1*Rcp1*Rcp2*Rcp3C/C) = log2(1+q) = ln(1+q)/ln2 =
= 1/(ln2)*q - 1/(2ln2)*q^2 + 1/(3ln2)*q^3 - ... =
= 1/(C*ln2)*cq - 1/(2*C^2*ln2)*cq^2 + 1/(3*C^3*ln2)*cq^3 - ... =
= (1 + a1)*cq + a2*cq^2 + a3*cq^3 + ...,
where cq = X1*Rcp1*Rcp2*Rcp3C-C,
a1=1/(C*ln(2))-1 is small,
a2=1/(2*C^2*ln2),
a3=1/(3*C^3*ln2),
...
We get 3 parts of log2 result: HH+HL+HLL ~= log2|x|.
2) Calculation of y*(HH+HL+HLL).
Split y into YHi+YLo.
Get high PH and medium PL parts of y*log2|x|.
Get low PLL part of y*log2|x|.
Now we have PH+PL+PLL ~= y*log2|x|.
3) Calculation of 2^(PH+PL+PLL).
Mathematical idea of computing 2^(PH+PL+PLL) is the following.
Let's represent PH+PL+PLL in the form N + j/2^expK + Z,
where expK=7 in this implementation, N and j are integers,
0<=j<=2^expK-1, |Z|<2^(-expK-1).
Hence 2^(PH+PL+PLL) ~= 2^N * 2^(j/2^expK) * 2^Z,
where 2^(j/2^expK) is stored in a table, and
2^Z ~= 1 + B1*Z + B2*Z^2 ... + B5*Z^5.
We compute 2^(PH+PL+PLL) as follows.
Break PH into PHH + PHL, where PHH = N + j/2^expK.
Z = PHL + PL + PLL
Exp2Poly = B1*Z + B2*Z^2 ... + B5*Z^5
Get 2^(j/2^expK) from table in the form THI+TLO.
Now we have 2^(PH+PL+PLL) ~= 2^N * (THI + TLO) * (1 + Exp2Poly).
Get significand of 2^(PH+PL+PLL) in the form ResHi+ResLo:
ResHi := THI
ResLo := THI * Exp2Poly + TLO
Get exponent ERes of the result:
Res := ResHi + ResLo:
Result := ex(Res) + N. */
pushq %rbp
cfi_adjust_cfa_offset (8)
cfi_rel_offset (%rbp, 0)
movq %rsp, %rbp
cfi_def_cfa_register (%rbp)
andq $-64, %rsp
subq $448, %rsp
movq __svml_dpow_data@GOTPCREL(%rip), %rax
vmovups %ymm11, 160(%rsp)
vmovups %ymm8, 224(%rsp)
vmovups %ymm10, 352(%rsp)
vmovups %ymm9, 384(%rsp)
vmovups %ymm13, 288(%rsp)
vmovapd %ymm1, %ymm11
vxorpd %ymm1, %ymm1, %ymm1
vextracti128 $1, %ymm0, %xmm5
vshufps $221, %xmm5, %xmm0, %xmm5
/* i = (((Hi(x) & 0x000ffe00) + 0x00000200) >> 10); -> i = (b1..b11 + 1) / 2 */
vandps _iIndexMask(%rax), %xmm5, %xmm3
vpaddd _iIndexAdd(%rax), %xmm3, %xmm6
vpsrld $10, %xmm6, %xmm8
/* Index for reciprocal table */
vpslld $3, %xmm8, %xmm9
/* Index for log2 table */
vpslld $4, %xmm8, %xmm6
/* x1 = x; Hi(x1) = (Hi(x1)&0x000fffff)|0x3ff00000 */
vandpd _iMantissaMask(%rax), %ymm0, %ymm4
vorpd _dbOne(%rax), %ymm4, %ymm13
vpcmpeqd %ymm4, %ymm4, %ymm4
vpcmpeqd %ymm8, %ymm8, %ymm8
/* k = Hi(x); k = k - 0x3fe7fe00; k = k >> 20 */
vpsubd _i3fe7fe00(%rax), %xmm5, %xmm3
vpaddd _HIDELTA(%rax), %xmm5, %xmm5
vextracti128 $1, %ymm11, %xmm7
vshufps $221, %xmm7, %xmm11, %xmm2
vpand _ABSMASK(%rax), %xmm2, %xmm10
vpcmpeqd %ymm2, %ymm2, %ymm2
vgatherdpd %ymm2, 11712(%rax,%xmm9), %ymm1
vmovups _LORANGE(%rax), %xmm7
vxorpd %ymm2, %ymm2, %ymm2
vgatherdpd %ymm4, 19968(%rax,%xmm6), %ymm2
vxorpd %ymm4, %ymm4, %ymm4
vgatherdpd %ymm8, 19976(%rax,%xmm6), %ymm4
vpsrad $20, %xmm3, %xmm6
vpaddd _i2p20_2p19(%rax), %xmm6, %xmm9
vpshufd $80, %xmm9, %xmm8
vpshufd $250, %xmm9, %xmm3
/* x1Hi=x1; Lo(x1Hi)&=0xf8000000; x1Lo = x1-x1Hi */
vandpd _iHighMask(%rax), %ymm13, %ymm9
vinserti128 $1, %xmm3, %ymm8, %ymm6
vandpd _iffffffff00000000(%rax), %ymm6, %ymm8
/* r1 = x1*rcp1 */
vmulpd %ymm1, %ymm13, %ymm6
vsubpd %ymm9, %ymm13, %ymm3
vsubpd _db2p20_2p19(%rax), %ymm8, %ymm8
/* cq = c+r1 */
vaddpd _LHN(%rax), %ymm6, %ymm13
/* E = -r1+__fence(x1Hi*rcp1) */
vfmsub213pd %ymm6, %ymm1, %ymm9
/* E=E+x1Lo*rcp1 */
vfmadd213pd %ymm9, %ymm1, %ymm3
/* T = k + L1hi */
vaddpd %ymm2, %ymm8, %ymm1
/* T_Rh = T + cq */
vaddpd %ymm13, %ymm1, %ymm8
/* Rl = T-T_Rh; -> -Rh */
vsubpd %ymm8, %ymm1, %ymm6
/* Rl=Rl+cq */
vaddpd %ymm6, %ymm13, %ymm1
/* T_Rh_Eh = T_Rh + E */
vaddpd %ymm3, %ymm8, %ymm6
/* cq = cq + E */
vaddpd %ymm3, %ymm13, %ymm13
/* HLL = T_Rh - T_Rh_Eh; -> -Eh */
vsubpd %ymm6, %ymm8, %ymm9
/* HLL+=E; -> El */
vaddpd %ymm9, %ymm3, %ymm2
/* HLL+=Rl */
vaddpd %ymm1, %ymm2, %ymm8
/* HLL+=L1lo */
vaddpd %ymm4, %ymm8, %ymm4
vmovupd _clv_2(%rax), %ymm8
/* HLL = HLL + (((((((a7)*cq+a6)*cq+a5)*cq+a4)*cq+a3)*cq+a2)*cq+a1)*cq */
vfmadd213pd _clv_3(%rax), %ymm13, %ymm8
vfmadd213pd _clv_4(%rax), %ymm13, %ymm8
vfmadd213pd _clv_5(%rax), %ymm13, %ymm8
vfmadd213pd _clv_6(%rax), %ymm13, %ymm8
vfmadd213pd _clv_7(%rax), %ymm13, %ymm8
vfmadd213pd %ymm4, %ymm13, %ymm8
/* T_Rh_Eh_HLLhi = T_Rh_Eh + HLL */
vaddpd %ymm8, %ymm6, %ymm9
/* HH = T_Rh_Eh_HLLhi; Lo(HH)&=0xf8000000 */
vandpd _iHighMask(%rax), %ymm9, %ymm2
/*
2^(y*(HH+HL+HLL)) starts here:
yH = y; Lo(yH)&=0xf8000000;
*/
vandpd _iHighMask(%rax), %ymm11, %ymm1
/* HLLhi = T_Rh_Eh_HLLhi - T_Rh_Eh */
vsubpd %ymm6, %ymm9, %ymm13
/* HL = T_Rh_Eh_HLLhi-HH */
vsubpd %ymm2, %ymm9, %ymm4
/* pH = yH*HH */
vmulpd %ymm2, %ymm1, %ymm9
/* HLL = HLL - HLLhi */
vsubpd %ymm13, %ymm8, %ymm6
/* yL = y-yH */
vsubpd %ymm1, %ymm11, %ymm8
vextracti128 $1, %ymm9, %xmm3
vshufps $221, %xmm3, %xmm9, %xmm13
vpand _ABSMASK(%rax), %xmm13, %xmm3
vpcmpgtd %xmm5, %xmm7, %xmm13
vpcmpgtd _INF(%rax), %xmm10, %xmm7
vpcmpeqd _INF(%rax), %xmm10, %xmm10
vpor %xmm10, %xmm7, %xmm7
vpor %xmm7, %xmm13, %xmm5
/* pL=yL*HL+yH*HL; pL+=yL*HH */
vmulpd %ymm4, %ymm8, %ymm7
vpcmpgtd _DOMAINRANGE(%rax), %xmm3, %xmm13
vpcmpeqd _DOMAINRANGE(%rax), %xmm3, %xmm10
vpor %xmm10, %xmm13, %xmm3
vpor %xmm3, %xmm5, %xmm13
vfmadd213pd %ymm7, %ymm4, %ymm1
/* pLL = y*HLL;
pHH = pH + *(double*)&db2p45_2p44
*/
vaddpd _db2p45_2p44(%rax), %ymm9, %ymm7
vmovmskps %xmm13, %ecx
vfmadd213pd %ymm1, %ymm2, %ymm8
/* t=pL+pLL; t+=pHL */
vfmadd231pd %ymm11, %ymm6, %ymm8
vextracti128 $1, %ymm7, %xmm1
vshufps $136, %xmm1, %xmm7, %xmm10
/* _n = Lo(pHH);
_n = _n & 0xffffff80;
_n = _n >> 7;
Hi(_2n) = (0x3ff+_n)<<20; Lo(_2n) = 0; -> 2^n
*/
vpslld $13, %xmm10, %xmm2
vpaddd _iOne(%rax), %xmm2, %xmm13
vpshufd $80, %xmm13, %xmm4
vpshufd $250, %xmm13, %xmm1
/* j = Lo(pHH)&0x0000007f */
vandps _jIndexMask(%rax), %xmm10, %xmm3
/* T1 = ((double*)exp2_tbl)[ 2*j ] */
vpcmpeqd %ymm10, %ymm10, %ymm10
vpslld $4, %xmm3, %xmm5
/* pHH = pHH - *(double*)&db2p45_2p44 */
vsubpd _db2p45_2p44(%rax), %ymm7, %ymm7
/* pHL = pH - pHH */
vsubpd %ymm7, %ymm9, %ymm9
vaddpd %ymm9, %ymm8, %ymm6
vinserti128 $1, %xmm1, %ymm4, %ymm2
vxorpd %ymm1, %ymm1, %ymm1
vgatherdpd %ymm10, 36416(%rax,%xmm5), %ymm1
vandpd _ifff0000000000000(%rax), %ymm2, %ymm13
vmovupd _cev_1(%rax), %ymm2
vmulpd %ymm1, %ymm13, %ymm1
vfmadd213pd _cev_2(%rax), %ymm6, %ymm2
vmulpd %ymm6, %ymm1, %ymm8
vfmadd213pd _cev_3(%rax), %ymm6, %ymm2
vfmadd213pd _cev_4(%rax), %ymm6, %ymm2
vfmadd213pd _cev_5(%rax), %ymm6, %ymm2
vfmadd213pd %ymm1, %ymm8, %ymm2
testl %ecx, %ecx
jne .LBL_1_3
.LBL_1_2:
cfi_remember_state
vmovups 224(%rsp), %ymm8
vmovups 384(%rsp), %ymm9
vmovups 352(%rsp), %ymm10
vmovups 160(%rsp), %ymm11
vmovups 288(%rsp), %ymm13
vmovdqa %ymm2, %ymm0
movq %rbp, %rsp
cfi_def_cfa_register (%rsp)
popq %rbp
cfi_adjust_cfa_offset (-8)
cfi_restore (%rbp)
ret
.LBL_1_3:
cfi_restore_state
vmovupd %ymm0, 192(%rsp)
vmovupd %ymm11, 256(%rsp)
vmovupd %ymm2, 320(%rsp)
je .LBL_1_2
xorb %dl, %dl
xorl %eax, %eax
vmovups %ymm12, 64(%rsp)
vmovups %ymm14, 32(%rsp)
vmovups %ymm15, (%rsp)
movq %rsi, 104(%rsp)
movq %rdi, 96(%rsp)
movq %r12, 136(%rsp)
cfi_offset_rel_rsp (12, 136)
movb %dl, %r12b
movq %r13, 128(%rsp)
cfi_offset_rel_rsp (13, 128)
movl %ecx, %r13d
movq %r14, 120(%rsp)
cfi_offset_rel_rsp (14, 120)
movl %eax, %r14d
movq %r15, 112(%rsp)
cfi_offset_rel_rsp (15, 112)
cfi_remember_state
.LBL_1_6:
btl %r14d, %r13d
jc .LBL_1_12
.LBL_1_7:
lea 1(%r14), %esi
btl %esi, %r13d
jc .LBL_1_10
.LBL_1_8:
incb %r12b
addl $2, %r14d
cmpb $16, %r12b
jb .LBL_1_6
vmovups 64(%rsp), %ymm12
vmovups 32(%rsp), %ymm14
vmovups (%rsp), %ymm15
vmovupd 320(%rsp), %ymm2
movq 104(%rsp), %rsi
movq 96(%rsp), %rdi
movq 136(%rsp), %r12
cfi_restore (%r12)
movq 128(%rsp), %r13
cfi_restore (%r13)
movq 120(%rsp), %r14
cfi_restore (%r14)
movq 112(%rsp), %r15
cfi_restore (%r15)
jmp .LBL_1_2
.LBL_1_10:
cfi_restore_state
movzbl %r12b, %r15d
shlq $4, %r15
vmovsd 200(%rsp,%r15), %xmm0
vmovsd 264(%rsp,%r15), %xmm1
vzeroupper
call pow@PLT
vmovsd %xmm0, 328(%rsp,%r15)
jmp .LBL_1_8
.LBL_1_12:
movzbl %r12b, %r15d
shlq $4, %r15
vmovsd 192(%rsp,%r15), %xmm0
vmovsd 256(%rsp,%r15), %xmm1
vzeroupper
call pow@PLT
vmovsd %xmm0, 320(%rsp,%r15)
jmp .LBL_1_7
END (_ZGVdN4vv_pow_avx2)

View File

@ -0,0 +1,39 @@
/* Multiple versions of vectorized pow.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include <init-arch.h>
.text
ENTRY (_ZGVeN8vv_pow)
.type _ZGVeN8vv_pow, @gnu_indirect_function
cmpl $0, KIND_OFFSET+__cpu_features(%rip)
jne 1
call __init_cpu_features
1: leaq _ZGVeN8vv_pow_skx(%rip), %rax
testl $bit_AVX512DQ_Usable, __cpu_features+FEATURE_OFFSET+index_AVX512DQ_Usable(%rip)
jnz 3
2: leaq _ZGVeN8vv_pow_knl(%rip), %rax
testl $bit_AVX512F_Usable, __cpu_features+FEATURE_OFFSET+index_AVX512F_Usable(%rip)
jnz 3
leaq _ZGVeN8vv_pow_avx2_wrapper(%rip), %rax
3: ret
END (_ZGVeN8vv_pow)
#define _ZGVeN8vv_pow _ZGVeN8vv_pow_avx2_wrapper
#include "../svml_d_pow8_core.S"

View File

@ -0,0 +1,741 @@
/* Function pow vectorized with AVX-512. KNL and SKX versions.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include "svml_d_pow_data.h"
#include "svml_d_wrapper_impl.h"
/* ALGORITHM DESCRIPTION:
1) Calculating log2|x|
Here we use the following formula.
Let |x|=2^k1*X1, where k1 is integer, 1<=X1<2.
Let C ~= 1/ln(2),
Rcp1 ~= 1/X1, X2=Rcp1*X1,
Rcp2 ~= 1/X2, X3=Rcp2*X2,
Rcp3 ~= 1/X3, Rcp3C ~= C/X3.
Then
log2|x| = k1 + log2(1/Rcp1) + log2(1/Rcp2) + log2(C/Rcp3C) +
log2(X1*Rcp1*Rcp2*Rcp3C/C),
where X1*Rcp1*Rcp2*Rcp3C = C*(1+q), q is very small.
The values of Rcp1, log2(1/Rcp1), Rcp2, log2(1/Rcp2),
Rcp3C, log2(C/Rcp3C) are taken from tables.
Values of Rcp1, Rcp2, Rcp3C are such that RcpC=Rcp1*Rcp2*Rcp3C
is exactly represented in target precision.
log2(X1*Rcp1*Rcp2*Rcp3C/C) = log2(1+q) = ln(1+q)/ln2 =
= 1/(ln2)*q - 1/(2ln2)*q^2 + 1/(3ln2)*q^3 - ... =
= 1/(C*ln2)*cq - 1/(2*C^2*ln2)*cq^2 + 1/(3*C^3*ln2)*cq^3 - ... =
= (1 + a1)*cq + a2*cq^2 + a3*cq^3 + ...,
where cq = X1*Rcp1*Rcp2*Rcp3C-C,
a1=1/(C*ln(2))-1 is small,
a2=1/(2*C^2*ln2),
a3=1/(3*C^3*ln2),
...
We get 3 parts of log2 result: HH+HL+HLL ~= log2|x|.
2) Calculation of y*(HH+HL+HLL).
Split y into YHi+YLo.
Get high PH and medium PL parts of y*log2|x|.
Get low PLL part of y*log2|x|.
Now we have PH+PL+PLL ~= y*log2|x|.
3) Calculation of 2^(PH+PL+PLL).
Mathematical idea of computing 2^(PH+PL+PLL) is the following.
Let's represent PH+PL+PLL in the form N + j/2^expK + Z,
where expK=7 in this implementation, N and j are integers,
0<=j<=2^expK-1, |Z|<2^(-expK-1).
Hence 2^(PH+PL+PLL) ~= 2^N * 2^(j/2^expK) * 2^Z,
where 2^(j/2^expK) is stored in a table, and
2^Z ~= 1 + B1*Z + B2*Z^2 ... + B5*Z^5.
We compute 2^(PH+PL+PLL) as follows.
Break PH into PHH + PHL, where PHH = N + j/2^expK.
Z = PHL + PL + PLL
Exp2Poly = B1*Z + B2*Z^2 ... + B5*Z^5
Get 2^(j/2^expK) from table in the form THI+TLO.
Now we have 2^(PH+PL+PLL) ~= 2^N * (THI + TLO) * (1 + Exp2Poly).
Get significand of 2^(PH+PL+PLL) in the form ResHi+ResLo:
ResHi := THI
ResLo := THI * Exp2Poly + TLO
Get exponent ERes of the result:
Res := ResHi + ResLo:
Result := ex(Res) + N. */
.text
ENTRY (_ZGVeN8vv_pow_knl)
#ifndef HAVE_AVX512_ASM_SUPPORT
WRAPPER_IMPL_AVX512_ff _ZGVdN4vv_pow
#else
pushq %rbp
cfi_adjust_cfa_offset (8)
cfi_rel_offset (%rbp, 0)
movq %rsp, %rbp
cfi_def_cfa_register (%rbp)
andq $-64, %rsp
subq $1344, %rsp
vpsrlq $32, %zmm0, %zmm13
vmovaps %zmm1, %zmm12
movq __svml_dpow_data@GOTPCREL(%rip), %rax
movl $255, %edx
vpmovqd %zmm13, %ymm10
vpsrlq $32, %zmm12, %zmm14
kmovw %edx, %k1
movl $-1, %ecx
vpmovqd %zmm14, %ymm15
/* x1 = x; Hi(x1) = (Hi(x1)&0x000fffff)|0x3ff00000 */
vmovups _dbOne(%rax), %zmm6
/* i = (((Hi(x) & 0x000ffe00) + 0x00000200) >> 10); -> i = (b1..b11 + 1) / 2 */
vmovaps %zmm10, %zmm5
/* k = Hi(x); k = k - 0x3fe7fe00; k = k >> 20 */
vpsubd _i3fe7fe00(%rax), %zmm10, %zmm14{%k1}
vpandd _iIndexMask(%rax), %zmm10, %zmm5{%k1}
vpsrad $20, %zmm14, %zmm14{%k1}
vpxord %zmm9, %zmm9, %zmm9
vpaddd _HIDELTA(%rax), %zmm10, %zmm3{%k1}
vpaddd _iIndexAdd(%rax), %zmm5, %zmm5{%k1}
vpxord %zmm7, %zmm7, %zmm7
vpaddd _i2p20_2p19(%rax), %zmm14, %zmm14{%k1}
vpcmpd $1, _LORANGE(%rax), %zmm3, %k2{%k1}
vpsrld $10, %zmm5, %zmm5{%k1}
vpandd _ABSMASK(%rax), %zmm15, %zmm2{%k1}
vpbroadcastd %ecx, %zmm1{%k2}{z}
/* Index for reciprocal table */
vpslld $3, %zmm5, %zmm8{%k1}
kxnorw %k2, %k2, %k2
vgatherdpd 11712(%rax,%ymm8), %zmm9{%k2}
vpmovzxdq %ymm14, %zmm10
/* Index for log2 table */
vpslld $4, %zmm5, %zmm13{%k1}
kxnorw %k2, %k2, %k2
vpsllq $32, %zmm10, %zmm3
vpxord %zmm8, %zmm8, %zmm8
vpcmpd $5, _INF(%rax), %zmm2, %k3{%k1}
vpbroadcastd %ecx, %zmm4{%k3}{z}
vpternlogq $248, _iMantissaMask(%rax), %zmm0, %zmm6
kxnorw %k3, %k3, %k3
vpternlogq $168, _iffffffff00000000(%rax), %zmm10, %zmm3
/* x1Hi=x1; Lo(x1Hi)&=0xf8000000; x1Lo = x1-x1Hi */
vpandq _iHighMask(%rax), %zmm6, %zmm2
vgatherdpd 19976(%rax,%ymm13), %zmm8{%k2}
vpord %zmm4, %zmm1, %zmm11{%k1}
vsubpd _db2p20_2p19(%rax), %zmm3, %zmm1
vsubpd %zmm2, %zmm6, %zmm5
/* r1 = x1*rcp1 */
vmulpd %zmm9, %zmm6, %zmm6
vgatherdpd 19968(%rax,%ymm13), %zmm7{%k3}
/* cq = c+r1 */
vaddpd _LHN(%rax), %zmm6, %zmm4
/* E = -r1+__fence(x1Hi*rcp1) */
vfmsub213pd %zmm6, %zmm9, %zmm2
/* T = k + L1hi */
vaddpd %zmm7, %zmm1, %zmm7
/* E=E+x1Lo*rcp1 */
vfmadd213pd %zmm2, %zmm9, %zmm5
/* T_Rh = T + cq */
vaddpd %zmm4, %zmm7, %zmm3
/* Rl = T-T_Rh; -> -Rh */
vsubpd %zmm3, %zmm7, %zmm9
/* Rl=Rl+cq */
vaddpd %zmm9, %zmm4, %zmm6
/* T_Rh_Eh = T_Rh + E */
vaddpd %zmm5, %zmm3, %zmm9
/* HLL = T_Rh - T_Rh_Eh; -> -Eh */
vsubpd %zmm9, %zmm3, %zmm2
/* cq = cq + E; */
vaddpd %zmm5, %zmm4, %zmm4
/* HLL+=E; -> El */
vaddpd %zmm2, %zmm5, %zmm1
vmovups _clv_2(%rax), %zmm5
/* HLL = HLL + (((((((a7)*cq+a6)*cq+a5)*cq+a4)*cq+a3)*cq+a2)*cq+a1)*cq */
vfmadd213pd _clv_3(%rax), %zmm4, %zmm5
/* HLL+=Rl */
vaddpd %zmm6, %zmm1, %zmm7
/* 2^(y*(HH+HL+HLL)) starts here:
yH = y; Lo(yH)&=0xf8000000
*/
vpandq _iHighMask(%rax), %zmm12, %zmm6
/* yL = y-yH */
vsubpd %zmm6, %zmm12, %zmm2
vfmadd213pd _clv_4(%rax), %zmm4, %zmm5
/* HLL+=L1lo */
vaddpd %zmm8, %zmm7, %zmm8
vfmadd213pd _clv_5(%rax), %zmm4, %zmm5
vfmadd213pd _clv_6(%rax), %zmm4, %zmm5
vfmadd213pd _clv_7(%rax), %zmm4, %zmm5
vfmadd213pd %zmm8, %zmm4, %zmm5
/* T_Rh_Eh_HLLhi = T_Rh_Eh + HLL */
vaddpd %zmm5, %zmm9, %zmm13
/* HLLhi = T_Rh_Eh_HLLhi - T_Rh_Eh */
vsubpd %zmm9, %zmm13, %zmm10
/* HLL = HLL - HLLhi */
vsubpd %zmm10, %zmm5, %zmm3
/* HH = T_Rh_Eh_HLLhi; Lo(HH)&=0xf8000000 */
vpandq _iHighMask(%rax), %zmm13, %zmm5
/* pH = yH*HH */
vmulpd %zmm5, %zmm6, %zmm1
/* HL = T_Rh_Eh_HLLhi-HH */
vsubpd %zmm5, %zmm13, %zmm4
vpsrlq $32, %zmm1, %zmm14
/* pLL = y*HLL;
pHH = pH + *(double*)&db2p45_2p44
*/
vaddpd _db2p45_2p44(%rax), %zmm1, %zmm10
vpmovqd %zmm14, %ymm15
vpandd _ABSMASK(%rax), %zmm15, %zmm14{%k1}
vpcmpd $5, _DOMAINRANGE(%rax), %zmm14, %k3{%k1}
/* T1 = ((double*)exp2_tbl)[ 2*j ] */
vpxord %zmm14, %zmm14, %zmm14
vpbroadcastd %ecx, %zmm13{%k3}{z}
vpord %zmm13, %zmm11, %zmm11{%k1}
vptestmd %zmm11, %zmm11, %k0{%k1}
/* pL=yL*HL+yH*HL; pL+=yL*HH */
vmulpd %zmm4, %zmm2, %zmm11
kmovw %k0, %ecx
vfmadd213pd %zmm11, %zmm4, %zmm6
/* pHH = pHH - *(double*)&db2p45_2p44 */
vsubpd _db2p45_2p44(%rax), %zmm10, %zmm11
vpmovqd %zmm10, %ymm4
movzbl %cl, %ecx
/* _n = Lo(pHH);
_n = _n & 0xffffff80;
_n = _n >> 7;
Hi(_2n) = (0x3ff+_n)<<20; Lo(_2n) = 0; -> 2^n
*/
vpslld $13, %zmm4, %zmm7{%k1}
/* j = Lo(pHH)&0x0000007f */
vpandd _jIndexMask(%rax), %zmm4, %zmm9{%k1}
vfmadd213pd %zmm6, %zmm5, %zmm2
/* pHL = pH - pHH */
vsubpd %zmm11, %zmm1, %zmm1
vpaddd _iOne(%rax), %zmm7, %zmm7{%k1}
/* t=pL+pLL; t+=pHL */
vfmadd231pd %zmm12, %zmm3, %zmm2
vpslld $4, %zmm9, %zmm9{%k1}
kxnorw %k1, %k1, %k1
vgatherdpd 36416(%rax,%ymm9), %zmm14{%k1}
vpmovzxdq %ymm7, %zmm8
vaddpd %zmm1, %zmm2, %zmm2
vmovups _cev_1(%rax), %zmm1
vpsllq $32, %zmm8, %zmm13
vpternlogq $168, _ifff0000000000000(%rax), %zmm8, %zmm13
vfmadd213pd _cev_2(%rax), %zmm2, %zmm1
vmulpd %zmm14, %zmm13, %zmm15
vfmadd213pd _cev_3(%rax), %zmm2, %zmm1
vmulpd %zmm2, %zmm15, %zmm3
vfmadd213pd _cev_4(%rax), %zmm2, %zmm1
vfmadd213pd _cev_5(%rax), %zmm2, %zmm1
vfmadd213pd %zmm15, %zmm3, %zmm1
testl %ecx, %ecx
jne .LBL_1_3
.LBL_1_2:
cfi_remember_state
vmovaps %zmm1, %zmm0
movq %rbp, %rsp
cfi_def_cfa_register (%rsp)
popq %rbp
cfi_adjust_cfa_offset (-8)
cfi_restore (%rbp)
ret
.LBL_1_3:
cfi_restore_state
vmovups %zmm0, 1152(%rsp)
vmovups %zmm12, 1216(%rsp)
vmovups %zmm1, 1280(%rsp)
je .LBL_1_2
xorb %dl, %dl
kmovw %k4, 1048(%rsp)
xorl %eax, %eax
kmovw %k5, 1040(%rsp)
kmovw %k6, 1032(%rsp)
kmovw %k7, 1024(%rsp)
vmovups %zmm16, 960(%rsp)
vmovups %zmm17, 896(%rsp)
vmovups %zmm18, 832(%rsp)
vmovups %zmm19, 768(%rsp)
vmovups %zmm20, 704(%rsp)
vmovups %zmm21, 640(%rsp)
vmovups %zmm22, 576(%rsp)
vmovups %zmm23, 512(%rsp)
vmovups %zmm24, 448(%rsp)
vmovups %zmm25, 384(%rsp)
vmovups %zmm26, 320(%rsp)
vmovups %zmm27, 256(%rsp)
vmovups %zmm28, 192(%rsp)
vmovups %zmm29, 128(%rsp)
vmovups %zmm30, 64(%rsp)
vmovups %zmm31, (%rsp)
movq %rsi, 1064(%rsp)
movq %rdi, 1056(%rsp)
movq %r12, 1096(%rsp)
cfi_offset_rel_rsp (12, 1096)
movb %dl, %r12b
movq %r13, 1088(%rsp)
cfi_offset_rel_rsp (13, 1088)
movl %ecx, %r13d
movq %r14, 1080(%rsp)
cfi_offset_rel_rsp (14, 1080)
movl %eax, %r14d
movq %r15, 1072(%rsp)
cfi_offset_rel_rsp (15, 1072)
cfi_remember_state
.LBL_1_6:
btl %r14d, %r13d
jc .LBL_1_12
.LBL_1_7:
lea 1(%r14), %esi
btl %esi, %r13d
jc .LBL_1_10
.LBL_1_8:
addb $1, %r12b
addl $2, %r14d
cmpb $16, %r12b
jb .LBL_1_6
kmovw 1048(%rsp), %k4
movq 1064(%rsp), %rsi
kmovw 1040(%rsp), %k5
movq 1056(%rsp), %rdi
kmovw 1032(%rsp), %k6
movq 1096(%rsp), %r12
cfi_restore (%r12)
movq 1088(%rsp), %r13
cfi_restore (%r13)
kmovw 1024(%rsp), %k7
vmovups 960(%rsp), %zmm16
vmovups 896(%rsp), %zmm17
vmovups 832(%rsp), %zmm18
vmovups 768(%rsp), %zmm19
vmovups 704(%rsp), %zmm20
vmovups 640(%rsp), %zmm21
vmovups 576(%rsp), %zmm22
vmovups 512(%rsp), %zmm23
vmovups 448(%rsp), %zmm24
vmovups 384(%rsp), %zmm25
vmovups 320(%rsp), %zmm26
vmovups 256(%rsp), %zmm27
vmovups 192(%rsp), %zmm28
vmovups 128(%rsp), %zmm29
vmovups 64(%rsp), %zmm30
vmovups (%rsp), %zmm31
movq 1080(%rsp), %r14
cfi_restore (%r14)
movq 1072(%rsp), %r15
cfi_restore (%r15)
vmovups 1280(%rsp), %zmm1
jmp .LBL_1_2
.LBL_1_10:
cfi_restore_state
movzbl %r12b, %r15d
shlq $4, %r15
vmovsd 1160(%rsp,%r15), %xmm0
vmovsd 1224(%rsp,%r15), %xmm1
call pow@PLT
vmovsd %xmm0, 1288(%rsp,%r15)
jmp .LBL_1_8
.LBL_1_12:
movzbl %r12b, %r15d
shlq $4, %r15
vmovsd 1152(%rsp,%r15), %xmm0
vmovsd 1216(%rsp,%r15), %xmm1
call pow@PLT
vmovsd %xmm0, 1280(%rsp,%r15)
jmp .LBL_1_7
#endif
END (_ZGVeN8vv_pow_knl)
ENTRY (_ZGVeN8vv_pow_skx)
#ifndef HAVE_AVX512_ASM_SUPPORT
WRAPPER_IMPL_AVX512_ff _ZGVdN4vv_pow
#else
pushq %rbp
cfi_adjust_cfa_offset (8)
cfi_rel_offset (%rbp, 0)
movq %rsp, %rbp
cfi_def_cfa_register (%rbp)
andq $-64, %rsp
subq $1344, %rsp
vpsrlq $32, %zmm0, %zmm10
kxnorw %k1, %k1, %k1
kxnorw %k2, %k2, %k2
kxnorw %k3, %k3, %k3
vpmovqd %zmm10, %ymm7
movq __svml_dpow_data@GOTPCREL(%rip), %rax
vmovaps %zmm1, %zmm6
vpsrlq $32, %zmm6, %zmm13
/* i = (((Hi(x) & 0x000ffe00) + 0x00000200) >> 10); -> i = (b1..b11 + 1) / 2 */
vpand _iIndexMask(%rax), %ymm7, %ymm15
vpaddd _HIDELTA(%rax), %ymm7, %ymm2
/* k = Hi(x); k = k - 0x3fe7fe00; k = k >> 20 */
vpsubd _i3fe7fe00(%rax), %ymm7, %ymm7
vmovdqu _ABSMASK(%rax), %ymm4
vmovdqu _LORANGE(%rax), %ymm3
/* x1 = x; Hi(x1) = (Hi(x1)&0x000fffff)|0x3ff00000 */
vmovups _dbOne(%rax), %zmm11
vmovdqu _INF(%rax), %ymm5
vpaddd _iIndexAdd(%rax), %ymm15, %ymm12
vpmovqd %zmm13, %ymm14
vpternlogq $248, _iMantissaMask(%rax), %zmm0, %zmm11
vpsrld $10, %ymm12, %ymm10
vpsrad $20, %ymm7, %ymm13
/* Index for reciprocal table */
vpslld $3, %ymm10, %ymm8
/* Index for log2 table */
vpslld $4, %ymm10, %ymm1
vpcmpgtd %ymm2, %ymm3, %ymm3
vpand %ymm4, %ymm14, %ymm2
vpaddd _i2p20_2p19(%rax), %ymm13, %ymm14
vpmovzxdq %ymm14, %zmm15
vpsllq $32, %zmm15, %zmm7
vpternlogq $168, _iffffffff00000000(%rax), %zmm15, %zmm7
vsubpd _db2p20_2p19(%rax), %zmm7, %zmm13
vpxord %zmm9, %zmm9, %zmm9
vgatherdpd 11712(%rax,%ymm8), %zmm9{%k1}
/* T1 = ((double*)exp2_tbl)[ 2*j ] */
kxnorw %k1, %k1, %k1
vpxord %zmm12, %zmm12, %zmm12
vpxord %zmm8, %zmm8, %zmm8
vgatherdpd 19968(%rax,%ymm1), %zmm12{%k2}
vgatherdpd 19976(%rax,%ymm1), %zmm8{%k3}
vmovups _iHighMask(%rax), %zmm1
/* x1Hi=x1; Lo(x1Hi)&=0xf8000000; x1Lo = x1-x1Hi */
vandpd %zmm1, %zmm11, %zmm10
vsubpd %zmm10, %zmm11, %zmm15
/* r1 = x1*rcp1 */
vmulpd %zmm9, %zmm11, %zmm11
/* E = -r1+__fence(x1Hi*rcp1) */
vfmsub213pd %zmm11, %zmm9, %zmm10
/* cq = c+r1 */
vaddpd _LHN(%rax), %zmm11, %zmm14
/* E=E+x1Lo*rcp1 */
vfmadd213pd %zmm10, %zmm9, %zmm15
/* T = k + L1hi */
vaddpd %zmm12, %zmm13, %zmm9
/* T_Rh = T + cq */
vaddpd %zmm14, %zmm9, %zmm11
/* T_Rh_Eh = T_Rh + E */
vaddpd %zmm15, %zmm11, %zmm13
/* Rl = T-T_Rh; -> -Rh */
vsubpd %zmm11, %zmm9, %zmm12
/* HLL = T_Rh - T_Rh_Eh; -> -Eh */
vsubpd %zmm13, %zmm11, %zmm9
/* Rl=Rl+cq */
vaddpd %zmm12, %zmm14, %zmm10
/* HLL+=E; -> El */
vaddpd %zmm9, %zmm15, %zmm7
/* HLL+=Rl */
vaddpd %zmm10, %zmm7, %zmm12
/* 2^(y*(HH+HL+HLL)) starts here:
yH = y; Lo(yH)&=0xf8000000
*/
vandpd %zmm1, %zmm6, %zmm7
/* HLL+=L1lo */
vaddpd %zmm8, %zmm12, %zmm12
/* cq = cq + E */
vaddpd %zmm15, %zmm14, %zmm8
vmovups _clv_2(%rax), %zmm14
/* HLL = HLL + (((((((a7)*cq+a6)*cq+a5)*cq+a4)*cq+a3)*cq+a2)*cq+a1)*cq */
vfmadd213pd _clv_3(%rax), %zmm8, %zmm14
vfmadd213pd _clv_4(%rax), %zmm8, %zmm14
vfmadd213pd _clv_5(%rax), %zmm8, %zmm14
vfmadd213pd _clv_6(%rax), %zmm8, %zmm14
vfmadd213pd _clv_7(%rax), %zmm8, %zmm14
vfmadd213pd %zmm12, %zmm8, %zmm14
/* yL = y-yH */
vsubpd %zmm7, %zmm6, %zmm8
/* T_Rh_Eh_HLLhi = T_Rh_Eh + HLL */
vaddpd %zmm14, %zmm13, %zmm15
/* HH = T_Rh_Eh_HLLhi; Lo(HH)&=0xf8000000 */
vandpd %zmm1, %zmm15, %zmm11
/* HLLhi = T_Rh_Eh_HLLhi - T_Rh_Eh */
vsubpd %zmm13, %zmm15, %zmm13
/* pH = yH*HH */
vmulpd %zmm11, %zmm7, %zmm9
/* HLL = HLL - HLLhi */
vsubpd %zmm13, %zmm14, %zmm12
/* HL = T_Rh_Eh_HLLhi-HH */
vsubpd %zmm11, %zmm15, %zmm10
vpsrlq $32, %zmm9, %zmm1
vmovdqu _DOMAINRANGE(%rax), %ymm13
vpmovqd %zmm1, %ymm1
vpand %ymm4, %ymm1, %ymm1
vpcmpgtd %ymm5, %ymm2, %ymm4
vpcmpeqd %ymm5, %ymm2, %ymm5
vpternlogd $254, %ymm5, %ymm4, %ymm3
vpcmpgtd %ymm13, %ymm1, %ymm2
vpcmpeqd %ymm13, %ymm1, %ymm4
vpternlogd $254, %ymm4, %ymm2, %ymm3
/* pLL = y*HLL */
vmovups _db2p45_2p44(%rax), %zmm2
/* pHH = pH + *(double*)&db2p45_2p44 */
vaddpd %zmm2, %zmm9, %zmm1
vpmovqd %zmm1, %ymm5
/* j = Lo(pHH)&0x0000007f */
vpand _jIndexMask(%rax), %ymm5, %ymm14
vpslld $4, %ymm14, %ymm15
vmovmskps %ymm3, %ecx
/* pL=yL*HL+yH*HL; pL+=yL*HH */
vmulpd %zmm10, %zmm8, %zmm3
vfmadd213pd %zmm3, %zmm10, %zmm7
vfmadd213pd %zmm7, %zmm11, %zmm8
/* _n = Lo(pHH)
_n = _n & 0xffffff80
_n = _n >> 7
Hi(_2n) = (0x3ff+_n)<<20; Lo(_2n) = 0; -> 2^n
*/
vpslld $13, %ymm5, %ymm7
/* t=pL+pLL; t+=pHL */
vfmadd231pd %zmm6, %zmm12, %zmm8
vpaddd _iOne(%rax), %ymm7, %ymm10
vpmovzxdq %ymm10, %zmm11
vpsllq $32, %zmm11, %zmm3
vpternlogq $168, _ifff0000000000000(%rax), %zmm11, %zmm3
/* pHH = pHH - *(double*)&db2p45_2p44 */
vsubpd %zmm2, %zmm1, %zmm11
vmovups _cev_1(%rax), %zmm2
/* pHL = pH - pHH */
vsubpd %zmm11, %zmm9, %zmm9
vaddpd %zmm9, %zmm8, %zmm8
vfmadd213pd _cev_2(%rax), %zmm8, %zmm2
vfmadd213pd _cev_3(%rax), %zmm8, %zmm2
vfmadd213pd _cev_4(%rax), %zmm8, %zmm2
vfmadd213pd _cev_5(%rax), %zmm8, %zmm2
vpxord %zmm4, %zmm4, %zmm4
vgatherdpd 36416(%rax,%ymm15), %zmm4{%k1}
vmulpd %zmm4, %zmm3, %zmm1
vmulpd %zmm8, %zmm1, %zmm12
vfmadd213pd %zmm1, %zmm12, %zmm2
testl %ecx, %ecx
jne .LBL_2_3
.LBL_2_2:
cfi_remember_state
vmovaps %zmm2, %zmm0
movq %rbp, %rsp
cfi_def_cfa_register (%rsp)
popq %rbp
cfi_adjust_cfa_offset (-8)
cfi_restore (%rbp)
ret
.LBL_2_3:
cfi_restore_state
vmovups %zmm0, 1152(%rsp)
vmovups %zmm6, 1216(%rsp)
vmovups %zmm2, 1280(%rsp)
je .LBL_2_2
xorb %dl, %dl
xorl %eax, %eax
kmovw %k4, 1048(%rsp)
kmovw %k5, 1040(%rsp)
kmovw %k6, 1032(%rsp)
kmovw %k7, 1024(%rsp)
vmovups %zmm16, 960(%rsp)
vmovups %zmm17, 896(%rsp)
vmovups %zmm18, 832(%rsp)
vmovups %zmm19, 768(%rsp)
vmovups %zmm20, 704(%rsp)
vmovups %zmm21, 640(%rsp)
vmovups %zmm22, 576(%rsp)
vmovups %zmm23, 512(%rsp)
vmovups %zmm24, 448(%rsp)
vmovups %zmm25, 384(%rsp)
vmovups %zmm26, 320(%rsp)
vmovups %zmm27, 256(%rsp)
vmovups %zmm28, 192(%rsp)
vmovups %zmm29, 128(%rsp)
vmovups %zmm30, 64(%rsp)
vmovups %zmm31, (%rsp)
movq %rsi, 1064(%rsp)
movq %rdi, 1056(%rsp)
movq %r12, 1096(%rsp)
cfi_offset_rel_rsp (12, 1096)
movb %dl, %r12b
movq %r13, 1088(%rsp)
cfi_offset_rel_rsp (13, 1088)
movl %ecx, %r13d
movq %r14, 1080(%rsp)
cfi_offset_rel_rsp (14, 1080)
movl %eax, %r14d
movq %r15, 1072(%rsp)
cfi_offset_rel_rsp (15, 1072)
cfi_remember_state
.LBL_2_6:
btl %r14d, %r13d
jc .LBL_2_12
.LBL_2_7:
lea 1(%r14), %esi
btl %esi, %r13d
jc .LBL_2_10
.LBL_2_8:
incb %r12b
addl $2, %r14d
cmpb $16, %r12b
jb .LBL_2_6
kmovw 1048(%rsp), %k4
kmovw 1040(%rsp), %k5
kmovw 1032(%rsp), %k6
kmovw 1024(%rsp), %k7
vmovups 960(%rsp), %zmm16
vmovups 896(%rsp), %zmm17
vmovups 832(%rsp), %zmm18
vmovups 768(%rsp), %zmm19
vmovups 704(%rsp), %zmm20
vmovups 640(%rsp), %zmm21
vmovups 576(%rsp), %zmm22
vmovups 512(%rsp), %zmm23
vmovups 448(%rsp), %zmm24
vmovups 384(%rsp), %zmm25
vmovups 320(%rsp), %zmm26
vmovups 256(%rsp), %zmm27
vmovups 192(%rsp), %zmm28
vmovups 128(%rsp), %zmm29
vmovups 64(%rsp), %zmm30
vmovups (%rsp), %zmm31
vmovups 1280(%rsp), %zmm2
movq 1064(%rsp), %rsi
movq 1056(%rsp), %rdi
movq 1096(%rsp), %r12
cfi_restore (%r12)
movq 1088(%rsp), %r13
cfi_restore (%r13)
movq 1080(%rsp), %r14
cfi_restore (%r14)
movq 1072(%rsp), %r15
cfi_restore (%r15)
jmp .LBL_2_2
.LBL_2_10:
cfi_restore_state
movzbl %r12b, %r15d
shlq $4, %r15
vmovsd 1224(%rsp,%r15), %xmm1
vzeroupper
vmovsd 1160(%rsp,%r15), %xmm0
call pow@PLT
vmovsd %xmm0, 1288(%rsp,%r15)
jmp .LBL_2_8
.LBL_2_12:
movzbl %r12b, %r15d
shlq $4, %r15
vmovsd 1216(%rsp,%r15), %xmm1
vzeroupper
vmovsd 1152(%rsp,%r15), %xmm0
call pow@PLT
vmovsd %xmm0, 1280(%rsp,%r15)
jmp .LBL_2_7
#endif
END (_ZGVeN8vv_pow_skx)

View File

@ -0,0 +1,29 @@
/* Function pow vectorized with SSE2.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include "svml_d_wrapper_impl.h"
.text
ENTRY (_ZGVbN2vv_pow)
WRAPPER_IMPL_SSE2_ff pow
END (_ZGVbN2vv_pow)
#ifndef USE_MULTIARCH
libmvec_hidden_def (_ZGVbN2vv_pow)
#endif

View File

@ -0,0 +1,29 @@
/* Function pow vectorized with AVX2, wrapper version.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include "svml_d_wrapper_impl.h"
.text
ENTRY (_ZGVdN4vv_pow)
WRAPPER_IMPL_AVX_ff _ZGVbN2vv_pow
END (_ZGVdN4vv_pow)
#ifndef USE_MULTIARCH
libmvec_hidden_def (_ZGVdN4vv_pow)
#endif

View File

@ -0,0 +1,25 @@
/* Function pow vectorized in AVX ISA as wrapper to SSE4 ISA version.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include "svml_d_wrapper_impl.h"
.text
ENTRY (_ZGVcN4vv_pow)
WRAPPER_IMPL_AVX_ff _ZGVbN2vv_pow
END (_ZGVcN4vv_pow)

View File

@ -0,0 +1,25 @@
/* Function pow vectorized with AVX-512. Wrapper to AVX2 version.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <sysdep.h>
#include "svml_d_wrapper_impl.h"
.text
ENTRY (_ZGVeN8vv_pow)
WRAPPER_IMPL_AVX512_ff _ZGVdN4vv_pow
END (_ZGVeN8vv_pow)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,104 @@
/* Offsets for data table for function pow.
Copyright (C) 2014-2015 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef D_POW_DATA_H
#define D_POW_DATA_H
#define _hsw_log2_table 0
#define _hsw_dTe 8256
#define _hsw_dMantMask 10304
#define _hsw_dOne 10368
#define _hsw_dCvtMask 10432
#define _hsw_dMinNorm 10496
#define _hsw_dMaxNorm 10560
#define _hsw_lRndBit 10624
#define _hsw_lRndMask 10688
#define _hsw_dc6 10752
#define _hsw_dc5 10816
#define _hsw_dc4 10880
#define _hsw_dc3 10944
#define _hsw_dc1 11008
#define _hsw_dc1h 11072
#define _hsw_dc2 11136
#define _hsw_dAbsMask 11200
#define _hsw_dDomainRange 11264
#define _hsw_dShifter 11328
#define _hsw_dIndexMask 11392
#define _hsw_dce4 11456
#define _hsw_dce3 11520
#define _hsw_dce2 11584
#define _hsw_dce1 11648
#define _rcp_t1 11712
#define _log2_t1 19968
#define _exp2_tbl 36416
#define _clv_1 38464
#define _clv_2 38528
#define _clv_3 38592
#define _clv_4 38656
#define _clv_5 38720
#define _clv_6 38784
#define _clv_7 38848
#define _cev_1 38912
#define _cev_2 38976
#define _cev_3 39040
#define _cev_4 39104
#define _cev_5 39168
#define _iMantissaMask 39232
#define _i3fe7fe0000000000 39296
#define _dbOne 39360
#define _iffffffff00000000 39424
#define _db2p20_2p19 39488
#define _iHighMask 39552
#define _LHN 39616
#define _ifff0000000000000 39680
#define _db2p45_2p44 39744
#define _NEG_INF 39808
#define _NEG_ZERO 39872
#define _d2pow52 39936
#define _d1div2pow111 40000
#define _HIDELTA 40064
#define _LORANGE 40128
#define _ABSMASK 40192
#define _INF 40256
#define _DOMAINRANGE 40320
#define _iIndexMask 40384
#define _iIndexAdd 40448
#define _i3fe7fe00 40512
#define _i2p20_2p19 40576
#define _iOne 40640
#define _jIndexMask 40704
.macro double_vector offset value
.if .-__svml_dpow_data != \offset
.err
.endif
.rept 8
.quad \value
.endr
.endm
.macro float_vector offset value
.if .-__svml_dpow_data != \offset
.err
.endif
.rept 16
.long \value
.endr
.endm
#endif

View File

@ -34,6 +34,26 @@
ret
.endm
/* 2 argument SSE2 ISA version as wrapper to scalar. */
.macro WRAPPER_IMPL_SSE2_ff callee
subq $56, %rsp
cfi_adjust_cfa_offset(56)
movaps %xmm0, (%rsp)
movaps %xmm1, 16(%rsp)
call \callee@PLT
movsd %xmm0, 32(%rsp)
movsd 8(%rsp), %xmm0
movsd 24(%rsp), %xmm1
call \callee@PLT
movsd 32(%rsp), %xmm1
movsd %xmm0, 40(%rsp)
unpcklpd %xmm0, %xmm1
movaps %xmm1, %xmm0
addq $56, %rsp
cfi_adjust_cfa_offset(-56)
ret
.endm
/* AVX/AVX2 ISA version as wrapper to SSE ISA version. */
.macro WRAPPER_IMPL_AVX callee
pushq %rbp
@ -60,6 +80,34 @@
ret
.endm
/* 2 argument AVX/AVX2 ISA version as wrapper to SSE ISA version. */
.macro WRAPPER_IMPL_AVX_ff callee
pushq %rbp
cfi_adjust_cfa_offset (8)
cfi_rel_offset (%rbp, 0)
movq %rsp, %rbp
cfi_def_cfa_register (%rbp)
andq $-32, %rsp
subq $64, %rsp
vextractf128 $1, %ymm0, 16(%rsp)
vextractf128 $1, %ymm1, (%rsp)
vzeroupper
call HIDDEN_JUMPTARGET(\callee)
vmovaps %xmm0, 32(%rsp)
vmovaps 16(%rsp), %xmm0
vmovaps (%rsp), %xmm1
call HIDDEN_JUMPTARGET(\callee)
vmovaps %xmm0, %xmm1
vmovaps 32(%rsp), %xmm0
vinsertf128 $1, %xmm1, %ymm0, %ymm0
movq %rbp, %rsp
cfi_def_cfa_register (%rsp)
popq %rbp
cfi_adjust_cfa_offset (-8)
cfi_restore (%rbp)
ret
.endm
/* AVX512 ISA version as wrapper to AVX2 ISA version. */
.macro WRAPPER_IMPL_AVX512 callee
pushq %rbp
@ -99,3 +147,65 @@
cfi_restore (%rbp)
ret
.endm
/* 2 argument AVX512 ISA version as wrapper to AVX2 ISA version. */
.macro WRAPPER_IMPL_AVX512_ff callee
pushq %rbp
cfi_adjust_cfa_offset (8)
cfi_rel_offset (%rbp, 0)
movq %rsp, %rbp
cfi_def_cfa_register (%rbp)
andq $-64, %rsp
subq $128, %rsp
/* Below is encoding for vmovaps %zmm0, (%rsp). */
.byte 0x62
.byte 0xf1
.byte 0x7c
.byte 0x48
.byte 0x29
.byte 0x04
.byte 0x24
/* Below is encoding for vmovaps %zmm1, 64(%rsp). */
.byte 0x62
.byte 0xf1
.byte 0x7c
.byte 0x48
.byte 0x29
.byte 0x4c
.byte 0x24
/* Below is encoding for vmovapd (%rsp), %ymm0. */
.byte 0xc5
.byte 0xfd
.byte 0x28
.byte 0x04
.byte 0x24
/* Below is encoding for vmovapd 64(%rsp), %ymm1. */
.byte 0xc5
.byte 0xfd
.byte 0x28
.byte 0x4c
.byte 0x24
.byte 0x40
call HIDDEN_JUMPTARGET(\callee)
/* Below is encoding for vmovapd 32(%rsp), %ymm0. */
.byte 0xc5
.byte 0xfd
.byte 0x28
.byte 0x44
.byte 0x24
.byte 0x20
/* Below is encoding for vmovapd 96(%rsp), %ymm1. */
.byte 0xc5
.byte 0xfd
.byte 0x28
.byte 0x4c
.byte 0x24
.byte 0x60
call HIDDEN_JUMPTARGET(\callee)
movq %rbp, %rsp
cfi_def_cfa_register (%rsp)
popq %rbp
cfi_adjust_cfa_offset (-8)
cfi_restore (%rbp)
ret
.endm

View File

@ -26,3 +26,4 @@ VECTOR_WRAPPER (WRAPPER_NAME (cos), _ZGVbN2v_cos)
VECTOR_WRAPPER (WRAPPER_NAME (sin), _ZGVbN2v_sin)
VECTOR_WRAPPER (WRAPPER_NAME (log), _ZGVbN2v_log)
VECTOR_WRAPPER (WRAPPER_NAME (exp), _ZGVbN2v_exp)
VECTOR_WRAPPER_ff (WRAPPER_NAME (pow), _ZGVbN2vv_pow)

View File

@ -22,5 +22,6 @@
#define TEST_VECTOR_sin 1
#define TEST_VECTOR_log 1
#define TEST_VECTOR_exp 1
#define TEST_VECTOR_pow 1
#include "libm-test.c"

View File

@ -29,3 +29,4 @@ VECTOR_WRAPPER (WRAPPER_NAME (cos), _ZGVdN4v_cos)
VECTOR_WRAPPER (WRAPPER_NAME (sin), _ZGVdN4v_sin)
VECTOR_WRAPPER (WRAPPER_NAME (log), _ZGVdN4v_log)
VECTOR_WRAPPER (WRAPPER_NAME (exp), _ZGVdN4v_exp)
VECTOR_WRAPPER_ff (WRAPPER_NAME (pow), _ZGVdN4vv_pow)

View File

@ -25,6 +25,7 @@
#define TEST_VECTOR_sin 1
#define TEST_VECTOR_log 1
#define TEST_VECTOR_exp 1
#define TEST_VECTOR_pow 1
#define REQUIRE_AVX2

View File

@ -26,3 +26,4 @@ VECTOR_WRAPPER (WRAPPER_NAME (cos), _ZGVcN4v_cos)
VECTOR_WRAPPER (WRAPPER_NAME (sin), _ZGVcN4v_sin)
VECTOR_WRAPPER (WRAPPER_NAME (log), _ZGVcN4v_log)
VECTOR_WRAPPER (WRAPPER_NAME (exp), _ZGVcN4v_exp)
VECTOR_WRAPPER_ff (WRAPPER_NAME (pow), _ZGVcN4vv_pow)

View File

@ -22,5 +22,6 @@
#define TEST_VECTOR_sin 1
#define TEST_VECTOR_log 1
#define TEST_VECTOR_exp 1
#define TEST_VECTOR_pow 1
#include "libm-test.c"

View File

@ -26,3 +26,4 @@ VECTOR_WRAPPER (WRAPPER_NAME (cos), _ZGVeN8v_cos)
VECTOR_WRAPPER (WRAPPER_NAME (sin), _ZGVeN8v_sin)
VECTOR_WRAPPER (WRAPPER_NAME (log), _ZGVeN8v_log)
VECTOR_WRAPPER (WRAPPER_NAME (exp), _ZGVeN8v_exp)
VECTOR_WRAPPER_ff (WRAPPER_NAME (pow), _ZGVeN8vv_pow)

View File

@ -22,6 +22,7 @@
#define TEST_VECTOR_sin 1
#define TEST_VECTOR_log 1
#define TEST_VECTOR_exp 1
#define TEST_VECTOR_pow 1
#define REQUIRE_AVX512F