2007-09-28 Patrick Mansfield <patmans@us.ibm.com>

* libm/machine/spu/headers/dom_chkd_less_than.h: New file.
	* libm/machine/spu/headers/dom_chkd_negone_one.h: Ditto.
	* libm/machine/spu/headers/dom_chkf_less_than.h: Ditto.
	* libm/machine/spu/headers/dom_chkf_negone_one.h: Ditto.
	* libm/machine/spu/headers/acos.h: Add domain check.
	* libm/machine/spu/headers/acosf.h: Ditto.
	* libm/machine/spu/headers/acosh.h: Ditto.
	* libm/machine/spu/headers/acoshf.h: Ditto.
	* libm/machine/spu/headers/asin.h: Ditto.
	* libm/machine/spu/headers/asinf.h: Ditto.
	* libm/machine/spu/headers/atanh.h: Ditto.
	* libm/machine/spu/headers/atanhf.h: Ditto.
	* libm/machine/spu/headers/fmod.h: Ditto.
	* libm/machine/spu/headers/fmodf.h: Ditto.
	* libm/machine/spu/headers/log.h: Ditto.
	* libm/machine/spu/headers/log10.h: Ditto.
	* libm/machine/spu/headers/log1p.h: Ditto.
	* libm/machine/spu/headers/log1pf.h: Ditto.
	* libm/machine/spu/headers/log2.h: Ditto.
	* libm/machine/spu/headers/log2f.h: Ditto.
	* libm/machine/spu/headers/sqrt.h: Ditto.
	* libm/machine/spu/headers/sqrtf.h: Ditto.
	* libm/machine/spu/headers/tgamma.h: Ditto.
	* libm/machine/spu/headers/tgammaf.h: Ditto.
This commit is contained in:
Jeff Johnston 2007-09-28 18:58:10 +00:00
parent e30a7b84aa
commit 1671fbe1ca
25 changed files with 541 additions and 17 deletions

View File

@ -1,3 +1,30 @@
2007-09-28 Patrick Mansfield <patmans@us.ibm.com>
* libm/machine/spu/headers/dom_chkd_less_than.h: New file.
* libm/machine/spu/headers/dom_chkd_negone_one.h: Ditto.
* libm/machine/spu/headers/dom_chkf_less_than.h: Ditto.
* libm/machine/spu/headers/dom_chkf_negone_one.h: Ditto.
* libm/machine/spu/headers/acos.h: Add domain check.
* libm/machine/spu/headers/acosf.h: Ditto.
* libm/machine/spu/headers/acosh.h: Ditto.
* libm/machine/spu/headers/acoshf.h: Ditto.
* libm/machine/spu/headers/asin.h: Ditto.
* libm/machine/spu/headers/asinf.h: Ditto.
* libm/machine/spu/headers/atanh.h: Ditto.
* libm/machine/spu/headers/atanhf.h: Ditto.
* libm/machine/spu/headers/fmod.h: Ditto.
* libm/machine/spu/headers/fmodf.h: Ditto.
* libm/machine/spu/headers/log.h: Ditto.
* libm/machine/spu/headers/log10.h: Ditto.
* libm/machine/spu/headers/log1p.h: Ditto.
* libm/machine/spu/headers/log1pf.h: Ditto.
* libm/machine/spu/headers/log2.h: Ditto.
* libm/machine/spu/headers/log2f.h: Ditto.
* libm/machine/spu/headers/sqrt.h: Ditto.
* libm/machine/spu/headers/sqrtf.h: Ditto.
* libm/machine/spu/headers/tgamma.h: Ditto.
* libm/machine/spu/headers/tgammaf.h: Ditto.
2007-09-28 Patrick Mansfield <patmans@us.ibm.com>
* libm/machine/spu/Makefile.am: Add new C files.

View File

@ -1,6 +1,18 @@
#include "headers/acosd2.h"
#include "headers/dom_chkd_negone_one.h"
static __inline double _acos(double x)
{
return spu_extract(_acosd2(spu_promote(x, 0)), 0);
double res;
vector double vx;
vx = spu_splats(x);
res = spu_extract(_acosd2(vx), 0);
#ifndef _IEEE_LIBM
/*
* Domain error if not in the interval [-1, +1]
*/
dom_chkd_negone_one(vx);
#endif
return res;
}

View File

@ -1,6 +1,18 @@
#include "headers/acosf4.h"
#include "headers/dom_chkf_negone_one.h"
static __inline float _acosf(float x)
{
return spu_extract(_acosf4(spu_promote(x, 0)), 0);
float res;
vector float vx;
vx = spu_splats(x);
res = spu_extract(_acosf4(vx), 0);
#ifndef _IEEE_LIBM
/*
* Domain error if not in the interval [-1, +1]
*/
dom_chkf_negone_one(vx);
#endif
return res;
}

View File

@ -1,6 +1,16 @@
#include "headers/acoshd2.h"
#include "headers/dom_chkd_less_than.h"
static __inline double _acosh(double x)
{
return spu_extract(_acoshd2(spu_promote(x, 0)), 0);
double res;
vector double vx;
vector double vc = { 1.0, 1.0 };
vx = spu_promote(x, 0);
res = spu_extract(_acoshd2(vx), 0);
#ifndef _IEEE_LIBM
dom_chkd_less_than(vx, vc);
#endif
return res;
}

View File

@ -1,6 +1,16 @@
#include "headers/acoshf4.h"
#include "headers/dom_chkf_less_than.h"
static __inline float _acoshf(float x)
{
return spu_extract(_acoshf4(spu_promote(x, 0)), 0);
float res;
vector float vx;
vector float vc = { 1.0, 1.0, 1.0, 1.0 };
vx = spu_promote(x, 0);
res = spu_extract(_acoshf4(vx), 0);
#ifndef _IEEE_LIBM
dom_chkf_less_than(vx, vc);
#endif
return res;
}

View File

@ -1,6 +1,18 @@
#include "headers/asind2.h"
#include "headers/dom_chkd_negone_one.h"
static __inline double _asin(double x)
{
return spu_extract(_asind2(spu_promote(x, 0)), 0);
double res;
vector double vx;
vx = spu_splats(x);
res = spu_extract(_asind2(vx), 0);
#ifndef _IEEE_LIBM
/*
* Domain error if not in the interval [-1, +1]
*/
dom_chkd_negone_one(vx);
#endif
return res;
}

View File

@ -1,6 +1,18 @@
#include "headers/asinf4.h"
#include "headers/dom_chkf_negone_one.h"
static __inline float _asinf(float x)
{
return spu_extract(_asinf4(spu_promote(x, 0)), 0);
float res;
vector float vx;
vx = spu_splats(x);
res = spu_extract(_asinf4(vx), 0);
#ifndef _IEEE_LIBM
/*
* Domain error if not in the interval [-1, +1]
*/
dom_chkf_negone_one(vx);
#endif
return res;
}

View File

@ -1,6 +1,18 @@
#include "headers/atanhd2.h"
#include "headers/dom_chkd_negone_one.h"
static __inline double _atanh(double x)
{
return spu_extract(_atanhd2(spu_promote(x, 0)), 0);
double res;
vector double vx;
vx = spu_splats(x);
res = spu_extract(_atanhd2(vx), 0);
#ifndef _IEEE_LIBM
/*
* Domain error if not in the interval [-1, +1]
*/
dom_chkd_negone_one(vx);
#endif
return res;
}

View File

@ -1,6 +1,18 @@
#include "headers/atanhf4.h"
#include "headers/dom_chkf_negone_one.h"
static __inline float _atanhf(float x)
{
return spu_extract(_atanhf4(spu_promote(x, 0)), 0);
float res;
vector float vx;
vx = spu_splats(x);
res = spu_extract(_atanhf4(vx), 0);
#ifndef _IEEE_LIBM
/*
* Domain error if not in the interval [-1, +1]
*/
dom_chkf_negone_one(vx);
#endif
return res;
}

View File

@ -0,0 +1,59 @@
/*
Copyright 2007
International Business Machines Corporation,
Sony Computer Entertainment, Incorporated,
Toshiba Corporation,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the names of the copyright holders nor the names of their
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <errno.h>
/*
* dom_chkd_less_than: "domain check double less than"
*
* Set errno to EDOM if vx < vc.
*
* This is for scalar use only, the input is a vector double, but both
* values in both vectors must be the same.
*/
static __inline void dom_chkd_less_than (vector double vx, vector double vc)
{
vector unsigned long long domain;
vector signed int verrno;
vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
domain = spu_cmpgt(vc, vx);
verrno = spu_splats(errno);
/*
* domain is 2 long longs, but they have the same value. Even so, no
* special code is needed to extract the scalar errno (we have all ones
* or all zeroes for the preferred scalar slot).
*/
errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
}

View File

@ -0,0 +1,69 @@
/*
Copyright 2007
International Business Machines Corporation,
Sony Computer Entertainment, Incorporated,
Toshiba Corporation,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the names of the copyright holders nor the names of their
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <errno.h>
/*
* dom_chkd_negone_one: "domain check double negative-one and one":
*
* Set errno to EDOM if |x| > 1.0.
*
* This is for scalar use only, the input is a vector double, but both
* values in the vector must be the same.
*
* We *only* set errno, and do not bother setting the actual return value
* of any functions to a NAN. That way, we have the same method for double
* and single precision (there are no float nans for single precision so
* those can't return a nan).
*
* Note that for newlib, errno is/was a function call, so not so obviously
* we are not branchless here. Unknown if adding a branch (and avoiding a
* call to __errno) is faster than this current code.
*/
static __inline void dom_chkd_negone_one (vector double vx)
{
vector unsigned long long domain;
vector signed int verrno;
vector double ones = { 1.0, 1.0 };
vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
domain = spu_cmpabsgt(vx, ones);
verrno = spu_splats(errno);
/*
* domain is 2 long longs, but they have the same value. Even so, no
* special code is needed to extract the scalar errno (we have all ones
* or all zeroes for the preferred scalar slot).
*/
errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
}

View File

@ -0,0 +1,59 @@
/*
Copyright 2007
International Business Machines Corporation,
Sony Computer Entertainment, Incorporated,
Toshiba Corporation,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the names of the copyright holders nor the names of their
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <errno.h>
/*
* dom_chkf_less_than: "domain check float less than"
*
* Set errno to EDOM if vx < vc.
*
* This is for scalar use only, the input is a vector float, but both
* values in both vectors must be the same.
*/
static __inline void dom_chkf_less_than (vector float vx, vector float vc)
{
vector unsigned int domain;
vector signed int verrno;
vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
domain = spu_cmpgt(vc, vx);
verrno = spu_splats(errno);
/*
* domain is 2 long longs, but they have the same value. Even so, no
* special code is needed to extract the scalar errno (we have all ones
* or all zeroes for the preferred scalar slot).
*/
errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
}

View File

@ -0,0 +1,69 @@
/*
Copyright 2007
International Business Machines Corporation,
Sony Computer Entertainment, Incorporated,
Toshiba Corporation,
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the names of the copyright holders nor the names of their
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <errno.h>
/*
* dom_chkf_negone_one: "domain check float negative-one and one":
*
* Set errno to EDOM if |x| > 1.0.
*
* This is for scalar use only, the input is a vector float, but all
* values in the vector must be the same.
*
* We *only* set errno, and do not bother setting the actual return value
* of any functions to a NAN. That way, we have the same method for float
* and single precision (there are no float nans for single precision so
* those can't return a nan).
*
* Note that for newlib, errno is/was a function call, so not so obviously
* we are not branchless here. Unknown if adding a branch (and avoiding a
* call to __errno) is faster than this current code.
*/
static __inline void dom_chkf_negone_one (vector float vx)
{
vector unsigned int domain;
vector signed int verrno;
vector float ones = { 1.0, 1.0, 1.0, 1.0 };
vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
domain = spu_cmpabsgt(vx, ones);
verrno = spu_splats(errno);
/*
* domain is 4 ints, but they have the same value, even so no special
* code is needed to extract the scalar errno (we have all ones or all
* zeroes for the preferred scalar slot).
*/
errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
}

View File

@ -34,6 +34,7 @@
#define _FMOD_H_ 1
#include <spu_intrinsics.h>
#include <errno.h>
#include "headers/vec_literal.h"
/* This implementation returns zero if y is a denorm or zero.
@ -57,6 +58,10 @@ static __inline double _fmod(double x, double y)
vec_uint4 sign_mask = (vec_uint4)(VEC_SPLAT_U64(0x8000000000000000ULL));
vec_uint4 implied_1 = (vec_uint4)(VEC_SPLAT_U64(0x0010000000000000ULL));
vec_uint4 mant_mask = (vec_uint4)(VEC_SPLAT_U64(0x000FFFFFFFFFFFFFULL));
vec_ullong2 domain;
vec_int4 verrno;
vec_double2 vc = { 0.0, 0.0 };
vec_int4 fail = { EDOM, EDOM, EDOM, EDOM };
vx = (vec_uint4)spu_promote(x, 0);
vy = (vec_uint4)spu_promote(y, 0);
@ -147,6 +152,15 @@ static __inline double _fmod(double x, double y)
result = spu_sel(spu_andc(result, spu_rlmask(result0, -1)), vx,
resultx);
#ifndef _IEEE_LIBM
/*
* If y is zero, set errno to EDOM
*/
domain = spu_cmpeq(vc, (vec_double2) vy);
verrno = spu_splats(errno);
errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
#endif
return (spu_extract((vec_double2)result, 0));
}
#endif /* _FMOD_H_ */

View File

@ -33,6 +33,7 @@
#ifndef _FMODF_H_
#define _FMODF_H_ 1
#include <errno.h>
#include <spu_intrinsics.h>
#include "headers/vec_literal.h"
@ -83,6 +84,10 @@ static __inline float _fmodf(float x, float y)
vec_uint4 sign_mask = VEC_SPLAT_U32(0x80000000);
vec_uint4 implied_1 = VEC_SPLAT_U32(0x00800000);
vec_uint4 mant_mask = VEC_SPLAT_U32(0x007FFFFF);
vec_uint4 domain;
vec_int4 verrno;
vec_float4 vc = { 0.0, 0.0, 0.0, 0.0 };
vec_int4 fail = { EDOM, EDOM, EDOM, EDOM };
vx = (vec_uint4)spu_promote(x, 0);
vy = (vec_uint4)spu_promote(y, 0);
@ -150,6 +155,15 @@ static __inline float _fmodf(float x, float y)
result = spu_sel(spu_andc(result, spu_rlmask(result0, -1)), vx,
resultx);
#ifndef _IEEE_LIBM
/*
* If y is zero, set errno to EDOM
*/
domain = spu_cmpeq(vc, (vec_float4) vy);
verrno = spu_splats(errno);
errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
#endif
return (spu_extract((vec_float4)result, 0));
#endif /* FMODF_INTEGER_RANGE */
}

View File

@ -1,6 +1,16 @@
#include "headers/logd2.h"
#include "headers/dom_chkd_less_than.h"
static __inline double _log(double x)
{
return spu_extract(_logd2(spu_promote(x, 0)), 0);
double res;
vector double vx;
vector double vc = { 0.0, 0.0 };
vx = spu_promote(x, 0);
res = spu_extract(_logd2(vx), 0);
#ifndef _IEEE_LIBM
dom_chkd_less_than(vx, vc);
#endif
return res;
}

View File

@ -1,6 +1,16 @@
#include "headers/log10d2.h"
#include "headers/dom_chkd_less_than.h"
static __inline double _log10(double x)
{
return spu_extract(_log10d2(spu_promote(x, 0)), 0);
double res;
vector double vx;
vector double vc = { 0.0, 0.0 };
vx = spu_promote(x, 0);
res = spu_extract(_log10d2(vx), 0);
#ifndef _IEEE_LIBM
dom_chkd_less_than(vx, vc);
#endif
return res;
}

View File

@ -1,6 +1,16 @@
#include "headers/log1pd2.h"
#include "headers/dom_chkd_less_than.h"
static __inline double _log1p(double x)
{
return spu_extract(_log1pd2(spu_promote(x, 0)), 0);
double res;
vector double vx;
vector double vc = { -1.0, -1.0 };
vx = spu_promote(x, 0);
res = spu_extract(_log1pd2(vx), 0);
#ifndef _IEEE_LIBM
dom_chkd_less_than(vx, vc);
#endif
return res;
}

View File

@ -1,6 +1,16 @@
#include "headers/log1pf4.h"
#include "headers/dom_chkf_less_than.h"
static __inline float _log1pf(float x)
{
return spu_extract(_log1pf4(spu_promote(x, 0)), 0);
float res;
vector float vx;
vector float vc = { -1.0, -1.0, -1.0, -1.0 };
vx = spu_promote(x, 0);
res = spu_extract(_log1pf4(vx), 0);
#ifndef _IEEE_LIBM
dom_chkf_less_than(vx, vc);
#endif
return res;
}

View File

@ -1,6 +1,16 @@
#include "headers/log2d2.h"
#include "headers/dom_chkd_less_than.h"
static __inline double _log2(double vx)
static __inline double _log2(double x)
{
return spu_extract(_log2d2(spu_promote(vx, 0)), 0);
double res;
vector double vx;
vector double vc = { 0.0, 0.0 };
vx = spu_promote(x, 0);
res = spu_extract(_log2d2(vx), 0);
#ifndef _IEEE_LIBM
dom_chkd_less_than(vx, vc);
#endif
return res;
}

View File

@ -33,6 +33,9 @@
#ifndef _LOG2F_H_
#define _LOG2F_H_ 1
#include <spu_intrinsics.h>
#include "headers/dom_chkf_less_than.h"
/*
* FUNCTION
* float _log2f(float x)
@ -73,6 +76,8 @@ static __inline float _log2f(float x)
float result;
float x2, x4;
float hi, lo;
vector float vx;
vector float vc = { 0.0, 0.0, 0.0, 0.0 };
in.f = x;
@ -109,6 +114,10 @@ static __inline float _log2f(float x)
*/
result += (float)(exponent);
#ifndef _IEEE_LIBM
vx = spu_promote(x, 0);
dom_chkf_less_than(vx, vc);
#endif
return (result);
}

View File

@ -43,6 +43,7 @@
*/
#include <spu_intrinsics.h>
#include "headers/vec_literal.h"
#include "headers/dom_chkd_less_than.h"
static __inline double _sqrt(double in)
{
@ -53,6 +54,7 @@ static __inline double _sqrt(double in)
vec_ullong2 mask = VEC_SPLAT_U64(0x7FE0000000000000ULL);
vec_double2 x, dx, de, dd, dy, dg, dy2, dhalf;
vec_double2 denorm, neg;
vec_double2 vc = { 0.0, 0.0 };
fhalf = VEC_SPLAT_F32(0.5f);
dhalf = VEC_SPLAT_F64(0.5);
@ -124,6 +126,9 @@ static __inline double _sqrt(double in)
dg = spu_sel(spu_andc(spu_or(dg, neg), denorm), x, nochange);
#ifndef _IEEE_LIBM
dom_chkd_less_than(spu_splats(in), vc);
#endif
return (spu_extract(dg, 0));
}
#endif /* _SQRT_H_ */

View File

@ -1,6 +1,16 @@
#include "headers/sqrtf4.h"
#include "headers/dom_chkf_less_than.h"
static __inline float _sqrtf(float in)
{
return spu_extract(_sqrtf4(spu_promote(in, 0)), 0);
float res;
vector float vx;
vector float vc = { 0.0, 0.0, 0.0, 0.0 };
vx = spu_promote(in, 0);
res = spu_extract(_sqrtf4(vx), 0);
#ifndef _IEEE_LIBM
dom_chkf_less_than(vx, vc);
#endif
return res;
}

View File

@ -1,6 +1,30 @@
#include <errno.h>
#include "headers/truncd2.h"
#include "headers/tgammad2.h"
static __inline double _tgamma(double x)
{
return spu_extract(_tgammad2(spu_promote(x, 0)), 0);
double res;
vector double vx;
vector double truncx;
vector double vc = { 0.0, 0.0 };
vector unsigned long long cmpres;
vector signed int verrno, ferrno;
vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
vx = spu_promote(x, 0);
res = spu_extract(_tgammad2(vx), 0);
#ifndef _IEEE_LIBM
/*
* use vector truncd2 rather than splat x, and splat truncx.
*/
truncx = _truncd2(vx);
cmpres = spu_cmpeq(truncx, vx);
verrno = spu_splats(errno);
ferrno = spu_sel(verrno, fail, (vector unsigned int) cmpres);
cmpres = spu_cmpgt(vc, vx);
errno = spu_extract(spu_sel(verrno, ferrno, (vector unsigned int) cmpres), 0);
#endif
return res;
}

View File

@ -1,6 +1,29 @@
#include <errno.h>
#include "headers/truncf4.h"
#include "headers/tgammaf4.h"
static __inline float _tgammaf(float x)
{
return spu_extract(_tgammaf4(spu_promote(x, 0)), 0);
float res;
vector float vx;
vector float truncx;
vector float vc = { 0.0, 0.0 };
vector unsigned int cmpres;
vector signed int verrno, ferrno;
vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
vx = spu_promote(x, 0);
res = spu_extract(_tgammaf4(vx), 0);
#ifndef _IEEE_LIBM
/*
* use vector truncf4 rather than splat x, and splat truncx.
*/
truncx = _truncf4(vx);
cmpres = spu_cmpeq(truncx, vx);
verrno = spu_splats(errno);
ferrno = spu_sel(verrno, fail, (vector unsigned int) cmpres);
cmpres = spu_cmpgt(vc, vx);
errno = spu_extract(spu_sel(verrno, ferrno, (vector unsigned int) cmpres), 0);
#endif
return res;
}