Skip to content

Commit

Permalink
More SPE tests
Browse files Browse the repository at this point in the history
  • Loading branch information
afxgroup committed Aug 2, 2023
1 parent 6bc8364 commit 9cc96f2
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 407 deletions.
1 change: 1 addition & 0 deletions library/math/e_sqrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ static const float one = 1.0, tiny = 1.0e-30;
double
__ieee754_sqrt(double x) {
double z;

#ifndef __SPE__
asm ("fsqrt %0,%1\n" :"=f" (z):"f" (x));
#else
Expand Down
1 change: 1 addition & 0 deletions library/math/e_sqrtf.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static const float one = 1.0, tiny = 1.0e-30;
float
__ieee754_sqrtf(float x) {
float z;

#ifndef __SPE__
asm ("fsqrts %0,%1\n" :"=f" (z):"f" (x));
#else
Expand Down
31 changes: 9 additions & 22 deletions library/math/math_fp_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,19 @@ struct Double {
double b;
};

#define DBL_MANH_SIZE 20
#define DBL_MANL_SIZE 32

union IEEEd2bits {
double d;
struct {
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#if __FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__
unsigned int manl :32;
#endif
unsigned int manh :20;
unsigned int exp :11;
unsigned int sign :1;
#if __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
unsigned int manl :32;
#endif
#else /* _BIG_ENDIAN */
unsigned int sign :1;
unsigned int exp :11;
unsigned int manh :20;
unsigned int manl :32;
uint32_t manl : 32;
uint32_t manh : 20;
uint32_t exp : 11;
uint32_t sign : 1;
#else // Big endian
uint32_t sign : 1;
uint32_t exp : 11;
uint32_t manh : 20;
uint32_t manl : 32;
#endif
} bits;
};
Expand All @@ -75,11 +67,6 @@ union IEEEd2bits {
#define LDBL_MANL_SIZE 32

/* 'Portable' raw representations of three IEEE floating point formats. */
union ieee_long_double {
long double value;
unsigned long raw[3];
};

union ieee_double {
double value;
unsigned long raw[2];
Expand Down
33 changes: 0 additions & 33 deletions library/math/s_isfinite.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,18 @@

int
__isfinite_float(float f) {
#ifdef __SPE__
union ieee_single x;
int result;

x.value = f;

if((x.raw[0] & 0x7f800000) == 0x7f800000 && (x.raw[0] & 0x007fffff) != 0)
result = 0; /* Exponent = 255 and fraction != 0.0 -> not a number */
else if ((x.raw[0] & 0x7fffffff) == 0x7f800000)
result = 0; /* Exponent = 255 and fraction = 0.0 -> infinity */
else
result = 1;

return(result);
#else
union IEEEf2bits u;

u.f = f;
return (u.bits.exp != 255);
#endif
}

int
__isfinite_double(double d) {
#ifdef __SPE__
union ieee_double x;
int result;

x.value = d;
//Printf("isfinite %ld %ld %ld\n", d, x.raw[0], x.raw[1]);

if(((x.raw[0] & 0x7ff00000) == 0x7ff00000) && ((x.raw[0] & 0x000fffff) != 0 || (x.raw[1] != 0)))
result = 0; /* Exponent = 2047 and fraction != 0.0 -> not a number */
else if (((x.raw[0] & 0x7fffffff) == 0x7ff00000) && (x.raw[1] == 0))
result = 0; /* Exponent = 2047 and fraction = 0.0 -> infinity */
else
result = 1;

return(result);
#else
union IEEEd2bits u;

u.d = d;
return (u.bits.exp != 2047);
#endif
}

int
Expand Down
10 changes: 0 additions & 10 deletions library/math/s_nanf.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ __scan_nan(uint32_t *words, int num_words, const char *s) {

float
nanf(const char *s) {
#ifndef __SPE__
union {
float f;
uint32_t bits[1];
Expand All @@ -47,13 +46,4 @@ nanf(const char *s) {
__scan_nan(u.bits, 1, s);
u.bits[0] |= 0x7fc00000;
return (u.f);
#else
(void) s;
union ieee_single x;

/* Exponent = 255 and fraction != 0.0; this must be a quiet nan. */
x.raw[0] = 0x7fc00000;

return x.value;
#endif
}
Loading

0 comments on commit 9cc96f2

Please sign in to comment.