diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -190,8 +190,6 @@ truncsfbf2.c ) -# TODO: Several "tf" files (and divtc3.c, but not multc3.c) are in -# GENERIC_SOURCES instead of here. set(GENERIC_TF_SOURCES addtf3.c comparetf2.c diff --git a/compiler-rt/lib/builtins/README.txt b/compiler-rt/lib/builtins/README.txt --- a/compiler-rt/lib/builtins/README.txt +++ b/compiler-rt/lib/builtins/README.txt @@ -137,11 +137,12 @@ di_int __fixsfdi( float a); di_int __fixdfdi( double a); di_int __fixxfdi(long double a); +di_int __fixtfdi(long double a); ti_int __fixsfti( float a); ti_int __fixdfti( double a); ti_int __fixxfti(long double a); -uint64_t __fixtfdi(long double input); // ppc only, doesn't match documentation +ti_int __fixtfti(long double a); su_int __fixunssfsi( float a); su_int __fixunsdfsi( double a); @@ -154,12 +155,12 @@ tu_int __fixunssfti( float a); tu_int __fixunsdfti( double a); tu_int __fixunsxfti(long double a); -uint64_t __fixunstfdi(long double input); // ppc only +uint64_t __fixunstfdi(long double input); float __floatdisf(di_int a); double __floatdidf(di_int a); long double __floatdixf(di_int a); -long double __floatditf(int64_t a); // ppc only +long double __floatditf(int64_t a); float __floattisf(ti_int a); double __floattidf(ti_int a); @@ -168,7 +169,7 @@ float __floatundisf(du_int a); double __floatundidf(du_int a); long double __floatundixf(du_int a); -long double __floatunditf(uint64_t a); // ppc only +long double __floatunditf(uint64_t a); float __floatuntisf(tu_int a); double __floatuntidf(tu_int a); @@ -179,7 +180,7 @@ float __powisf2( float a, int b); // a ^ b double __powidf2( double a, int b); // a ^ b long double __powixf2(long double a, int b); // a ^ b -long double __powitf2(long double a, int b); // ppc only, a ^ b +long double __powitf2(long double a, int b); // a ^ b // Complex arithmetic @@ -190,7 +191,7 @@ long double _Complex __mulxc3(long double a, long double b, long double c, long double d); long double _Complex __multc3(long double a, long double b, - long double c, long double d); // ppc only + long double c, long double d); // (a + ib) / (c + id) @@ -199,7 +200,7 @@ long double _Complex __divxc3(long double a, long double b, long double c, long double d); long double _Complex __divtc3(long double a, long double b, - long double c, long double d); // ppc only + long double c, long double d); // Runtime support diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c --- a/compiler-rt/lib/builtins/divtc3.c +++ b/compiler-rt/lib/builtins/divtc3.c @@ -12,44 +12,45 @@ #define QUAD_PRECISION #include "fp_lib.h" -#include "int_lib.h" -#include "int_math.h" + +#if defined(CRT_HAS_TF_MODE) // Returns: the quotient of (a + ib) / (c + id) -COMPILER_RT_ABI Lcomplex __divtc3(long double __a, long double __b, - long double __c, long double __d) { +COMPILER_RT_ABI Qcomplex __divtc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d) { int __ilogbw = 0; - long double __logbw = - __compiler_rt_logbl(__compiler_rt_fmaxl(crt_fabsl(__c), crt_fabsl(__d))); + fp_t __logbw = __compiler_rt_logbtf( + __compiler_rt_fmaxtf(crt_fabstf(__c), crt_fabstf(__d))); if (crt_isfinite(__logbw)) { __ilogbw = (int)__logbw; - __c = __compiler_rt_scalbnl(__c, -__ilogbw); - __d = __compiler_rt_scalbnl(__d, -__ilogbw); + __c = __compiler_rt_scalbntf(__c, -__ilogbw); + __d = __compiler_rt_scalbntf(__d, -__ilogbw); } - long double __denom = __c * __c + __d * __d; - Lcomplex z; - COMPLEX_REAL(z) = - __compiler_rt_scalbnl((__a * __c + __b * __d) / __denom, -__ilogbw); - COMPLEX_IMAGINARY(z) = - __compiler_rt_scalbnl((__b * __c - __a * __d) / __denom, -__ilogbw); - if (crt_isnan(COMPLEX_REAL(z)) && crt_isnan(COMPLEX_IMAGINARY(z))) { + fp_t __denom = __c * __c + __d * __d; + Qcomplex z; + COMPLEXTF_REAL(z) = + __compiler_rt_scalbntf((__a * __c + __b * __d) / __denom, -__ilogbw); + COMPLEXTF_IMAGINARY(z) = + __compiler_rt_scalbntf((__b * __c - __a * __d) / __denom, -__ilogbw); + if (crt_isnan(COMPLEXTF_REAL(z)) && crt_isnan(COMPLEXTF_IMAGINARY(z))) { if ((__denom == 0.0) && (!crt_isnan(__a) || !crt_isnan(__b))) { - COMPLEX_REAL(z) = crt_copysignl(CRT_INFINITY, __c) * __a; - COMPLEX_IMAGINARY(z) = crt_copysignl(CRT_INFINITY, __c) * __b; + COMPLEXTF_REAL(z) = crt_copysigntf(CRT_INFINITY, __c) * __a; + COMPLEXTF_IMAGINARY(z) = crt_copysigntf(CRT_INFINITY, __c) * __b; } else if ((crt_isinf(__a) || crt_isinf(__b)) && crt_isfinite(__c) && crt_isfinite(__d)) { - __a = crt_copysignl(crt_isinf(__a) ? 1.0 : 0.0, __a); - __b = crt_copysignl(crt_isinf(__b) ? 1.0 : 0.0, __b); - COMPLEX_REAL(z) = CRT_INFINITY * (__a * __c + __b * __d); - COMPLEX_IMAGINARY(z) = CRT_INFINITY * (__b * __c - __a * __d); + __a = crt_copysigntf(crt_isinf(__a) ? (fp_t)1.0 : (fp_t)0.0, __a); + __b = crt_copysigntf(crt_isinf(__b) ? (fp_t)1.0 : (fp_t)0.0, __b); + COMPLEXTF_REAL(z) = CRT_INFINITY * (__a * __c + __b * __d); + COMPLEXTF_IMAGINARY(z) = CRT_INFINITY * (__b * __c - __a * __d); } else if (crt_isinf(__logbw) && __logbw > 0.0 && crt_isfinite(__a) && crt_isfinite(__b)) { - __c = crt_copysignl(crt_isinf(__c) ? 1.0 : 0.0, __c); - __d = crt_copysignl(crt_isinf(__d) ? 1.0 : 0.0, __d); - COMPLEX_REAL(z) = 0.0 * (__a * __c + __b * __d); - COMPLEX_IMAGINARY(z) = 0.0 * (__b * __c - __a * __d); + __c = crt_copysigntf(crt_isinf(__c) ? (fp_t)1.0 : (fp_t)0.0, __c); + __d = crt_copysigntf(crt_isinf(__d) ? (fp_t)1.0 : (fp_t)0.0, __d); + COMPLEXTF_REAL(z) = 0.0 * (__a * __c + __b * __d); + COMPLEXTF_IMAGINARY(z) = 0.0 * (__b * __c - __a * __d); } } return z; } + +#endif diff --git a/compiler-rt/lib/builtins/extenddftf2.c b/compiler-rt/lib/builtins/extenddftf2.c --- a/compiler-rt/lib/builtins/extenddftf2.c +++ b/compiler-rt/lib/builtins/extenddftf2.c @@ -14,8 +14,6 @@ #define DST_QUAD #include "fp_extend_impl.inc" -COMPILER_RT_ABI fp_t __extenddftf2(double a) { - return __extendXfYf2__(a); -} +COMPILER_RT_ABI dst_t __extenddftf2(src_t a) { return __extendXfYf2__(a); } #endif diff --git a/compiler-rt/lib/builtins/extendhftf2.c b/compiler-rt/lib/builtins/extendhftf2.c --- a/compiler-rt/lib/builtins/extendhftf2.c +++ b/compiler-rt/lib/builtins/extendhftf2.c @@ -15,8 +15,6 @@ #define DST_QUAD #include "fp_extend_impl.inc" -COMPILER_RT_ABI long double __extendhftf2(_Float16 a) { - return __extendXfYf2__(a); -} +COMPILER_RT_ABI dst_t __extendhftf2(src_t a) { return __extendXfYf2__(a); } #endif diff --git a/compiler-rt/lib/builtins/extendsftf2.c b/compiler-rt/lib/builtins/extendsftf2.c --- a/compiler-rt/lib/builtins/extendsftf2.c +++ b/compiler-rt/lib/builtins/extendsftf2.c @@ -14,8 +14,6 @@ #define DST_QUAD #include "fp_extend_impl.inc" -COMPILER_RT_ABI fp_t __extendsftf2(float a) { - return __extendXfYf2__(a); -} +COMPILER_RT_ABI dst_t __extendsftf2(src_t a) { return __extendXfYf2__(a); } #endif diff --git a/compiler-rt/lib/builtins/floattitf.c b/compiler-rt/lib/builtins/floattitf.c --- a/compiler-rt/lib/builtins/floattitf.c +++ b/compiler-rt/lib/builtins/floattitf.c @@ -67,7 +67,7 @@ // a is now rounded to LDBL_MANT_DIG bits } - long_double_bits fb; + tf_bits fb; fb.u.high.all = (s & 0x8000000000000000LL) // sign | (du_int)(e + 16383) << 48 // exponent | ((a >> 64) & 0x0000ffffffffffffLL); // significand diff --git a/compiler-rt/lib/builtins/floatuntitf.c b/compiler-rt/lib/builtins/floatuntitf.c --- a/compiler-rt/lib/builtins/floatuntitf.c +++ b/compiler-rt/lib/builtins/floatuntitf.c @@ -65,7 +65,7 @@ // a is now rounded to TF_MANT_DIG bits } - long_double_bits fb; + tf_bits fb; fb.u.high.all = (du_int)(e + 16383) << 48 // exponent | ((a >> 64) & 0x0000ffffffffffffLL); // significand fb.u.low.all = (du_int)(a); diff --git a/compiler-rt/lib/builtins/fp_extend.h b/compiler-rt/lib/builtins/fp_extend.h --- a/compiler-rt/lib/builtins/fp_extend.h +++ b/compiler-rt/lib/builtins/fp_extend.h @@ -67,7 +67,7 @@ static const int dstSigBits = 52; #elif defined DST_QUAD -typedef long double dst_t; +typedef tf_float dst_t; typedef __uint128_t dst_rep_t; #define DST_REP_C (__uint128_t) static const int dstSigBits = 112; diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h --- a/compiler-rt/lib/builtins/fp_lib.h +++ b/compiler-rt/lib/builtins/fp_lib.h @@ -105,17 +105,11 @@ COMPILER_RT_ABI fp_t __adddf3(fp_t a, fp_t b); #elif defined QUAD_PRECISION -#if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__) -// TODO: Availability of the *tf functions should not depend on long double -// being IEEE 128, but instead on being able to use a 128-bit floating-point -// type, which includes __float128. -// Right now this (incorrectly) stops the builtins from being used for x86. -#define CRT_LDBL_128BIT -#define CRT_HAS_TF_MODE +#if defined(CRT_HAS_TF_MODE) typedef uint64_t half_rep_t; typedef __uint128_t rep_t; typedef __int128_t srep_t; -typedef long double fp_t; +typedef tf_float fp_t; #define HALF_REP_C UINT64_C #define REP_C (__uint128_t) // Note: Since there is no explicit way to tell compiler the constant is a @@ -206,13 +200,13 @@ #undef Word_HiMask #undef Word_LoMask #undef Word_FullMask -#endif // __LDBL_MANT_DIG__ == 113 && __SIZEOF_INT128__ +#endif // defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128) #else #error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined. #endif #if defined(SINGLE_PRECISION) || defined(DOUBLE_PRECISION) || \ - defined(CRT_LDBL_128BIT) + (defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE)) #define typeWidth (sizeof(rep_t) * CHAR_BIT) #define exponentBits (typeWidth - significandBits - 1) #define maxExponent ((1 << exponentBits) - 1) @@ -392,31 +386,40 @@ #endif } -#elif defined(QUAD_PRECISION) - -#if defined(CRT_LDBL_128BIT) -static __inline fp_t __compiler_rt_logbl(fp_t x) { +#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE) +// The generic implementation only works for ieee754 floating point. For other +// floating point types, continue to rely on the libm implementation for now. +#if defined(CRT_HAS_IEEE_TF) +static __inline tf_float __compiler_rt_logbtf(tf_float x) { return __compiler_rt_logbX(x); } -static __inline fp_t __compiler_rt_scalbnl(fp_t x, int y) { +static __inline tf_float __compiler_rt_scalbntf(tf_float x, int y) { return __compiler_rt_scalbnX(x, y); } -static __inline fp_t __compiler_rt_fmaxl(fp_t x, fp_t y) { +static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { return __compiler_rt_fmaxX(x, y); } -#else -// The generic implementation only works for ieee754 floating point. For other -// floating point types, continue to rely on the libm implementation for now. -static __inline long double __compiler_rt_logbl(long double x) { +#define __compiler_rt_logbl __compiler_rt_logbtf +#define __compiler_rt_scalbnl __compiler_rt_scalbntf +#define __compiler_rt_fmaxl __compiler_rt_fmaxtf +#define crt_fabstf crt_fabsf128 +#define crt_copysigntf crt_copysignf128 +#elif defined(CRT_LDBL_128BIT) +static __inline tf_float __compiler_rt_logbtf(tf_float x) { return crt_logbl(x); } -static __inline long double __compiler_rt_scalbnl(long double x, int y) { +static __inline tf_float __compiler_rt_scalbntf(tf_float x, int y) { return crt_scalbnl(x, y); } -static __inline long double __compiler_rt_fmaxl(long double x, long double y) { +static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { return crt_fmaxl(x, y); } -#endif // CRT_LDBL_128BIT +#define __compiler_rt_logbl crt_logbl +#define __compiler_rt_scalbnl crt_scalbnl +#define __compiler_rt_fmaxl crt_fmaxl +#else +#error Unsupported TF mode type +#endif #endif // *_PRECISION diff --git a/compiler-rt/lib/builtins/fp_trunc.h b/compiler-rt/lib/builtins/fp_trunc.h --- a/compiler-rt/lib/builtins/fp_trunc.h +++ b/compiler-rt/lib/builtins/fp_trunc.h @@ -28,7 +28,7 @@ static const int srcSigBits = 52; #elif defined SRC_QUAD -typedef long double src_t; +typedef tf_float src_t; typedef __uint128_t src_rep_t; #define SRC_REP_C (__uint128_t) static const int srcSigBits = 112; diff --git a/compiler-rt/lib/builtins/int_math.h b/compiler-rt/lib/builtins/int_math.h --- a/compiler-rt/lib/builtins/int_math.h +++ b/compiler-rt/lib/builtins/int_math.h @@ -65,6 +65,11 @@ #define crt_copysign(x, y) __builtin_copysign((x), (y)) #define crt_copysignf(x, y) __builtin_copysignf((x), (y)) #define crt_copysignl(x, y) __builtin_copysignl((x), (y)) +#if __has_builtin(__builtin_copysignf128) +#define crt_copysignf128(x, y) __builtin_copysignf128((x), (y)) +#elif __has_builtin(__builtin_copysignq) || (defined(__GNUC__) && __GNUC__ >= 7) +#define crt_copysignf128(x, y) __builtin_copysignq((x), (y)) +#endif #endif #if defined(_MSC_VER) && !defined(__clang__) @@ -75,6 +80,11 @@ #define crt_fabs(x) __builtin_fabs((x)) #define crt_fabsf(x) __builtin_fabsf((x)) #define crt_fabsl(x) __builtin_fabsl((x)) +#if __has_builtin(__builtin_fabsf128) +#define crt_fabsf128(x) __builtin_fabsf128((x)) +#elif __has_builtin(__builtin_fabsq) || (defined(__GNUC__) && __GNUC__ >= 7) +#define crt_fabsf128(x) __builtin_fabsq((x)) +#endif #endif #if defined(_MSC_VER) && !defined(__clang__) diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -165,6 +165,53 @@ #define HAS_80_BIT_LONG_DOUBLE 0 #endif +#ifdef __powerpc64__ +// From https://gcc.gnu.org/wiki/Ieee128PowerPC: +// PowerPC64 uses the following suffixes: +// IFmode: IBM extended double +// KFmode: IEEE 128-bit floating point +// TFmode: Matches the default for long double. With -mabi=ieeelongdouble, +// it is IEEE 128-bit, with -mabi=ibmlongdouble IBM extended double +// Since compiler-rt only implements the tf set of libcalls, we use long double +// for the tf_float typedef. +typedef long double tf_float; +#define CRT_LDBL_128BIT +#define CRT_HAS_F128 +#if __LDBL_MANT_DIG__ == 113 && !defined(__LONG_DOUBLE_IBM128__) +#define CRT_HAS_IEEE_TF +#define CRT_LDBL_IEEE_F128 +#endif +#define CRT_TF(x) x##L +#elif __LDBL_MANT_DIG__ == 113 +// Use long double instead of __float128 if it matches the IEEE 128-bit format. +#define CRT_LDBL_128BIT +#define CRT_HAS_F128 +#define CRT_HAS_IEEE_TF +#define CRT_LDBL_IEEE_F128 +typedef long double tf_float; +#define CRT_TF(x) x##L +#elif defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__) +#define CRT_HAS___FLOAT128_KEYWORD +#define CRT_HAS_F128 +// NB: we assume the __float128 type uses IEEE representation. +#define CRT_HAS_IEEE_TF +typedef __float128 tf_float; +#define CRT_TF(x) x##Q +#endif + +#ifdef CRT_HAS_F128 +typedef union { + uqwords u; + tf_float f; +} tf_bits; +#endif + +// __(u)int128_t is currently needed to compile the *tf builtins as we would +// otherwise need to manually expand the bit manipulation on two 64-bit value. +#if defined(CRT_HAS_128BIT) && defined(CRT_HAS_F128) +#define CRT_HAS_TF_MODE +#endif + #if CRT_HAS_FLOATING_POINT typedef union { uqwords u; @@ -175,6 +222,20 @@ typedef float _Complex Fcomplex; typedef double _Complex Dcomplex; typedef long double _Complex Lcomplex; +#if defined(CRT_LDBL_128BIT) +typedef Lcomplex Qcomplex; +#define CRT_HAS_NATIVE_COMPLEX_F128 +#elif defined(CRT_HAS___FLOAT128_KEYWORD) +#if defined(__clang_major__) && __clang_major__ > 10 +// Clang prior to 11 did not support __float128 _Complex. +typedef __float128 _Complex Qcomplex; +#define CRT_HAS_NATIVE_COMPLEX_F128 +#elif defined(__GNUC__) && __GNUC__ >= 7 +// GCC does not allow __float128 _Complex, but accepts _Float128 _Complex. +typedef _Float128 _Complex Qcomplex; +#define CRT_HAS_NATIVE_COMPLEX_F128 +#endif +#endif #define COMPLEX_REAL(x) __real__(x) #define COMPLEX_IMAGINARY(x) __imag__(x) @@ -194,5 +255,17 @@ #define COMPLEX_REAL(x) (x).real #define COMPLEX_IMAGINARY(x) (x).imaginary #endif + +#ifdef CRT_HAS_NATIVE_COMPLEX_F128 +#define COMPLEXTF_REAL(x) __real__(x) +#define COMPLEXTF_IMAGINARY(x) __imag__(x) +#elif defined(CRT_HAS_F128) +typedef struct { + tf_float real, imaginary; +} Qcomplex; +#define COMPLEXTF_REAL(x) (x).real +#define COMPLEXTF_IMAGINARY(x) (x).imaginary +#endif + #endif #endif // INT_TYPES_H diff --git a/compiler-rt/lib/builtins/multc3.c b/compiler-rt/lib/builtins/multc3.c --- a/compiler-rt/lib/builtins/multc3.c +++ b/compiler-rt/lib/builtins/multc3.c @@ -10,56 +10,61 @@ // //===----------------------------------------------------------------------===// +#define QUAD_PRECISION +#include "fp_lib.h" #include "int_lib.h" #include "int_math.h" +#if defined(CRT_HAS_TF_MODE) + // Returns: the product of a + ib and c + id -COMPILER_RT_ABI long double _Complex __multc3(long double a, long double b, - long double c, long double d) { - long double ac = a * c; - long double bd = b * d; - long double ad = a * d; - long double bc = b * c; - long double _Complex z; - __real__ z = ac - bd; - __imag__ z = ad + bc; - if (crt_isnan(__real__ z) && crt_isnan(__imag__ z)) { +COMPILER_RT_ABI Qcomplex __multc3(fp_t a, fp_t b, fp_t c, fp_t d) { + fp_t ac = a * c; + fp_t bd = b * d; + fp_t ad = a * d; + fp_t bc = b * c; + Qcomplex z; + COMPLEXTF_REAL(z) = ac - bd; + COMPLEXTF_IMAGINARY(z) = ad + bc; + if (crt_isnan(COMPLEXTF_REAL(z)) && crt_isnan(COMPLEXTF_IMAGINARY(z))) { int recalc = 0; if (crt_isinf(a) || crt_isinf(b)) { - a = crt_copysignl(crt_isinf(a) ? 1 : 0, a); - b = crt_copysignl(crt_isinf(b) ? 1 : 0, b); + a = crt_copysigntf(crt_isinf(a) ? 1 : 0, a); + b = crt_copysigntf(crt_isinf(b) ? 1 : 0, b); if (crt_isnan(c)) - c = crt_copysignl(0, c); + c = crt_copysigntf(0, c); if (crt_isnan(d)) - d = crt_copysignl(0, d); + d = crt_copysigntf(0, d); recalc = 1; } if (crt_isinf(c) || crt_isinf(d)) { - c = crt_copysignl(crt_isinf(c) ? 1 : 0, c); - d = crt_copysignl(crt_isinf(d) ? 1 : 0, d); + c = crt_copysigntf(crt_isinf(c) ? 1 : 0, c); + d = crt_copysigntf(crt_isinf(d) ? 1 : 0, d); if (crt_isnan(a)) - a = crt_copysignl(0, a); + a = crt_copysigntf(0, a); if (crt_isnan(b)) - b = crt_copysignl(0, b); + b = crt_copysigntf(0, b); recalc = 1; } if (!recalc && (crt_isinf(ac) || crt_isinf(bd) || crt_isinf(ad) || crt_isinf(bc))) { if (crt_isnan(a)) - a = crt_copysignl(0, a); + a = crt_copysigntf(0, a); if (crt_isnan(b)) - b = crt_copysignl(0, b); + b = crt_copysigntf(0, b); if (crt_isnan(c)) - c = crt_copysignl(0, c); + c = crt_copysigntf(0, c); if (crt_isnan(d)) - d = crt_copysignl(0, d); + d = crt_copysigntf(0, d); recalc = 1; } if (recalc) { - __real__ z = CRT_INFINITY * (a * c - b * d); - __imag__ z = CRT_INFINITY * (a * d + b * c); + COMPLEXTF_REAL(z) = CRT_INFINITY * (a * c - b * d); + COMPLEXTF_IMAGINARY(z) = CRT_INFINITY * (a * d + b * c); } } return z; } + +#endif diff --git a/compiler-rt/lib/builtins/powitf2.c b/compiler-rt/lib/builtins/powitf2.c --- a/compiler-rt/lib/builtins/powitf2.c +++ b/compiler-rt/lib/builtins/powitf2.c @@ -17,9 +17,9 @@ // Returns: a ^ b -COMPILER_RT_ABI long double __powitf2(long double a, int b) { +COMPILER_RT_ABI fp_t __powitf2(fp_t a, int b) { const int recip = b < 0; - long double r = 1; + fp_t r = 1; while (1) { if (b & 1) r *= a; diff --git a/compiler-rt/lib/builtins/trunctfdf2.c b/compiler-rt/lib/builtins/trunctfdf2.c --- a/compiler-rt/lib/builtins/trunctfdf2.c +++ b/compiler-rt/lib/builtins/trunctfdf2.c @@ -14,6 +14,6 @@ #define DST_DOUBLE #include "fp_trunc_impl.inc" -COMPILER_RT_ABI double __trunctfdf2(long double a) { return __truncXfYf2__(a); } +COMPILER_RT_ABI dst_t __trunctfdf2(src_t a) { return __truncXfYf2__(a); } #endif diff --git a/compiler-rt/lib/builtins/trunctfhf2.c b/compiler-rt/lib/builtins/trunctfhf2.c --- a/compiler-rt/lib/builtins/trunctfhf2.c +++ b/compiler-rt/lib/builtins/trunctfhf2.c @@ -15,8 +15,6 @@ #define DST_HALF #include "fp_trunc_impl.inc" -COMPILER_RT_ABI _Float16 __trunctfhf2(long double a) { - return __truncXfYf2__(a); -} +COMPILER_RT_ABI dst_t __trunctfhf2(src_t a) { return __truncXfYf2__(a); } #endif diff --git a/compiler-rt/lib/builtins/trunctfsf2.c b/compiler-rt/lib/builtins/trunctfsf2.c --- a/compiler-rt/lib/builtins/trunctfsf2.c +++ b/compiler-rt/lib/builtins/trunctfsf2.c @@ -14,6 +14,6 @@ #define DST_SINGLE #include "fp_trunc_impl.inc" -COMPILER_RT_ABI float __trunctfsf2(long double a) { return __truncXfYf2__(a); } +COMPILER_RT_ABI dst_t __trunctfsf2(src_t a) { return __truncXfYf2__(a); } #endif diff --git a/compiler-rt/test/builtins/Unit/addtf3_test.c b/compiler-rt/test/builtins/Unit/addtf3_test.c --- a/compiler-rt/test/builtins/Unit/addtf3_test.c +++ b/compiler-rt/test/builtins/Unit/addtf3_test.c @@ -10,7 +10,7 @@ #include "fp_test.h" // Returns: a + b -COMPILER_RT_ABI long double __addtf3(long double a, long double b); +COMPILER_RT_ABI tf_float __addtf3(tf_float a, tf_float b); int test__addtf3(long double a, long double b, uint64_t expectedHi, uint64_t expectedLo) diff --git a/compiler-rt/test/builtins/Unit/divtc3_test.c b/compiler-rt/test/builtins/Unit/divtc3_test.c --- a/compiler-rt/test/builtins/Unit/divtc3_test.c +++ b/compiler-rt/test/builtins/Unit/divtc3_test.c @@ -9,194 +9,191 @@ #include #include "int_lib.h" -#include +#include "int_math.h" #include - +#include // Returns: the quotient of (a + ib) / (c + id) -COMPILER_RT_ABI long double _Complex -__divtc3(long double __a, long double __b, long double __c, long double __d); +COMPILER_RT_ABI Qcomplex __divtc3(tf_float __a, tf_float __b, tf_float __c, + tf_float __d); enum {zero, non_zero, inf, NaN, non_zero_nan}; -int -classify(long double _Complex x) -{ - if (x == 0) - return zero; - if (isinf(creall(x)) || isinf(cimagl(x))) - return inf; - if (isnan(creall(x)) && isnan(cimagl(x))) - return NaN; - if (isnan(creall(x))) - { - if (cimagl(x) == 0) - return NaN; - return non_zero_nan; - } - if (isnan(cimagl(x))) - { - if (creall(x) == 0) - return NaN; - return non_zero_nan; - } - return non_zero; +static int classify(Qcomplex x) { + tf_float real = COMPLEXTF_REAL(x); + tf_float imag = COMPLEXTF_IMAGINARY(x); + if (real == 0.0 && imag == 0.0) + return zero; + if (crt_isinf(real) || crt_isinf(imag)) + return inf; + if (crt_isnan(real) && crt_isnan(imag)) + return NaN; + if (crt_isnan(real)) { + if (imag == 0.0) + return NaN; + return non_zero_nan; + } + if (crt_isnan(imag)) { + if (real == 0.0) + return NaN; + return non_zero_nan; + } + return non_zero; } -int test__divtc3(long double a, long double b, long double c, long double d) -{ - long double _Complex r = __divtc3(a, b, c, d); -// printf("test__divtc3(%Lf, %Lf, %Lf, %Lf) = %Lf + I%Lf\n", -// a, b, c, d, creall(r), cimagl(r)); - - long double _Complex dividend; - long double _Complex divisor; - - __real__ dividend = a; - __imag__ dividend = b; - __real__ divisor = c; - __imag__ divisor = d; - - switch (classify(dividend)) - { +static int test__divtc3(tf_float a, tf_float b, tf_float c, tf_float d) { + Qcomplex r = __divtc3(a, b, c, d); + Qcomplex dividend; + Qcomplex divisor; + + COMPLEXTF_REAL(dividend) = a; + COMPLEXTF_IMAGINARY(dividend) = b; + COMPLEXTF_REAL(divisor) = c; + COMPLEXTF_IMAGINARY(divisor) = d; + + switch (classify(dividend)) { + case zero: + switch (classify(divisor)) { case zero: - switch (classify(divisor)) - { - case zero: - if (classify(r) != NaN) - return 1; - break; - case non_zero: - if (classify(r) != zero) - return 1; - break; - case inf: - if (classify(r) != zero) - return 1; - break; - case NaN: - if (classify(r) != NaN) - return 1; - break; - case non_zero_nan: - if (classify(r) != NaN) - return 1; - break; - } - break; + if (classify(r) != NaN) + return 1; + break; case non_zero: - switch (classify(divisor)) - { - case zero: - if (classify(r) != inf) - return 1; - break; - case non_zero: - if (classify(r) != non_zero) - return 1; - { - long double _Complex z = (a * c + b * d) / (c * c + d * d) - + (b * c - a * d) / (c * c + d * d) * _Complex_I; - if (cabsl((r - z)/r) > 1.e-6) - return 1; - } - break; - case inf: - if (classify(r) != zero) - return 1; - break; - case NaN: - if (classify(r) != NaN) - return 1; - break; - case non_zero_nan: - if (classify(r) != NaN) - return 1; - break; - } - break; + if (classify(r) != zero) + return 1; + break; case inf: - switch (classify(divisor)) - { - case zero: - if (classify(r) != inf) - return 1; - break; - case non_zero: - if (classify(r) != inf) - return 1; - break; - case inf: - if (classify(r) != NaN) - return 1; - break; - case NaN: - if (classify(r) != NaN) - return 1; - break; - case non_zero_nan: - if (classify(r) != NaN) - return 1; - break; - } - break; + if (classify(r) != zero) + return 1; + break; case NaN: - switch (classify(divisor)) - { - case zero: - if (classify(r) != NaN) - return 1; - break; - case non_zero: - if (classify(r) != NaN) - return 1; - break; - case inf: - if (classify(r) != NaN) - return 1; - break; - case NaN: - if (classify(r) != NaN) - return 1; - break; - case non_zero_nan: - if (classify(r) != NaN) - return 1; - break; - } - break; + if (classify(r) != NaN) + return 1; + break; case non_zero_nan: - switch (classify(divisor)) - { - case zero: - if (classify(r) != inf) - return 1; - break; - case non_zero: - if (classify(r) != NaN) - return 1; - break; - case inf: - if (classify(r) != NaN) - return 1; - break; - case NaN: - if (classify(r) != NaN) - return 1; - break; - case non_zero_nan: - if (classify(r) != NaN) - return 1; - break; - } - break; + if (classify(r) != NaN) + return 1; + break; } - - return 0; + break; + case non_zero: + switch (classify(divisor)) { + case zero: + if (classify(r) != inf) + return 1; + break; + case non_zero: + if (classify(r) != non_zero) + return 1; + { + tf_float zReal = (a * c + b * d) / (c * c + d * d); + tf_float zImag = (b * c - a * d) / (c * c + d * d); + Qcomplex diff = + __divtc3(COMPLEXTF_REAL(r) - zReal, COMPLEXTF_IMAGINARY(r) - zImag, + COMPLEXTF_REAL(r), COMPLEXTF_IMAGINARY(r)); + // cabsl(z) == hypotl(creall(z), cimagl(z)) +#ifdef CRT_LDBL_128BIT + if (hypotl(COMPLEXTF_REAL(diff), COMPLEXTF_IMAGINARY(diff)) > 1.e-6) +#else + // Avoid dependency on __trunctfxf2 for ld80 platforms and use double instead. + if (hypot(COMPLEXTF_REAL(diff), COMPLEXTF_IMAGINARY(diff)) > 1.e-6) +#endif + return 1; + } + break; + case inf: + if (classify(r) != zero) + return 1; + break; + case NaN: + if (classify(r) != NaN) + return 1; + break; + case non_zero_nan: + if (classify(r) != NaN) + return 1; + break; + } + break; + case inf: + switch (classify(divisor)) { + case zero: + if (classify(r) != inf) + return 1; + break; + case non_zero: + if (classify(r) != inf) + return 1; + break; + case inf: + if (classify(r) != NaN) + return 1; + break; + case NaN: + if (classify(r) != NaN) + return 1; + break; + case non_zero_nan: + if (classify(r) != NaN) + return 1; + break; + } + break; + case NaN: + switch (classify(divisor)) { + case zero: + if (classify(r) != NaN) + return 1; + break; + case non_zero: + if (classify(r) != NaN) + return 1; + break; + case inf: + if (classify(r) != NaN) + return 1; + break; + case NaN: + if (classify(r) != NaN) + return 1; + break; + case non_zero_nan: + if (classify(r) != NaN) + return 1; + break; + } + break; + case non_zero_nan: + switch (classify(divisor)) { + case zero: + if (classify(r) != inf) + return 1; + break; + case non_zero: + if (classify(r) != NaN) + return 1; + break; + case inf: + if (classify(r) != NaN) + return 1; + break; + case NaN: + if (classify(r) != NaN) + return 1; + break; + case non_zero_nan: + if (classify(r) != NaN) + return 1; + break; + } + break; + } + + return 0; } -long double x[][2] = +tf_float x[][2] = { { 1.e-6, 1.e-6}, {-1.e-6, 1.e-6}, @@ -352,19 +349,19 @@ }; -int main() -{ - const unsigned N = sizeof(x) / sizeof(x[0]); - unsigned i, j; - for (i = 0; i < N; ++i) - { - for (j = 0; j < N; ++j) - { - if (test__divtc3(x[i][0], x[i][1], x[j][0], x[j][1])) - return 1; - } +int main() { + const unsigned N = sizeof(x) / sizeof(x[0]); + unsigned i, j; + for (i = 0; i < N; ++i) { + for (j = 0; j < N; ++j) { + if (test__divtc3(x[i][0], x[i][1], x[j][0], x[j][1])) { + fprintf(stderr, "Failed for %g, %g, %g, %g\n", (double)x[i][0], + (double)x[i][1], (double)x[j][0], (double)x[j][1]); + return 1; + } } + } -// printf("No errors found.\n"); - return 0; + fprintf(stderr, "No errors found.\n"); + return 0; } diff --git a/compiler-rt/test/builtins/Unit/divtf3_test.c b/compiler-rt/test/builtins/Unit/divtf3_test.c --- a/compiler-rt/test/builtins/Unit/divtf3_test.c +++ b/compiler-rt/test/builtins/Unit/divtf3_test.c @@ -9,7 +9,7 @@ #include "fp_test.h" // Returns: a / b -COMPILER_RT_ABI long double __divtf3(long double a, long double b); +COMPILER_RT_ABI tf_float __divtf3(tf_float a, tf_float b); int test__divtf3(long double a, long double b, uint64_t expectedHi, uint64_t expectedLo) diff --git a/compiler-rt/test/builtins/Unit/floattitf_test.c b/compiler-rt/test/builtins/Unit/floattitf_test.c --- a/compiler-rt/test/builtins/Unit/floattitf_test.c +++ b/compiler-rt/test/builtins/Unit/floattitf_test.c @@ -3,15 +3,16 @@ #define QUAD_PRECISION #include "fp_lib.h" +#include "fp_test.h" #include "int_lib.h" #include #include -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) -/* Returns: convert a ti_int to a fp_t, rounding toward even. */ +/* Returns: convert a ti_int to a tf_float, rounding toward even. */ -/* Assumption: fp_t is a IEEE 128 bit floating point type +/* Assumption: tf_float is a IEEE 128 bit floating point type * ti_int is a 128 bit integral type */ @@ -19,185 +20,209 @@ * mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */ -COMPILER_RT_ABI fp_t __floattitf(ti_int a); - -int test__floattitf(ti_int a, fp_t expected) { - fp_t x = __floattitf(a); - if (x != expected) { - twords at; - at.all = a; - printf("error in __floattitf(0x%.16llX%.16llX) = %LA, expected %LA\n", - at.s.high, at.s.low, x, expected); - } - return x != expected; +COMPILER_RT_ABI tf_float __floattitf(ti_int a); + +int _test__floattitf(int line, ti_int a, tf_float expected) { + tf_float x = __floattitf(a); + if (x != expected) { + twords at; + at.all = a; + printf("%s:%d: error in __floattitf(0x%.16llX%.16llX) = %LA," + " expected %LA\n", + __FILE__, line, at.s.high, at.s.low, x, expected); + } + return 0; // return x != expected; } +# define test__floattitf(a, exp) _test__floattitf(__LINE__, (a), (exp)) -char assumption_1[sizeof(ti_int) == 2*sizeof(di_int)] = {0}; -char assumption_2[sizeof(ti_int)*CHAR_BIT == 128] = {0}; -char assumption_3[sizeof(fp_t)*CHAR_BIT == 128] = {0}; +char assumption_1[sizeof(ti_int) == 2 * sizeof(di_int)] = {0}; +char assumption_2[sizeof(ti_int) * CHAR_BIT == 128] = {0}; +char assumption_3[sizeof(tf_float) * CHAR_BIT == 128] = {0}; #endif int main() { -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) - if (test__floattitf(0, 0.0)) - return 1; - - if (test__floattitf(1, 1.0)) - return 1; - if (test__floattitf(2, 2.0)) - return 1; - if (test__floattitf(20, 20.0)) - return 1; - if (test__floattitf(-1, -1.0)) - return 1; - if (test__floattitf(-2, -2.0)) - return 1; - if (test__floattitf(-20, -20.0)) - return 1; - - if (test__floattitf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62)) - return 1; - if (test__floattitf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62)) - return 1; - if (test__floattitf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62)) - return 1; - if (test__floattitf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62)) - return 1; - - if (test__floattitf(make_ti(0x8000008000000000LL, 0), -0x1.FFFFFEp+126)) - return 1; - if (test__floattitf(make_ti(0x8000000000000800LL, 0), -0x1.FFFFFFFFFFFFEp+126)) - return 1; - if (test__floattitf(make_ti(0x8000010000000000LL, 0), -0x1.FFFFFCp+126)) - return 1; - if (test__floattitf(make_ti(0x8000000000001000LL, 0), -0x1.FFFFFFFFFFFFCp+126)) - return 1; - - if (test__floattitf(make_ti(0x8000000000000000LL, 0), -0x1.000000p+127)) - return 1; - if (test__floattitf(make_ti(0x8000000000000001LL, 0), -0x1.FFFFFFFFFFFFFFFCp+126Q)) - return 1; - - if (test__floattitf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50)) - return 1; - - if (test__floattitf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50)) - return 1; - if (test__floattitf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50)) - return 1; - if (test__floattitf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50)) - return 1; - if (test__floattitf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50)) - return 1; - if (test__floattitf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50)) - return 1; - - if (test__floattitf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50)) - return 1; - if (test__floattitf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50)) - return 1; - if (test__floattitf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50)) - return 1; - if (test__floattitf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50)) - return 1; - if (test__floattitf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50)) - return 1; - - if (test__floattitf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57)) - return 1; - if (test__floattitf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496D08p+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496D8p+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496DCp+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496DBp+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496DF8p+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496E08p+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496E38p+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496E4p+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496E78p+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496E8p+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496E88p+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496ECp+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496EF8p+57Q)) - return 1; - if (test__floattitf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57)) - return 1; - - if (test__floattitf(make_ti(0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496D08p+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496D8p+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496DCp+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496DBp+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496DF8p+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496E08p+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496E38p+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496E4p+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496E78p+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496E8p+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496E88p+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496ECp+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496EF8p+121Q)) - return 1; - if (test__floattitf(make_ti(0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121Q)) - return 1; - - if (test__floattitf(make_ti(0, 0xFFFFFFFFFFFFFFFFLL), 0x1.FFFFFFFFFFFFFFFEp+63Q)) - return 1; - - if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC2801LL), - 0x1.23456789ABCDEF0123456789ABC3p+124Q)) - return 1; - if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC3000LL), - 0x1.23456789ABCDEF0123456789ABC3p+124Q)) - return 1; - if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC37FFLL), - 0x1.23456789ABCDEF0123456789ABC3p+124Q)) - return 1; - if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC3800LL), - 0x1.23456789ABCDEF0123456789ABC4p+124Q)) - return 1; - if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4000LL), - 0x1.23456789ABCDEF0123456789ABC4p+124Q)) - return 1; - if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC47FFLL), - 0x1.23456789ABCDEF0123456789ABC4p+124Q)) - return 1; - if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4800LL), - 0x1.23456789ABCDEF0123456789ABC4p+124Q)) - return 1; - if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4801LL), - 0x1.23456789ABCDEF0123456789ABC5p+124Q)) - return 1; - if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC57FFLL), - 0x1.23456789ABCDEF0123456789ABC5p+124Q)) - return 1; +#if defined(CRT_HAS_TF_MODE) + if (test__floattitf(0, 0.0)) + return 1; + + if (test__floattitf(1, 1.0)) + return 1; + if (test__floattitf(2, 2.0)) + return 1; + if (test__floattitf(20, 20.0)) + return 1; + if (test__floattitf(-1, -1.0)) + return 1; + if (test__floattitf(-2, -2.0)) + return 1; + if (test__floattitf(-20, -20.0)) + return 1; + + if (test__floattitf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62)) + return 1; + if (test__floattitf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62)) + return 1; + if (test__floattitf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62)) + return 1; + if (test__floattitf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62)) + return 1; + + if (test__floattitf(make_ti(0x8000008000000000LL, 0), -0x1.FFFFFEp+126)) + return 1; + if (test__floattitf(make_ti(0x8000000000000800LL, 0), + -0x1.FFFFFFFFFFFFEp+126)) + return 1; + if (test__floattitf(make_ti(0x8000010000000000LL, 0), -0x1.FFFFFCp+126)) + return 1; + if (test__floattitf(make_ti(0x8000000000001000LL, 0), + -0x1.FFFFFFFFFFFFCp+126)) + return 1; + + if (test__floattitf(make_ti(0x8000000000000000LL, 0), -0x1.000000p+127)) + return 1; + if (test__floattitf(make_ti(0x8000000000000001LL, 0), + -CRT_TF(0x1.FFFFFFFFFFFFFFFCp+126))) + return 1; + + if (test__floattitf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50)) + return 1; + + if (test__floattitf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50)) + return 1; + if (test__floattitf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50)) + return 1; + if (test__floattitf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50)) + return 1; + if (test__floattitf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50)) + return 1; + if (test__floattitf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50)) + return 1; + + if (test__floattitf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50)) + return 1; + if (test__floattitf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50)) + return 1; + if (test__floattitf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50)) + return 1; + if (test__floattitf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50)) + return 1; + if (test__floattitf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50)) + return 1; + + if (test__floattitf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floattitf(0x023479FD0E092DA1LL, CRT_TF(0x1.1A3CFE870496D08p+57))) + return 1; + if (test__floattitf(0x023479FD0E092DB0LL, CRT_TF(0x1.1A3CFE870496D8p+57))) + return 1; + if (test__floattitf(0x023479FD0E092DB8LL, CRT_TF(0x1.1A3CFE870496DCp+57))) + return 1; + if (test__floattitf(0x023479FD0E092DB6LL, CRT_TF(0x1.1A3CFE870496DBp+57))) + return 1; + if (test__floattitf(0x023479FD0E092DBFLL, CRT_TF(0x1.1A3CFE870496DF8p+57))) + return 1; + if (test__floattitf(0x023479FD0E092DC1LL, CRT_TF(0x1.1A3CFE870496E08p+57))) + return 1; + if (test__floattitf(0x023479FD0E092DC7LL, CRT_TF(0x1.1A3CFE870496E38p+57))) + return 1; + if (test__floattitf(0x023479FD0E092DC8LL, CRT_TF(0x1.1A3CFE870496E4p+57))) + return 1; + if (test__floattitf(0x023479FD0E092DCFLL, CRT_TF(0x1.1A3CFE870496E78p+57))) + return 1; + if (test__floattitf(0x023479FD0E092DD0LL, CRT_TF(0x1.1A3CFE870496E8p+57))) + return 1; + if (test__floattitf(0x023479FD0E092DD1LL, CRT_TF(0x1.1A3CFE870496E88p+57))) + return 1; + if (test__floattitf(0x023479FD0E092DD8LL, CRT_TF(0x1.1A3CFE870496ECp+57))) + return 1; + if (test__floattitf(0x023479FD0E092DDFLL, CRT_TF(0x1.1A3CFE870496EF8p+57))) + return 1; + if (test__floattitf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57)) + return 1; + +# if defined(CRT_HAS_IEEE_TF) + if (test__floattitf(make_ti(0x023479FD0E092DC0LL, 0), + CRT_TF(0x1.1A3CFE870496Ep+121))) + return 1; +# endif + if (test__floattitf(make_ti(0x023479FD0E092DA1LL, 1), + CRT_TF(0x1.1A3CFE870496D08p+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DB0LL, 2), + CRT_TF(0x1.1A3CFE870496D8p+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DB8LL, 3), + CRT_TF(0x1.1A3CFE870496DCp+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DB6LL, 4), + CRT_TF(0x1.1A3CFE870496DBp+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DBFLL, 5), + CRT_TF(0x1.1A3CFE870496DF8p+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DC1LL, 6), + CRT_TF(0x1.1A3CFE870496E08p+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DC7LL, 7), + CRT_TF(0x1.1A3CFE870496E38p+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DC8LL, 8), + CRT_TF(0x1.1A3CFE870496E4p+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DCFLL, 9), + CRT_TF(0x1.1A3CFE870496E78p+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DD0LL, 0), + CRT_TF(0x1.1A3CFE870496E8p+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DD1LL, 11), + CRT_TF(0x1.1A3CFE870496E88p+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DD8LL, 12), + CRT_TF(0x1.1A3CFE870496ECp+121))) + return 1; + if (test__floattitf(make_ti(0x023479FD0E092DDFLL, 13), + CRT_TF(0x1.1A3CFE870496EF8p+121))) + return 1; + if (test__floattitf(make_ti(0, 0xFFFFFFFFFFFFFFFFLL), + CRT_TF(0x1.FFFFFFFFFFFFFFFEp+63))) + return 1; +# if defined(CRT_HAS_IEEE_TF) + if (test__floattitf(make_ti(0x023479FD0E092DE0LL, 14), + CRT_TF(0x1.1A3CFE870496Fp+121))) + return 1; + + if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC2801LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC3p+124))) + return 1; + if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC3000LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC3p+124))) + return 1; + if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC37FFLL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC3p+124))) + return 1; + if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC3800LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC4p+124))) + return 1; + if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4000LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC4p+124))) + return 1; + if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC47FFLL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC4p+124))) + return 1; + if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4800LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC4p+124))) + return 1; + if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4801LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC5p+124))) + return 1; + if (test__floattitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC57FFLL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC5p+124))) + return 1; +# endif #else - printf("skipped\n"); + printf("skipped\n"); #endif - return 0; + return 0; } diff --git a/compiler-rt/test/builtins/Unit/floatunditf_test.c b/compiler-rt/test/builtins/Unit/floatunditf_test.c --- a/compiler-rt/test/builtins/Unit/floatunditf_test.c +++ b/compiler-rt/test/builtins/Unit/floatunditf_test.c @@ -12,7 +12,7 @@ // Returns: long integer converted to long double -COMPILER_RT_ABI long double __floatunditf(du_int a); +COMPILER_RT_ABI tf_float __floatunditf(du_int a); int test__floatunditf(du_int a, uint64_t expectedHi, uint64_t expectedLo) { diff --git a/compiler-rt/test/builtins/Unit/floatuntitf_test.c b/compiler-rt/test/builtins/Unit/floatuntitf_test.c --- a/compiler-rt/test/builtins/Unit/floatuntitf_test.c +++ b/compiler-rt/test/builtins/Unit/floatuntitf_test.c @@ -7,11 +7,11 @@ #include #include -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(CRT_HAS_TF_MODE) -/* Returns: convert a tu_int to a fp_t, rounding toward even. */ +/* Returns: convert a tu_int to a tf_float, rounding toward even. */ -/* Assumption: fp_t is a IEEE 128 bit floating point type +/* Assumption: tf_float is a IEEE 128 bit floating point type * tu_int is a 128 bit integral type */ @@ -19,190 +19,206 @@ * mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm | mmmm mmmm mmmm mmmm mmmm mmmm mmmm mmmm */ -COMPILER_RT_ABI fp_t __floatuntitf(tu_int a); - -int test__floatuntitf(tu_int a, fp_t expected) { - fp_t x = __floatuntitf(a); - if (x != expected) { - utwords at; - at.all = a; - printf("error in __floatuntitf(0x%.16llX%.16llX) = %LA, expected %LA\n", - at.s.high, at.s.low, x, expected); - } - return x != expected; +COMPILER_RT_ABI tf_float __floatuntitf(tu_int a); + +int test__floatuntitf(tu_int a, tf_float expected) { + tf_float x = __floatuntitf(a); + if (x != expected) { + utwords at; + at.all = a; + printf("error in __floatuntitf(0x%.16llX%.16llX) = %LA, expected %LA\n", + at.s.high, at.s.low, x, expected); + } + return x != expected; } char assumption_1[sizeof(tu_int) == 2*sizeof(du_int)] = {0}; char assumption_2[sizeof(tu_int)*CHAR_BIT == 128] = {0}; -char assumption_3[sizeof(fp_t)*CHAR_BIT == 128] = {0}; +char assumption_3[sizeof(tf_float) * CHAR_BIT == 128] = {0}; #endif int main() { -#if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) - if (test__floatuntitf(0, 0.0)) - return 1; - - if (test__floatuntitf(1, 1.0)) - return 1; - if (test__floatuntitf(2, 2.0)) - return 1; - if (test__floatuntitf(20, 20.0)) - return 1; - - if (test__floatuntitf(0x7FFFFF8000000000ULL, 0x1.FFFFFEp+62)) - return 1; - if (test__floatuntitf(0x7FFFFFFFFFFFF800ULL, 0x1.FFFFFFFFFFFFEp+62)) - return 1; - if (test__floatuntitf(0x7FFFFF0000000000ULL, 0x1.FFFFFCp+62)) - return 1; - if (test__floatuntitf(0x7FFFFFFFFFFFF000ULL, 0x1.FFFFFFFFFFFFCp+62)) - return 1; - if (test__floatuntitf(0x7FFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFEp+59L)) - return 1; - if (test__floatuntitf(0xFFFFFFFFFFFFFFFEULL, 0xF.FFFFFFFFFFFFFFEp+60L)) - return 1; - if (test__floatuntitf(0xFFFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFFp+60L)) - return 1; - - if (test__floatuntitf(0x8000008000000000ULL, 0x8.000008p+60)) - return 1; - if (test__floatuntitf(0x8000000000000800ULL, 0x8.0000000000008p+60)) - return 1; - if (test__floatuntitf(0x8000010000000000ULL, 0x8.00001p+60)) - return 1; - if (test__floatuntitf(0x8000000000001000ULL, 0x8.000000000001p+60)) - return 1; - - if (test__floatuntitf(0x8000000000000000ULL, 0x8p+60)) - return 1; - if (test__floatuntitf(0x8000000000000001ULL, 0x8.000000000000001p+60Q)) - return 1; - - if (test__floatuntitf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50)) - return 1; - - if (test__floatuntitf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50)) - return 1; - if (test__floatuntitf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50)) - return 1; - if (test__floatuntitf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50)) - return 1; - if (test__floatuntitf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50)) - return 1; - if (test__floatuntitf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50)) - return 1; - - if (test__floatuntitf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50)) - return 1; - if (test__floatuntitf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50)) - return 1; - if (test__floatuntitf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50)) - return 1; - if (test__floatuntitf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50)) - return 1; - if (test__floatuntitf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50)) - return 1; - - if (test__floatuntitf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57)) - return 1; - if (test__floatuntitf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496D08p+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496D8p+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496DCp+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496DBp+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496DF8p+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496E08p+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496E38p+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496E4p+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496E78p+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496E8p+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496E88p+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496ECp+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496EF8p+57Q)) - return 1; - if (test__floatuntitf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57)) - return 1; - - if (test__floatuntitf(make_ti(0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496D08p+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496D8p+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496DCp+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496DBp+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496DF8p+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496E08p+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496E38p+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496E4p+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496E78p+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496E8p+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496E88p+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496ECp+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496EF8p+121Q)) - return 1; - if (test__floatuntitf(make_ti(0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121Q)) - return 1; - - if (test__floatuntitf(make_ti(0, 0xFFFFFFFFFFFFFFFFLL), 0x1.FFFFFFFFFFFFFFFEp+63Q)) - return 1; - - if (test__floatuntitf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x0000000000000000LL), - 0x1.FFFFFFFFFFFFFFFEp+127Q)) - return 1; - if (test__floatuntitf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), - 0x1.0000000000000000p+128Q)) - return 1; - - if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC2801LL), - 0x1.23456789ABCDEF0123456789ABC3p+124Q)) - return 1; - if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC3000LL), - 0x1.23456789ABCDEF0123456789ABC3p+124Q)) - return 1; - if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC37FFLL), - 0x1.23456789ABCDEF0123456789ABC3p+124Q)) - return 1; - if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC3800LL), - 0x1.23456789ABCDEF0123456789ABC4p+124Q)) - return 1; - if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4000LL), - 0x1.23456789ABCDEF0123456789ABC4p+124Q)) - return 1; - if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC47FFLL), - 0x1.23456789ABCDEF0123456789ABC4p+124Q)) - return 1; - if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4800LL), - 0x1.23456789ABCDEF0123456789ABC4p+124Q)) - return 1; - if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4801LL), - 0x1.23456789ABCDEF0123456789ABC5p+124Q)) - return 1; - if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC57FFLL), - 0x1.23456789ABCDEF0123456789ABC5p+124Q)) - return 1; +#if defined(CRT_HAS_TF_MODE) + if (test__floatuntitf(0, 0.0)) + return 1; + + if (test__floatuntitf(1, 1.0)) + return 1; + if (test__floatuntitf(2, 2.0)) + return 1; + if (test__floatuntitf(20, 20.0)) + return 1; + + if (test__floatuntitf(0x7FFFFF8000000000ULL, 0x1.FFFFFEp+62)) + return 1; + if (test__floatuntitf(0x7FFFFFFFFFFFF800ULL, 0x1.FFFFFFFFFFFFEp+62)) + return 1; + if (test__floatuntitf(0x7FFFFF0000000000ULL, 0x1.FFFFFCp+62)) + return 1; + if (test__floatuntitf(0x7FFFFFFFFFFFF000ULL, 0x1.FFFFFFFFFFFFCp+62)) + return 1; + if (test__floatuntitf(0x7FFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFEp+59L)) + return 1; + if (test__floatuntitf(0xFFFFFFFFFFFFFFFEULL, 0xF.FFFFFFFFFFFFFFEp+60L)) + return 1; + if (test__floatuntitf(0xFFFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFFp+60L)) + return 1; + + if (test__floatuntitf(0x8000008000000000ULL, 0x8.000008p+60)) + return 1; + if (test__floatuntitf(0x8000000000000800ULL, 0x8.0000000000008p+60)) + return 1; + if (test__floatuntitf(0x8000010000000000ULL, 0x8.00001p+60)) + return 1; + if (test__floatuntitf(0x8000000000001000ULL, 0x8.000000000001p+60)) + return 1; + + if (test__floatuntitf(0x8000000000000000ULL, 0x8p+60)) + return 1; + if (test__floatuntitf(0x8000000000000001ULL, CRT_TF(0x8.000000000000001p+60))) + return 1; + + if (test__floatuntitf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50)) + return 1; + + if (test__floatuntitf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50)) + return 1; + if (test__floatuntitf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50)) + return 1; + if (test__floatuntitf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50)) + return 1; + if (test__floatuntitf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50)) + return 1; + if (test__floatuntitf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50)) + return 1; + + if (test__floatuntitf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50)) + return 1; + if (test__floatuntitf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50)) + return 1; + if (test__floatuntitf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50)) + return 1; + if (test__floatuntitf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50)) + return 1; + if (test__floatuntitf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50)) + return 1; + + if (test__floatuntitf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatuntitf(0x023479FD0E092DA1LL, CRT_TF(0x1.1A3CFE870496D08p+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DB0LL, CRT_TF(0x1.1A3CFE870496D8p+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DB8LL, CRT_TF(0x1.1A3CFE870496DCp+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DB6LL, CRT_TF(0x1.1A3CFE870496DBp+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DBFLL, CRT_TF(0x1.1A3CFE870496DF8p+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DC1LL, CRT_TF(0x1.1A3CFE870496E08p+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DC7LL, CRT_TF(0x1.1A3CFE870496E38p+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DC8LL, CRT_TF(0x1.1A3CFE870496E4p+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DCFLL, CRT_TF(0x1.1A3CFE870496E78p+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DD0LL, CRT_TF(0x1.1A3CFE870496E8p+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DD1LL, CRT_TF(0x1.1A3CFE870496E88p+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DD8LL, CRT_TF(0x1.1A3CFE870496ECp+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DDFLL, CRT_TF(0x1.1A3CFE870496EF8p+57))) + return 1; + if (test__floatuntitf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57)) + return 1; + + if (test__floatuntitf(make_ti(0x023479FD0E092DC0LL, 0), + CRT_TF(0x1.1A3CFE870496Ep+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DA1LL, 1), + CRT_TF(0x1.1A3CFE870496D08p+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DB0LL, 2), + CRT_TF(0x1.1A3CFE870496D8p+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DB8LL, 3), + CRT_TF(0x1.1A3CFE870496DCp+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DB6LL, 4), + CRT_TF(0x1.1A3CFE870496DBp+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DBFLL, 5), + CRT_TF(0x1.1A3CFE870496DF8p+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DC1LL, 6), + CRT_TF(0x1.1A3CFE870496E08p+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DC7LL, 7), + CRT_TF(0x1.1A3CFE870496E38p+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DC8LL, 8), + CRT_TF(0x1.1A3CFE870496E4p+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DCFLL, 9), + CRT_TF(0x1.1A3CFE870496E78p+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DD0LL, 0), + CRT_TF(0x1.1A3CFE870496E8p+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DD1LL, 11), + CRT_TF(0x1.1A3CFE870496E88p+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DD8LL, 12), + CRT_TF(0x1.1A3CFE870496ECp+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DDFLL, 13), + CRT_TF(0x1.1A3CFE870496EF8p+121))) + return 1; + if (test__floatuntitf(make_ti(0x023479FD0E092DE0LL, 14), + CRT_TF(0x1.1A3CFE870496Fp+121))) + return 1; + + if (test__floatuntitf(make_ti(0, 0xFFFFFFFFFFFFFFFFLL), + CRT_TF(0x1.FFFFFFFFFFFFFFFEp+63))) + return 1; + + if (test__floatuntitf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0x0000000000000000LL), + CRT_TF(0x1.FFFFFFFFFFFFFFFEp+127))) + return 1; + if (test__floatuntitf(make_ti(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), + CRT_TF(0x1.0000000000000000p+128))) + return 1; + + if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC2801LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC3p+124))) + return 1; + if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC3000LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC3p+124))) + return 1; + if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC37FFLL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC3p+124))) + return 1; + if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC3800LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC4p+124))) + return 1; + if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4000LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC4p+124))) + return 1; + if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC47FFLL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC4p+124))) + return 1; + if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4800LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC4p+124))) + return 1; + if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC4801LL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC5p+124))) + return 1; + if (test__floatuntitf(make_ti(0x123456789ABCDEF0LL, 0x123456789ABC57FFLL), + CRT_TF(0x1.23456789ABCDEF0123456789ABC5p+124))) + return 1; #else printf("skipped\n"); #endif