void test_double_pow (void) { int i; for (i = 0; i < SIZE; i++) d1[i] = __builtin_pow (d2[i], d3[i]); }
double foo (double x, double y) { return __builtin_pow (x, 0.75) + y; }
void bar() { /* An argument of NaN is not evaluated at compile-time. */ #ifndef __SPU__ foof (__builtin_exp2f (__builtin_nanf(""))); #endif foo (__builtin_exp2 (__builtin_nan(""))); fool (__builtin_exp2l (__builtin_nanl(""))); /* An argument of Inf/-Inf is not evaluated at compile-time. */ #ifndef __SPU__ foof (__builtin_exp2f (__builtin_inff())); #endif foo (__builtin_exp2 (__builtin_inf())); fool (__builtin_exp2l (__builtin_infl())); #ifndef __SPU__ foof (__builtin_exp2f (-__builtin_inff())); #endif foo (__builtin_exp2 (-__builtin_inf())); fool (__builtin_exp2l (-__builtin_infl())); /* Result overflows MPFR, which in version 2.2.x has 30 exponent bits. */ TESTIT (exp2, 0x1p50); /* Result underflows MPFR, which in version 2.2.x has 30 exponent bits. */ TESTIT (exp2, -0x1p50); /* Result overflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits. */ TESTIT (exp2, 0x1p28); /* Result underflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits. */ TESTIT (exp2, -0x1p28); /* Result overflows (even an extended) C double's mode. */ TESTIT (exp2, 0x1p24); /* Result underflows (even an extended) C double's mode. */ TESTIT (exp2, -0x1p24); /* Ensure that normal arguments/results are folded. */ TESTIT (exp2, 1.5); TESTIT (exp2, -1.5); /* The asin arg must be [-1 ... 1] inclusive. */ TESTIT (asin, -1.5); TESTIT (asin, 1.5); /* The acos arg must be [-1 ... 1] inclusive. */ TESTIT (acos, -1.5); TESTIT (acos, 1.5); /* The acosh arg must be [1 ... Inf] inclusive. */ TESTIT (acosh, 0.5); /* The atanh arg must be [-1 ... 1] EXclusive. */ TESTIT (atanh, -1.0); TESTIT (atanh, 1.0); /* The log* arg must be [0 ... Inf] EXclusive. */ TESTIT (log, -1.0); TESTIT (log, 0.0); TESTIT (log, -0.0); TESTIT (log2, -1.0); TESTIT (log2, 0.0); TESTIT (log2, -0.0); TESTIT (log10, -1.0); TESTIT (log10, 0.0); TESTIT (log10, -0.0); /* The log1p arg must be [-1 ... Inf] EXclusive. */ TESTIT (log1p, -2.0); TESTIT (log1p, -1.0); /* The tgamma arg errors with zero or negative integers. */ TESTIT (tgamma, 0.0); TESTIT (tgamma, -0.0); TESTIT (tgamma, -1.0); TESTIT (tgamma, -2.0); TESTIT (tgamma, -3.0); /* An argument of NaN is not evaluated at compile-time. */ #ifndef __SPU__ foof (__builtin_powf (__builtin_nanf(""), 2.5F)); #endif foo (__builtin_pow (__builtin_nan(""), 2.5)); fool (__builtin_powl (__builtin_nanl(""), 2.5L)); #ifndef __SPU__ foof (__builtin_powf (2.5F, __builtin_nanf(""))); #endif foo (__builtin_pow (2.5, __builtin_nan(""))); fool (__builtin_powl (2.5L, __builtin_nanl(""))); /* An argument of Inf/-Inf is not evaluated at compile-time. */ #ifndef __SPU__ foof (__builtin_powf (__builtin_inff(), 2.5F)); #endif foo (__builtin_pow (__builtin_inf(), 2.5)); fool (__builtin_powl (__builtin_infl(), 2.5L)); #ifndef __SPU__ foof (__builtin_powf (-__builtin_inff(), 2.5F)); #endif foo (__builtin_pow (-__builtin_inf(), 2.5)); fool (__builtin_powl (-__builtin_infl(), 2.5L)); #ifndef __SPU__ foof (__builtin_powf (2.5F, __builtin_inff())); #endif foo (__builtin_pow (2.5, __builtin_inf())); fool (__builtin_powl (2.5L, __builtin_infl())); #ifndef __SPU__ foof (__builtin_powf (2.5F, -__builtin_inff())); #endif foo (__builtin_pow (2.5, -__builtin_inf())); fool (__builtin_powl (2.5L, -__builtin_infl())); /* Check for Inv/NaN return values. */ TESTIT2 (pow, -0.0, -4.5); /* Returns Inf */ TESTIT2 (pow, 0.0, -4.5); /* Returns Inf */ TESTIT2 (pow, -3.0, -4.5); /* Returns NaN */ /* Check for overflow/underflow. */ foof (__builtin_powf (__FLT_MAX__, 3.5F)); foo (__builtin_pow (__DBL_MAX__, 3.5)); fool (__builtin_powl (__LDBL_MAX__, 3.5L)); TESTIT2 (pow, 2.0, 0x1p50); foof (__builtin_powf (__FLT_MAX__, -3.5F)); foo (__builtin_pow (__DBL_MAX__, -3.5)); fool (__builtin_powl (__LDBL_MAX__, -3.5L)); TESTIT2 (pow, 2.0, -0x1p50); /* The sqrt arg must be [0 ... Inf] inclusive. */ TESTIT (sqrt, -0.5); TESTIT (sqrt, -0.0); TESTIT (sqrt, 0.0); /* Check for overflow/underflow. */ /* These adjustments are too big. */ #define FLT_EXP_ADJ (2*(__FLT_MAX_EXP__-__FLT_MIN_EXP__)+1) #define DBL_EXP_ADJ (2*(__DBL_MAX_EXP__-__DBL_MIN_EXP__)+1) #define LDBL_EXP_ADJ (2*(__LDBL_MAX_EXP__-__LDBL_MIN_EXP__)+1) TESTIT2_I2 (ldexp, 1.0, __INT_MAX__); TESTIT2_I2 (ldexp, 1.0, -__INT_MAX__-1); TESTIT2_I2 (ldexp, -1.0, __INT_MAX__); TESTIT2_I2 (ldexp, -1.0, -__INT_MAX__-1); TESTIT2_I2ALL (ldexp, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__, DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ); TESTIT2_I2ALL (ldexp, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__, -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ); TESTIT2_I2ALL (ldexp, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__, __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__); TESTIT2_I2ALL (ldexp, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__, __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__); TESTIT2_I2 (scalbn, 1.0, __INT_MAX__); TESTIT2_I2 (scalbn, 1.0, -__INT_MAX__-1); TESTIT2_I2 (scalbn, -1.0, __INT_MAX__); TESTIT2_I2 (scalbn, -1.0, -__INT_MAX__-1); TESTIT2_I2ALL (scalbn, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__, DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ); TESTIT2_I2ALL (scalbn, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__, -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ); TESTIT2_I2ALL (scalbn, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__, __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__); TESTIT2_I2ALL (scalbn, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__, __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__); TESTIT2_I2 (scalbln, 1.0, __LONG_MAX__); TESTIT2_I2 (scalbln, 1.0, -__LONG_MAX__-1); TESTIT2_I2 (scalbln, -1.0, __LONG_MAX__); TESTIT2_I2 (scalbln, -1.0, -__LONG_MAX__-1); TESTIT2_I2ALL (scalbln, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__, DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ); TESTIT2_I2ALL (scalbln, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__, -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ); TESTIT2_I2ALL (scalbln, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__, __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__); TESTIT2_I2ALL (scalbln, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__, __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__); TESTIT (logb, 0.0); TESTIT (logb, -0.0); TESTIT (ilogb, 0.0); TESTIT (ilogb, -0.0); #ifndef __SPU__ foof (__builtin_ilogbf (__builtin_inff())); #endif foo (__builtin_ilogb (__builtin_inf())); fool (__builtin_ilogbl (__builtin_infl())); #ifndef __SPU__ foof (__builtin_ilogbf (-__builtin_inff())); #endif foo (__builtin_ilogb (-__builtin_inf())); fool (__builtin_ilogbl (-__builtin_infl())); #ifndef __SPU__ foof (__builtin_ilogbf (__builtin_nanf(""))); #endif foo (__builtin_ilogb (__builtin_nan(""))); fool (__builtin_ilogbl (__builtin_nanl(""))); #ifndef __SPU__ foof (__builtin_ilogbf (-__builtin_nanf(""))); #endif foo (__builtin_ilogb (-__builtin_nan(""))); fool (__builtin_ilogbl (-__builtin_nanl(""))); /* The y* arg must be [0 ... Inf] EXclusive. */ TESTIT (y0, -1.0); TESTIT (y0, 0.0); TESTIT (y0, -0.0); TESTIT (y1, -1.0); TESTIT (y1, 0.0); TESTIT (y1, -0.0); TESTIT2_I1 (yn, 2, -1.0); TESTIT2_I1 (yn, 2, 0.0); TESTIT2_I1 (yn, 2, -0.0); TESTIT2_I1 (yn, -3, -1.0); TESTIT2_I1 (yn, -3, 0.0); TESTIT2_I1 (yn, -3, -0.0); /* The second argument of remquo/remainder/drem must not be 0. */ TESTIT_REMQUO (1.0, 0.0); TESTIT_REMQUO (1.0, -0.0); TESTIT2 (remainder, 1.0, 0.0); TESTIT2 (remainder, 1.0, -0.0); TESTIT2 (drem, 1.0, 0.0); TESTIT2 (drem, 1.0, -0.0); /* The argument to lgamma* cannot be zero or a negative integer. */ TESTIT_REENT (lgamma, -4.0); /* lgamma_r */ TESTIT_REENT (lgamma, -3.0); /* lgamma_r */ TESTIT_REENT (lgamma, -2.0); /* lgamma_r */ TESTIT_REENT (lgamma, -1.0); /* lgamma_r */ TESTIT_REENT (lgamma, -0.0); /* lgamma_r */ TESTIT_REENT (lgamma, 0.0); /* lgamma_r */ TESTIT_REENT (gamma, -4.0); /* gamma_r */ TESTIT_REENT (gamma, -3.0); /* gamma_r */ TESTIT_REENT (gamma, -2.0); /* gamma_r */ TESTIT_REENT (gamma, -1.0); /* gamma_r */ TESTIT_REENT (gamma, -0.0); /* gamma_r */ TESTIT_REENT (gamma, 0.0); /* gamma_r */ }
double pow(double x, double y) { return __builtin_pow(x, y); }
double test2 (double x) { return __builtin_pow (x, 3./2.); }
double test1 (double x) { return __builtin_pow (x, 1./2.); }
double test4 (double x) { return __builtin_pow (x, -5./2.); }
double test3 (double x) { return __builtin_pow (x, 5./2.); }