/*
* Copyright ( c ) 2016 , 2021 , Intel Corporation . All rights reserved .
* Copyright ( C ) 2021 THL A29 Limited , a Tencent company . All rights reserved .
* Intel Math Library ( LIBM ) Source Code
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
*
* This code is free software ; you can redistribute it and / or modify it
* under the terms of the GNU General Public License version 2 only , as
* published by the Free Software Foundation .
*
* This code 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 General Public License
* version 2 for more details ( a copy is included in the LICENSE file that
* accompanied this code ) .
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work ; if not , write to the Free Software Foundation ,
* Inc . , 51 Franklin St , Fifth Floor , Boston , MA 02110 - 1301 USA .
*
* Please contact Oracle , 500 Oracle Parkway , Redwood Shores , CA 94065 USA
* or visit www . oracle . com if you need additional information or have any
* questions .
*
*/
#include "precompiled.hpp"
#include "macroAssembler_x86.hpp"
#include "stubGenerator_x86_64.hpp"
/******************************************************************************/
// ALGORITHM DESCRIPTION - EXP()
// ---------------------
//
// Description:
// Let K = 64 (table size).
// x x/log(2) n
// e = 2 = 2 * T[j] * (1 + P(y))
// where
// x = m*log(2)/K + y, y in [-log(2)/K..log(2)/K]
// m = n*K + j, m,n,j - signed integer, j in [-K/2..K/2]
// j/K
// values of 2 are tabulated as T[j] = T_hi[j] ( 1 + T_lo[j]).
//
// P(y) is a minimax polynomial approximation of exp(x)-1
// on small interval [-log(2)/K..log(2)/K] (were calculated by Maple V).
//
// To avoid problems with arithmetic overflow and underflow,
// n n1 n2
// value of 2 is safely computed as 2 * 2 where n1 in [-BIAS/2..BIAS/2]
// where BIAS is a value of exponent bias.
//
// Special cases:
// exp(NaN) = NaN
// exp(+INF) = +INF
// exp(-INF) = 0
// exp(x) = 1 for subnormals
// for finite argument, only exp(0)=1 is exact
// For IEEE double
// if x > 709.782712893383973096 then exp(x) overflow
// if x < -745.133219101941108420 then exp(x) underflow
//
/******************************************************************************/
ATTRIBUTE_ALIGNED(16 ) juint _cv[] =
{
0 x652b82feUL, 0 x40571547UL, 0 x652b82feUL, 0 x40571547UL, 0 xfefa0000UL,
0 x3f862e42UL, 0 xfefa0000UL, 0 x3f862e42UL, 0 xbc9e3b3aUL, 0 x3d1cf79aUL,
0 xbc9e3b3aUL, 0 x3d1cf79aUL, 0 xfffffffeUL, 0 x3fdfffffUL, 0 xfffffffeUL,
0 x3fdfffffUL, 0 xe3289860UL, 0 x3f56c15cUL, 0 x555b9e25UL, 0 x3fa55555UL,
0 xc090cf0fUL, 0 x3f811115UL, 0 x55548ba1UL, 0 x3fc55555UL
};
ATTRIBUTE_ALIGNED(16 ) juint _mmask[] =
{
0 xffffffc0UL, 0 x00000000UL, 0 xffffffc0UL, 0 x00000000UL
};
ATTRIBUTE_ALIGNED(16 ) juint _bias[] =
{
0 x0000ffc0UL, 0 x00000000UL, 0 x0000ffc0UL, 0 x00000000UL
};
ATTRIBUTE_ALIGNED(16 ) juint _Tbl_addr[] =
{
0 x00000000UL, 0 x00000000UL, 0 x00000000UL, 0 x00000000UL, 0 x0e03754dUL,
0 x3cad7bbfUL, 0 x3e778060UL, 0 x00002c9aUL, 0 x3567f613UL, 0 x3c8cd252UL,
0 xd3158574UL, 0 x000059b0UL, 0 x61e6c861UL, 0 x3c60f74eUL, 0 x18759bc8UL,
0 x00008745UL, 0 x5d837b6cUL, 0 x3c979aa6UL, 0 x6cf9890fUL, 0 x0000b558UL,
0 x702f9cd1UL, 0 x3c3ebe3dUL, 0 x32d3d1a2UL, 0 x0000e3ecUL, 0 x1e63bcd8UL,
0 x3ca3516eUL, 0 xd0125b50UL, 0 x00011301UL, 0 x26f0387bUL, 0 x3ca4c554UL,
0 xaea92ddfUL, 0 x0001429aUL, 0 x62523fb6UL, 0 x3ca95153UL, 0 x3c7d517aUL,
0 x000172b8UL, 0 x3f1353bfUL, 0 x3c8b898cUL, 0 xeb6fcb75UL, 0 x0001a35bUL,
0 x3e3a2f5fUL, 0 x3c9aecf7UL, 0 x3168b9aaUL, 0 x0001d487UL, 0 x44a6c38dUL,
0 x3c8a6f41UL, 0 x88628cd6UL, 0 x0002063bUL, 0 xe3a8a894UL, 0 x3c968efdUL,
0 x6e756238UL, 0 x0002387aUL, 0 x981fe7f2UL, 0 x3c80472bUL, 0 x65e27cddUL,
0 x00026b45UL, 0 x6d09ab31UL, 0 x3c82f7e1UL, 0 xf51fdee1UL, 0 x00029e9dUL,
0 x720c0ab3UL, 0 x3c8b3782UL, 0 xa6e4030bUL, 0 x0002d285UL, 0 x4db0abb6UL,
0 x3c834d75UL, 0 x0a31b715UL, 0 x000306feUL, 0 x5dd3f84aUL, 0 x3c8fdd39UL,
0 xb26416ffUL, 0 x00033c08UL, 0 xcc187d29UL, 0 x3ca12f8cUL, 0 x373aa9caUL,
0 x000371a7UL, 0 x738b5e8bUL, 0 x3ca7d229UL, 0 x34e59ff6UL, 0 x0003a7dbUL,
0 xa72a4c6dUL, 0 x3c859f48UL, 0 x4c123422UL, 0 x0003dea6UL, 0 x259d9205UL,
0 x3ca8b846UL, 0 x21f72e29UL, 0 x0004160aUL, 0 x60c2ac12UL, 0 x3c4363edUL,
0 x6061892dUL, 0 x00044e08UL, 0 xdaa10379UL, 0 x3c6ecce1UL, 0 xb5c13cd0UL,
0 x000486a2UL, 0 xbb7aafb0UL, 0 x3c7690ceUL, 0 xd5362a27UL, 0 x0004bfdaUL,
0 x9b282a09UL, 0 x3ca083ccUL, 0 x769d2ca6UL, 0 x0004f9b2UL, 0 xc1aae707UL,
0 x3ca509b0UL, 0 x569d4f81UL, 0 x0005342bUL, 0 x18fdd78eUL, 0 x3c933505UL,
0 x36b527daUL, 0 x00056f47UL, 0 xe21c5409UL, 0 x3c9063e1UL, 0 xdd485429UL,
0 x0005ab07UL, 0 x2b64c035UL, 0 x3c9432e6UL, 0 x15ad2148UL, 0 x0005e76fUL,
0 x99f08c0aUL, 0 x3ca01284UL, 0 xb03a5584UL, 0 x0006247eUL, 0 x0073dc06UL,
0 x3c99f087UL, 0 x82552224UL, 0 x00066238UL, 0 x0da05571UL, 0 x3c998d4dUL,
0 x667f3bccUL, 0 x0006a09eUL, 0 x86ce4786UL, 0 x3ca52bb9UL, 0 x3c651a2eUL,
0 x0006dfb2UL, 0 x206f0dabUL, 0 x3ca32092UL, 0 xe8ec5f73UL, 0 x00071f75UL,
0 x8e17a7a6UL, 0 x3ca06122UL, 0 x564267c8UL, 0 x00075febUL, 0 x461e9f86UL,
0 x3ca244acUL, 0 x73eb0186UL, 0 x0007a114UL, 0 xabd66c55UL, 0 x3c65ebe1UL,
0 x36cf4e62UL, 0 x0007e2f3UL, 0 xbbff67d0UL, 0 x3c96fe9fUL, 0 x994cce12UL,
0 x00082589UL, 0 x14c801dfUL, 0 x3c951f14UL, 0 x9b4492ecUL, 0 x000868d9UL,
0 xc1f0eab4UL, 0 x3c8db72fUL, 0 x422aa0dbUL, 0 x0008ace5UL, 0 x59f35f44UL,
0 x3c7bf683UL, 0 x99157736UL, 0 x0008f1aeUL, 0 x9c06283cUL, 0 x3ca360baUL,
0 xb0cdc5e4UL, 0 x00093737UL, 0 x20f962aaUL, 0 x3c95e8d1UL, 0 x9fde4e4fUL,
0 x00097d82UL, 0 x2b91ce27UL, 0 x3c71affcUL, 0 x82a3f090UL, 0 x0009c491UL,
0 x589a2ebdUL, 0 x3c9b6d34UL, 0 x7b5de564UL, 0 x000a0c66UL, 0 x9ab89880UL,
0 x3c95277cUL, 0 xb23e255cUL, 0 x000a5503UL, 0 x6e735ab3UL, 0 x3c846984UL,
0 x5579fdbfUL, 0 x000a9e6bUL, 0 x92cb3387UL, 0 x3c8c1a77UL, 0 x995ad3adUL,
0 x000ae89fUL, 0 xdc2d1d96UL, 0 x3ca22466UL, 0 xb84f15faUL, 0 x000b33a2UL,
0 xb19505aeUL, 0 x3ca1112eUL, 0 xf2fb5e46UL, 0 x000b7f76UL, 0 x0a5fddcdUL,
0 x3c74ffd7UL, 0 x904bc1d2UL, 0 x000bcc1eUL, 0 x30af0cb3UL, 0 x3c736eaeUL,
0 xdd85529cUL, 0 x000c199bUL, 0 xd10959acUL, 0 x3c84e08fUL, 0 x2e57d14bUL,
0 x000c67f1UL, 0 x6c921968UL, 0 x3c676b2cUL, 0 xdcef9069UL, 0 x000cb720UL,
0 x36df99b3UL, 0 x3c937009UL, 0 x4a07897bUL, 0 x000d072dUL, 0 xa63d07a7UL,
0 x3c74a385UL, 0 xdcfba487UL, 0 x000d5818UL, 0 xd5c192acUL, 0 x3c8e5a50UL,
0 x03db3285UL, 0 x000da9e6UL, 0 x1c4a9792UL, 0 x3c98bb73UL, 0 x337b9b5eUL,
0 x000dfc97UL, 0 x603a88d3UL, 0 x3c74b604UL, 0 xe78b3ff6UL, 0 x000e502eUL,
0 x92094926UL, 0 x3c916f27UL, 0 xa2a490d9UL, 0 x000ea4afUL, 0 x41aa2008UL,
0 x3c8ec3bcUL, 0 xee615a27UL, 0 x000efa1bUL, 0 x31d185eeUL, 0 x3c8a64a9UL,
0 x5b6e4540UL, 0 x000f5076UL, 0 x4d91cd9dUL, 0 x3c77893bUL, 0 x819e90d8UL,
0 x000fa7c1UL
};
ATTRIBUTE_ALIGNED(16 ) juint _ALLONES[] =
{
0 xffffffffUL, 0 xffffffffUL, 0 xffffffffUL, 0 xffffffffUL
};
ATTRIBUTE_ALIGNED(16 ) juint _ebias[] =
{
0 x00000000UL, 0 x3ff00000UL, 0 x00000000UL, 0 x3ff00000UL
};
ATTRIBUTE_ALIGNED(4 ) juint _XMAX[] =
{
0 xffffffffUL, 0 x7fefffffUL
};
ATTRIBUTE_ALIGNED(4 ) juint _XMIN[] =
{
0 x00000000UL, 0 x00100000UL
};
ATTRIBUTE_ALIGNED(4 ) juint _INF[] =
{
0 x00000000UL, 0 x7ff00000UL
};
#define __ _masm->
address StubGenerator::generate_libmExp() {
StubCodeMark mark(this , "StubRoutines" , "libmExp" );
address start = __ pc();
Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2;
Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2;
Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2;
Label L_2TAG_PACKET_12_0_2, B1_3, B1_5;
address cv = (address)_cv;
address mmask = (address)_mmask;
address bias = (address)_bias;
address Tbl_addr = (address)_Tbl_addr;
address ALLONES = (address)_ALLONES;
address ebias = (address)_ebias;
address XMAX = (address)_XMAX;
address XMIN = (address)_XMIN;
address INF = (address)_INF;
__ enter(); // required for proper stackwalking of RuntimeStub frame
__ subq(rsp, 24 );
__ movsd(Address(rsp, 8 ), xmm0);
__ unpcklpd(xmm0, xmm0);
__ movdqu(xmm1, ExternalAddress(cv), r11 /*rscratch*/); // 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL
__ movdqu(xmm2, ExternalAddress(cv + 16 ), r11 /*rscratch*/); // 0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL
__ movdqu(xmm3, ExternalAddress(cv + 32 ), r11 /*rscratch*/); // 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL
__ movdqu(xmm6, ExternalAddress(SHIFTER), r11 /*rscratch*/); // 0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL
__ pextrw(rax, xmm0, 3 );
__ andl(rax, 32767 );
__ movl(rdx, 16527 );
__ subl(rdx, rax);
__ subl(rax, 15504 );
__ orl(rdx, rax);
__ cmpl(rdx, INT_MIN);
__ jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2);
__ mulpd(xmm1, xmm0);
__ addpd(xmm1, xmm6);
__ movapd(xmm7, xmm1);
__ subpd(xmm1, xmm6);
__ mulpd(xmm2, xmm1);
__ movdqu(xmm4, ExternalAddress(cv + 64 ), r11 /*rscratch*/); // 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL
__ mulpd(xmm3, xmm1);
__ movdqu(xmm5, ExternalAddress(cv + 80 ), r11 /*rscratch*/); // 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL
__ subpd(xmm0, xmm2);
__ movdl(rax, xmm7);
__ movl(rcx, rax);
__ andl(rcx, 63 );
__ shll(rcx, 4 );
__ sarl(rax, 6 );
__ movl(rdx, rax);
__ movdqu(xmm6, ExternalAddress(mmask), r11 /*rscratch*/); // 0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL
__ pand(xmm7, xmm6);
__ movdqu(xmm6, ExternalAddress(bias), r11 /*rscratch*/); // 0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL
__ paddq(xmm7, xmm6);
__ psllq(xmm7, 46 );
__ subpd(xmm0, xmm3);
__ lea(r11, ExternalAddress(Tbl_addr));
__ movdqu(xmm2, Address(rcx, r11));
__ mulpd(xmm4, xmm0);
__ movapd(xmm6, xmm0);
__ movapd(xmm1, xmm0);
__ mulpd(xmm6, xmm6);
__ mulpd(xmm0, xmm6);
__ addpd(xmm5, xmm4);
__ mulsd(xmm0, xmm6);
__ mulpd(xmm6, ExternalAddress(cv + 48 ), r11 /*rscratch*/); // 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL, 0x3fdfffffUL
__ addsd(xmm1, xmm2);
__ unpckhpd(xmm2, xmm2);
__ mulpd(xmm0, xmm5);
__ addsd(xmm1, xmm0);
__ por(xmm2, xmm7);
__ unpckhpd(xmm0, xmm0);
__ addsd(xmm0, xmm1);
__ addsd(xmm0, xmm6);
__ addl(rdx, 894 );
__ cmpl(rdx, 1916 );
__ jcc(Assembler::above, L_2TAG_PACKET_1_0_2);
__ mulsd(xmm0, xmm2);
__ addsd(xmm0, xmm2);
__ jmp(B1_5);
__ bind(L_2TAG_PACKET_1_0_2);
__ xorpd(xmm3, xmm3);
__ movdqu(xmm4, ExternalAddress(ALLONES), r11 /*rscratch*/); // 0xffffffffUL, 0xffffffffUL, 0xffffffffUL, 0xffffffffUL
__ movl(rdx, -1022 );
__ subl(rdx, rax);
__ movdl(xmm5, rdx);
__ psllq(xmm4, xmm5);
__ movl(rcx, rax);
__ sarl(rax, 1 );
__ pinsrw(xmm3, rax, 3 );
__ movdqu(xmm6, ExternalAddress(ebias), r11 /*rscratch*/); // 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3ff00000UL
__ psllq(xmm3, 4 );
__ psubd(xmm2, xmm3);
__ mulsd(xmm0, xmm2);
__ cmpl(rdx, 52 );
__ jcc(Assembler::greater, L_2TAG_PACKET_2_0_2);
__ pand(xmm4, xmm2);
__ paddd(xmm3, xmm6);
__ subsd(xmm2, xmm4);
__ addsd(xmm0, xmm2);
__ cmpl(rcx, 1023 );
__ jcc(Assembler::greaterEqual, L_2TAG_PACKET_3_0_2);
__ pextrw(rcx, xmm0, 3 );
__ andl(rcx, 32768 );
__ orl(rdx, rcx);
__ cmpl(rdx, 0 );
__ jcc(Assembler::equal, L_2TAG_PACKET_4_0_2);
__ movapd(xmm6, xmm0);
__ addsd(xmm0, xmm4);
__ mulsd(xmm0, xmm3);
__ pextrw(rcx, xmm0, 3 );
__ andl(rcx, 32752 );
__ cmpl(rcx, 0 );
__ jcc(Assembler::equal, L_2TAG_PACKET_5_0_2);
__ jmp(B1_5);
__ bind(L_2TAG_PACKET_5_0_2);
__ mulsd(xmm6, xmm3);
__ mulsd(xmm4, xmm3);
__ movdqu(xmm0, xmm6);
__ pxor(xmm6, xmm4);
__ psrad(xmm6, 31 );
__ pshufd(xmm6, xmm6, 85 );
__ psllq(xmm0, 1 );
__ psrlq(xmm0, 1 );
__ pxor(xmm0, xmm6);
__ psrlq(xmm6, 63 );
__ paddq(xmm0, xmm6);
__ paddq(xmm0, xmm4);
__ movl(Address(rsp, 0 ), 15 );
__ jmp(L_2TAG_PACKET_6_0_2);
__ bind(L_2TAG_PACKET_4_0_2);
__ addsd(xmm0, xmm4);
__ mulsd(xmm0, xmm3);
__ jmp(B1_5);
__ bind(L_2TAG_PACKET_3_0_2);
__ addsd(xmm0, xmm4);
__ mulsd(xmm0, xmm3);
__ pextrw(rcx, xmm0, 3 );
__ andl(rcx, 32752 );
__ cmpl(rcx, 32752 );
__ jcc(Assembler::aboveEqual, L_2TAG_PACKET_7_0_2);
__ jmp(B1_5);
__ bind(L_2TAG_PACKET_2_0_2);
__ paddd(xmm3, xmm6);
__ addpd(xmm0, xmm2);
__ mulsd(xmm0, xmm3);
__ movl(Address(rsp, 0 ), 15 );
__ jmp(L_2TAG_PACKET_6_0_2);
__ bind(L_2TAG_PACKET_8_0_2);
__ cmpl(rax, 2146435072 );
__ jcc(Assembler::aboveEqual, L_2TAG_PACKET_9_0_2);
__ movl(rax, Address(rsp, 12 ));
__ cmpl(rax, INT_MIN);
__ jcc(Assembler::aboveEqual, L_2TAG_PACKET_10_0_2);
__ movsd(xmm0, ExternalAddress(XMAX), r11 /*rscratch*/); // 0xffffffffUL, 0x7fefffffUL
__ mulsd(xmm0, xmm0);
__ bind(L_2TAG_PACKET_7_0_2);
__ movl(Address(rsp, 0 ), 14 );
__ jmp(L_2TAG_PACKET_6_0_2);
__ bind(L_2TAG_PACKET_10_0_2);
__ movsd(xmm0, ExternalAddress(XMIN), r11 /*rscratch*/); // 0x00000000UL, 0x00100000UL
__ mulsd(xmm0, xmm0);
__ movl(Address(rsp, 0 ), 15 );
__ jmp(L_2TAG_PACKET_6_0_2);
__ bind(L_2TAG_PACKET_9_0_2);
__ movl(rdx, Address(rsp, 8 ));
__ cmpl(rax, 2146435072 );
__ jcc(Assembler::above, L_2TAG_PACKET_11_0_2);
__ cmpl(rdx, 0 );
__ jcc(Assembler::notEqual, L_2TAG_PACKET_11_0_2);
__ movl(rax, Address(rsp, 12 ));
__ cmpl(rax, 2146435072 );
__ jcc(Assembler::notEqual, L_2TAG_PACKET_12_0_2);
__ movsd(xmm0, ExternalAddress(INF), r11 /*rscratch*/); // 0x00000000UL, 0x7ff00000UL
__ jmp(B1_5);
__ bind(L_2TAG_PACKET_12_0_2);
__ movsd(xmm0, ExternalAddress(ZERO), r11 /*rscratch*/); // 0x00000000UL, 0x00000000UL
__ jmp(B1_5);
__ bind(L_2TAG_PACKET_11_0_2);
__ movsd(xmm0, Address(rsp, 8 ));
__ addsd(xmm0, xmm0);
__ jmp(B1_5);
__ bind(L_2TAG_PACKET_0_0_2);
__ movl(rax, Address(rsp, 12 ));
__ andl(rax, 2147483647 );
__ cmpl(rax, 1083179008 );
__ jcc(Assembler::aboveEqual, L_2TAG_PACKET_8_0_2);
__ movsd(Address(rsp, 8 ), xmm0);
__ addsd(xmm0, ExternalAddress(ONE), r11 /*rscratch*/); // 0x00000000UL, 0x3ff00000UL
__ jmp(B1_5);
__ bind(L_2TAG_PACKET_6_0_2);
__ movq(Address(rsp, 16 ), xmm0);
__ bind(B1_3);
__ movq(xmm0, Address(rsp, 16 ));
__ bind(B1_5);
__ addq(rsp, 24 );
__ leave(); // required for proper stackwalking of RuntimeStub frame
__ ret(0 );
return start;
}
#undef __
Messung V0.5 in Prozent C=100 H=100 G=100
¤ Dauer der Verarbeitung: 0.6 Sekunden
¤
*© Formatika GbR, Deutschland