diff --git a/SingleSource/Regression/C/BitInt_fixdfqi_test.c b/SingleSource/Regression/C/BitInt_fixdfqi_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixdfqi_test.c @@ -0,0 +1,116 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + signed long long t3; + } s; +} twords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + twords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__fixdfqi(double a, _BitInt(256) expected) +{ + _BitInt(256) x = a; + if (x != expected) + { + twords xt; + xt.all = x; + twords expectedt; + expectedt.all = expected; + printf("error in __fixsfqi(%A) = 0x%.16llX%.16llX%.16llX%.16llX, expected 0x%.16llX%.16llX%.16llX%.16llX\n", + a, xt.s.t3, xt.s.t2, xt.s.t1, xt.s.t0, expectedt.s.t3, expectedt.s.t2, expectedt.s.t1, expectedt.s.t0); + } + return x != expected; +} + +int main() +{ + if (test__fixdfqi(0.0, 0)) + return 1; + + if (test__fixdfqi(0.5, 0)) + return 1; + if (test__fixdfqi(0.99, 0)) + return 1; + if (test__fixdfqi(1.0, 1)) + return 1; + if (test__fixdfqi(1.5, 1)) + return 1; + if (test__fixdfqi(1.99, 1)) + return 1; + if (test__fixdfqi(2.0, 2)) + return 1; + if (test__fixdfqi(2.01, 2)) + return 1; + if (test__fixdfqi(-0.5, 0)) + return 1; + if (test__fixdfqi(-0.99, 0)) + return 1; + if (test__fixdfqi(-1.0, -1)) + return 1; + if (test__fixdfqi(-1.5, -1)) + return 1; + if (test__fixdfqi(-1.99, -1)) + return 1; + if (test__fixdfqi(-2.0, -2)) + return 1; + if (test__fixdfqi(-2.01, -2)) + return 1; + + if (test__fixdfqi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL)) + return 1; + if (test__fixdfqi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL)) + return 1; + + if (test__fixdfqi(-0x1.FFFFFEp+62, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000008000000000LL))) + return 1; + if (test__fixdfqi(-0x1.FFFFFCp+62, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000010000000000LL))) + return 1; + + + if (test__fixdfqi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL)) + return 1; + if (test__fixdfqi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL)) + return 1; + + if (test__fixdfqi(-0x1.FFFFFFFFFFFFFp+62, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000000000000400LL))) + return 1; + if (test__fixdfqi(-0x1.FFFFFFFFFFFFEp+62, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000000000000800LL))) + return 1; + + if (test__fixdfqi(0x1.FFFFFFFFFFFFFp+126, make_qi(0, 0, 0x7FFFFFFFFFFFFC00LL, 0))) + return 1; + if (test__fixdfqi(0x1.FFFFFFFFFFFFEp+126, make_qi(0, 0, 0x7FFFFFFFFFFFF800LL, 0))) + return 1; + + if (test__fixdfqi(-0x1.FFFFFFFFFFFFFp+126, make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000000000000400LL, 0))) + return 1; + if (test__fixdfqi(-0x1.FFFFFFFFFFFFEp+126, make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000000000000800LL, 0))) + return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_fixdfqi_test.reference_output b/SingleSource/Regression/C/BitInt_fixdfqi_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixdfqi_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_fixsfqi_test.c b/SingleSource/Regression/C/BitInt_fixsfqi_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixsfqi_test.c @@ -0,0 +1,101 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + signed long long t3; + } s; +} twords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + twords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__fixsfqi(float a, _BitInt(256) expected) +{ + _BitInt(256) x = a; + if (x != expected) + { + twords xt; + xt.all = x; + twords expectedt; + expectedt.all = expected; + printf("error in __fixsfqi(%A) = 0x%.16llX%.16llX%.16llX%.16llX, expected 0x%.16llX%.16llX%.16llX%.16llX\n", + a, xt.s.t3, xt.s.t2, xt.s.t1, xt.s.t0, expectedt.s.t3, expectedt.s.t2, expectedt.s.t1, expectedt.s.t0); + } + return x != expected; +} + +int main() +{ + if (test__fixsfqi(0.0F, 0)) + return 1; + + if (test__fixsfqi(0.5F, 0)) + return 1; + if (test__fixsfqi(0.99F, 0)) + return 1; + if (test__fixsfqi(1.0F, 1)) + return 1; + if (test__fixsfqi(1.5F, 1)) + return 1; + if (test__fixsfqi(1.99F, 1)) + return 1; + if (test__fixsfqi(2.0F, 2)) + return 1; + if (test__fixsfqi(2.01F, 2)) + return 1; + if (test__fixsfqi(-0.5F, 0)) + return 1; + if (test__fixsfqi(-0.99F, 0)) + return 1; + if (test__fixsfqi(-1.0F, -1)) + return 1; + if (test__fixsfqi(-1.5F, -1)) + return 1; + if (test__fixsfqi(-1.99F, -1)) + return 1; + if (test__fixsfqi(-2.0F, -2)) + return 1; + if (test__fixsfqi(-2.01F, -2)) + return 1; + + if (test__fixsfqi(0x1.FFFFFEp+62F, 0x7FFFFF8000000000LL)) + return 1; + if (test__fixsfqi(0x1.FFFFFCp+62F, 0x7FFFFF0000000000LL)) + return 1; + + if (test__fixsfqi(-0x1.FFFFFEp+62F, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000008000000000LL))) + return 1; + if (test__fixsfqi(-0x1.FFFFFCp+62F, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000010000000000LL))) + return 1; + + if (test__fixsfqi(0x1.FFFFFEp+126F, make_qi(0, 0, 0x7FFFFF8000000000LL, 0))) + return 1; + if (test__fixsfqi(0x1.FFFFFCp+126F, make_qi(0, 0, 0x7FFFFF0000000000LL, 0))) + return 1; + + if (test__fixsfqi(-0x1.FFFFFEp+126F, make_qi(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, + 0x8000008000000000LL, 0))) + return 1; + if (test__fixsfqi(-0x1.FFFFFCp+126F, make_qi(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, + 0x8000010000000000LL, 0))) + return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_fixsfqi_test.reference_output b/SingleSource/Regression/C/BitInt_fixsfqi_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixsfqi_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_fixtfqi_test.c b/SingleSource/Regression/C/BitInt_fixtfqi_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixtfqi_test.c @@ -0,0 +1,97 @@ +#include +#include + +static inline __float128 fromRep128(unsigned long long hi, unsigned long long lo) +{ + unsigned __int128 x = ((unsigned __int128)hi << 64) + lo; + __float128 ret; + memcpy(&ret, &x, 16); + return ret; +} + +static inline __float128 makeInf128(void) +{ + return fromRep128(0x7fff000000000000UL, 0x0UL); +} + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + signed long long t3; + } s; +} twords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + twords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__fixtfqi(__float128 a, _BitInt(256) expected) +{ + _BitInt(256) x = a; + int ret = (x != expected); + + if (ret) + { + twords xt; + xt.all = x; + + twords expectedt; + expectedt.all = expected; + + printf("error in test__fixtfqi(%.20Lf) = 0x%.16llX %.16llX %.16llX %.16llX, " + "expected 0x%.16llX %.16llX %.16llX %.16llX\n", + (long double)a, xt.s.t3, xt.s.t2, xt.s.t1, xt.s.t0, expectedt.s.t3, expectedt.s.t2, expectedt.s.t1, expectedt.s.t0); + } + return ret; +} + +int main() +{ + // FIXME: O2 failed due to FE opts. + // if (test__fixtfqi(makeInf128(), make_qi(0x7fffffffffffffffLL, + // 0xffffffffffffffffLL, + // 0xffffffffffffffffLL, + // 0xffffffffffffffffLL))) + // return 1; + if (test__fixtfqi(0, make_qi(0x0LL, 0x0LL, 0x0LL, 0x0LL))) + return 1; + if (test__fixtfqi(0x1.23456789abcdefp+5q, make_qi(0x0LL, 0x0LL, 0x0LL, 0x24LL))) + return 1; + if (test__fixtfqi(0x1.23456789abcdefp-3q, make_qi(0x0LL, 0x0LL, 0x0LL, 0x0LL))) + return 1; + if (test__fixtfqi(0x1.23456789abcdef12345678p+20q, + make_qi(0x0LL, 0x0LL, 0x0LL, 0x123456LL))) + return 1; + if (test__fixtfqi(0x1.23456789abcdef123456789abcdep+112q, + make_qi(0x0LL, 0x0LL, 0x123456789abcdLL, 0xef123456789abcdeLL))) + return 1; + if (test__fixtfqi(-0x1.23456789abcdef123456789abcdep+112q, + make_qi(0xffffffffffffffffLL, 0xffffffffffffffffLL, 0xFFFEDCBA98765432LL, 0x10EDCBA987654322LL))) + return 1; + // FIXME: O2 failed due to FE opts. + // if (test__fixtfqi(0x1.23456789abcdefp+256q, make_qi(0x7fffffffffffffffLL, + // 0xffffffffffffffffLL, + // 0xffffffffffffffffLL, + // 0xffffffffffffffffLL))) + // return 1; + if (test__fixtfqi(-0x1.23456789abcdefp+20q, make_qi(0xffffffffffffffffLL, + 0xffffffffffffffffLL, + 0xffffffffffffffffLL, + 0xffffffffffedcbaaLL))) + return 1; + // FIXME: O2 failed due to FE opts. + // if (test__fixtfqi(-0x1.23456789abcdefp+256q, make_qi(0x8000000000000000LL, + // 0x0, 0x0, 0x0))) + // return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_fixtfqi_test.reference_output b/SingleSource/Regression/C/BitInt_fixtfqi_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixtfqi_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_fixunsdfqi_test.c b/SingleSource/Regression/C/BitInt_fixunsdfqi_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixunsdfqi_test.c @@ -0,0 +1,89 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + unsigned long long t3; + } s; +} utwords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + utwords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__fixunsdfqi(double a, unsigned _BitInt(256) expected) +{ + unsigned _BitInt(256) x = a; + if (x != expected) + { + utwords xt; + xt.all = x; + utwords expectedt; + expectedt.all = expected; + printf("error in __fixunsdfqi(%A) = 0x%.16llX%.16llX%.16llX%.16llX, expected 0x%.16llX%.16llX%.16llX%.16llX\n", + a, xt.s.t3, xt.s.t2, xt.s.t1, xt.s.t0, expectedt.s.t3, expectedt.s.t2, expectedt.s.t1, expectedt.s.t0); + } + return x != expected; +} + +int main() +{ + if (test__fixunsdfqi(0.0, 0)) + return 1; + + if (test__fixunsdfqi(0.5, 0)) + return 1; + if (test__fixunsdfqi(0.99, 0)) + return 1; + if (test__fixunsdfqi(1.0, 1)) + return 1; + if (test__fixunsdfqi(1.5, 1)) + return 1; + if (test__fixunsdfqi(1.99, 1)) + return 1; + if (test__fixunsdfqi(2.0, 2)) + return 1; + if (test__fixunsdfqi(2.01, 2)) + return 1; + if (test__fixunsdfqi(-0.5, 0)) + return 1; + if (test__fixunsdfqi(-0.99, 0)) + return 1; + + if (test__fixunsdfqi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL)) + return 1; + if (test__fixunsdfqi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL)) + return 1; + + if (test__fixunsdfqi(0x1.FFFFFFFFFFFFFp+63, 0xFFFFFFFFFFFFF800ULL)) + return 1; + if (test__fixunsdfqi(0x1.0000000000000p+63, 0x8000000000000000ULL)) + return 1; + if (test__fixunsdfqi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00ULL)) + return 1; + if (test__fixunsdfqi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800ULL)) + return 1; + + if (test__fixunsdfqi(0x1.FFFFFFFFFFFFFp+127, make_qi(0, 0, 0xFFFFFFFFFFFFF800ULL, 0))) + return 1; + if (test__fixunsdfqi(0x1.0000000000000p+127, make_qi(0, 0, 0x8000000000000000ULL, 0))) + return 1; + if (test__fixunsdfqi(0x1.FFFFFFFFFFFFFp+126, make_qi(0, 0, 0x7FFFFFFFFFFFFC00ULL, 0))) + return 1; + if (test__fixunsdfqi(0x1.FFFFFFFFFFFFEp+126, make_qi(0, 0, 0x7FFFFFFFFFFFF800ULL, 0))) + return 1; + if (test__fixunsdfqi(0x1.0000000000000p+128, make_qi(0, 1, 0, 0))) //256 specific results + return 1; + + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_fixunsdfqi_test.reference_output b/SingleSource/Regression/C/BitInt_fixunsdfqi_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixunsdfqi_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_fixunssfqi_test.c b/SingleSource/Regression/C/BitInt_fixunssfqi_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixunssfqi_test.c @@ -0,0 +1,81 @@ +#include + +typedef union { + unsigned _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + unsigned long long t3; + } s; +} utwords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + utwords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__fixunssfqi(float a, unsigned _BitInt(256) expected) +{ + unsigned _BitInt(256) x = a; + if (x != expected) + { + utwords xt; + xt.all = x; + utwords expectedt; + expectedt.all = expected; + printf("error in __fixunssfqi(%f) = 0x%.16llX%.16llX%.16llX%.16llX, expected 0x%.16llX%.16llX%.16llX%.16llX\n", + a, xt.s.t3, xt.s.t2, xt.s.t1, xt.s.t0, expectedt.s.t3, expectedt.s.t2, expectedt.s.t1, expectedt.s.t0); + } + return x != expected; +} + +int main() +{ + if (test__fixunssfqi(0.0F, 0)) + return 1; + if (test__fixunssfqi(0.5F, 0)) + return 1; + if (test__fixunssfqi(0.99F, 0)) + return 1; + if (test__fixunssfqi(1.0F, 1)) + return 1; + if (test__fixunssfqi(1.5F, 1)) + return 1; + if (test__fixunssfqi(1.99F, 1)) + return 1; + if (test__fixunssfqi(2.0F, 2)) + return 1; + if (test__fixunssfqi(2.01F, 2)) + return 1; + if (test__fixunssfqi(-0.5F, 0)) + return 1; + if (test__fixunssfqi(-0.99F, 0)) + return 1; + + if (test__fixunssfqi(0x1.FFFFFEp+63F, 0xFFFFFF0000000000ULL)) + return 1; + if (test__fixunssfqi(0x1.000000p+63F, 0x8000000000000000ULL)) + return 1; + if (test__fixunssfqi(0x1.FFFFFEp+62F, 0x7FFFFF8000000000LL)) + return 1; + if (test__fixunssfqi(0x1.FFFFFCp+62F, 0x7FFFFF0000000000LL)) + return 1; + + if (test__fixunssfqi(0x1.FFFFFEp+127F, make_qi(0, 0, 0xFFFFFF0000000000ULL, 0))) + return 1; + if (test__fixunssfqi(0x1.000000p+127F, make_qi(0, 0, 0x8000000000000000ULL, 0))) + return 1; + if (test__fixunssfqi(0x1.FFFFFEp+126F, make_qi(0, 0, 0x7FFFFF8000000000LL, 0))) + return 1; + if (test__fixunssfqi(0x1.FFFFFCp+126F, make_qi(0, 0, 0x7FFFFF0000000000LL, 0))) + return 1; + + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_fixunssfqi_test.reference_output b/SingleSource/Regression/C/BitInt_fixunssfqi_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixunssfqi_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_fixunstfqi_test.c b/SingleSource/Regression/C/BitInt_fixunstfqi_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixunstfqi_test.c @@ -0,0 +1,99 @@ +#include +#include + +static inline __float128 fromRep128(unsigned long long hi, unsigned long long lo) +{ + unsigned __int128 x = ((unsigned __int128)hi << 64) + lo; + __float128 ret; + memcpy(&ret, &x, 16); + return ret; +} + +static inline __float128 makeInf128(void) +{ + return fromRep128(0x7fff000000000000UL, 0x0UL); +} + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + unsigned long long t3; + } s; +} twords; + +static __inline _BitInt(256) make_qi(unsigned long long t3, unsigned long long t2, + unsigned long long t1, unsigned long long t0) { + twords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__fixunstfqi(__float128 a, unsigned _BitInt(256) expected) +{ + unsigned _BitInt(256) x = a; + if (x != expected) + { + twords xt; + xt.all = x; + + twords expectedt; + expectedt.all = expected; + + printf("error in __fixunstfqi(%.20Lf) = 0x%.16llX %.16llX %.16llX %.16llX, " + "expected 0x%.16llX %.16llX %.16llX %.16llX\n", + (long double)a, xt.s.t3, xt.s.t2, xt.s.t1, xt.s.t0, expectedt.s.t3, expectedt.s.t2, expectedt.s.t1, expectedt.s.t0); + } + return x != expected; +} + +int main() +{ + // FIXME: O2 failed due to FE opts. + // if (test__fixunstfqi(makeInf128(), make_qi(0xffffffffffffffffLL, + // 0xffffffffffffffffLL, + // 0xffffffffffffffffLL, + // 0xffffffffffffffffLL))) + // return 1; + if (test__fixunstfqi(0.0, 0)) + return 1; + + if (test__fixunstfqi(0.5, 0)) + return 1; + if (test__fixunstfqi(0.99, 0)) + return 1; + if (test__fixunstfqi(1.0, 1)) + return 1; + if (test__fixunstfqi(1.5, 1)) + return 1; + if (test__fixunstfqi(1.99, 1)) + return 1; + if (test__fixunstfqi(2.0, 2)) + return 1; + if (test__fixunstfqi(2.01, 2)) + return 1; + if (test__fixunstfqi(-0.01, 0)) + return 1; + if (test__fixunstfqi(-0.99, 0)) + return 1; + + if (test__fixunstfqi(0x1.p+128q, make_qi(0, 1, 0, 0))) + return 1; + + if (test__fixunstfqi(0x1.FFFFFEp+126q, make_qi(0x0, 0x0, 0x7fffff8000000000LL, 0x0))) + return 1; + if (test__fixunstfqi(0x1.FFFFFEp+127q, make_qi(0, 0, 0xffffff0000000000LL, 0x0))) + return 1; + if (test__fixunstfqi(0x1.FFFFFEp+128q, make_qi(0, 1, 0xFFFFFE0000000000LL, 0))) + return 1; + if (test__fixunstfqi(0x1.FFFFFEp+129q, make_qi(0, 3, 0xFFFFFC0000000000LL, 0))) + return 1; + + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_fixunstfqi_test.reference_output b/SingleSource/Regression/C/BitInt_fixunstfqi_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixunstfqi_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_fixunsxfqi_test.c b/SingleSource/Regression/C/BitInt_fixunsxfqi_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixunsxfqi_test.c @@ -0,0 +1,97 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + unsigned long long t3; + } s; +} utwords; + +static __inline _BitInt(256) make_qi(unsigned long long t3, unsigned long long t2, + unsigned long long t1, unsigned long long t0) { + utwords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__fixunsxfqi(long double a, unsigned _BitInt(256) expected) +{ + unsigned _BitInt(256) x = a; + if (x != expected) + { + utwords xt; + xt.all = x; + utwords expectedt; + expectedt.all = expected; + printf("error in __fixunsxfqi(%Lf) = 0x%.16llX%.16llX%.16llX%.16llX, expected 0x%.16llX%.16llX%.16llX%.16llX\n", + a, xt.s.t3, xt.s.t2, xt.s.t1, xt.s.t0, expectedt.s.t3, expectedt.s.t2, expectedt.s.t1, expectedt.s.t0); + } + return x != expected; +} + + +int main() +{ + if (test__fixunsxfqi(0.0, 0)) + return 1; + + if (test__fixunsxfqi(0.5, 0)) + return 1; + if (test__fixunsxfqi(0.99, 0)) + return 1; + if (test__fixunsxfqi(1.0, 1)) + return 1; + if (test__fixunsxfqi(1.5, 1)) + return 1; + if (test__fixunsxfqi(1.99, 1)) + return 1; + if (test__fixunsxfqi(2.0, 2)) + return 1; + if (test__fixunsxfqi(2.01, 2)) + return 1; + if (test__fixunsxfqi(-0.5, 0)) + return 1; + if (test__fixunsxfqi(-0.99, 0)) + return 1; + + if (test__fixunsxfqi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL)) + return 1; + if (test__fixunsxfqi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL)) + return 1; + + if (test__fixunsxfqi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL)) + return 1; + if (test__fixunsxfqi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL)) + return 1; + + if (test__fixunsxfqi(0x1.FFFFFFFFFFFFFFFEp+63L, 0xFFFFFFFFFFFFFFFFLL)) + return 1; + if (test__fixunsxfqi(0x1.0000000000000002p+63L, 0x8000000000000001LL)) + return 1; + if (test__fixunsxfqi(0x1.0000000000000000p+63L, 0x8000000000000000LL)) + return 1; + if (test__fixunsxfqi(0x1.FFFFFFFFFFFFFFFCp+62L, 0x7FFFFFFFFFFFFFFFLL)) + return 1; + if (test__fixunsxfqi(0x1.FFFFFFFFFFFFFFF8p+62L, 0x7FFFFFFFFFFFFFFELL)) + return 1; + + if (test__fixunsxfqi(0x1.FFFFFFFFFFFFFFFEp+127L, make_qi(0, 0, 0xFFFFFFFFFFFFFFFFLL, 0))) + return 1; + if (test__fixunsxfqi(0x1.0000000000000002p+127L, make_qi(0, 0, 0x8000000000000001LL, 0))) + return 1; + if (test__fixunsxfqi(0x1.0000000000000000p+127L, make_qi(0, 0, 0x8000000000000000LL, 0))) + return 1; + if (test__fixunsxfqi(0x1.FFFFFFFFFFFFFFFCp+126L, make_qi(0, 0, 0x7FFFFFFFFFFFFFFFLL, 0))) + return 1; + if (test__fixunsxfqi(0x1.FFFFFFFFFFFFFFF8p+126L, make_qi(0, 0, 0x7FFFFFFFFFFFFFFELL, 0))) + return 1; + + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_fixunsxfqi_test.reference_output b/SingleSource/Regression/C/BitInt_fixunsxfqi_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixunsxfqi_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_fixxfqi_test.c b/SingleSource/Regression/C/BitInt_fixxfqi_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixxfqi_test.c @@ -0,0 +1,150 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + signed long long t3; + } s; +} twords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + twords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__fixxfqi(long double a, _BitInt(256) expected) +{ + _BitInt(256) x = a; + if (x != expected) + { + twords xt; + xt.all = x; + twords expectedt; + expectedt.all = expected; + printf("error in __fixxfqi(%LA) = 0x%.16llX%.16llX%.16llX%.16llX, expected 0x%.16llX%.16llX%.16llX%.16llX\n", + a, xt.s.t3, xt.s.t2, xt.s.t1, xt.s.t0, expectedt.s.t3, expectedt.s.t2, expectedt.s.t1, expectedt.s.t0); + } + return x != expected; +} + +int main() +{ + if (test__fixxfqi(0.0, 0)) + return 1; + + if (test__fixxfqi(0.5, 0)) + return 1; + if (test__fixxfqi(0.99, 0)) + return 1; + if (test__fixxfqi(1.0, 1)) + return 1; + if (test__fixxfqi(1.5, 1)) + return 1; + if (test__fixxfqi(1.99, 1)) + return 1; + if (test__fixxfqi(2.0, 2)) + return 1; + if (test__fixxfqi(2.01, 2)) + return 1; + if (test__fixxfqi(-0.5, 0)) + return 1; + if (test__fixxfqi(-0.99, 0)) + return 1; + if (test__fixxfqi(-1.0, -1)) + return 1; + if (test__fixxfqi(-1.5, -1)) + return 1; + if (test__fixxfqi(-1.99, -1)) + return 1; + if (test__fixxfqi(-2.0, -2)) + return 1; + if (test__fixxfqi(-2.01, -2)) + return 1; + + if (test__fixxfqi(0x1.FFFFFEp+62, 0x7FFFFF8000000000LL)) + return 1; + if (test__fixxfqi(0x1.FFFFFCp+62, 0x7FFFFF0000000000LL)) + return 1; + + if (test__fixxfqi(-0x1.FFFFFEp+62, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000008000000000LL))) + return 1; + if (test__fixxfqi(-0x1.FFFFFCp+62, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000010000000000LL))) + return 1; + + if (test__fixxfqi(0x1.FFFFFFFFFFFFFp+62, 0x7FFFFFFFFFFFFC00LL)) + return 1; + if (test__fixxfqi(0x1.FFFFFFFFFFFFEp+62, 0x7FFFFFFFFFFFF800LL)) + return 1; + + if (test__fixxfqi(-0x1.FFFFFFFFFFFFFp+62, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000000000000400LL))) + return 1; + if (test__fixxfqi(-0x1.FFFFFFFFFFFFEp+62, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000000000000800LL))) + return 1; + + if (test__fixxfqi(0x1.FFFFFFFFFFFFFFFCp+62L, 0x7FFFFFFFFFFFFFFFLL)) + return 1; + if (test__fixxfqi(0x1.FFFFFFFFFFFFFFF8p+62L, 0x7FFFFFFFFFFFFFFELL)) + return 1; + + if (test__fixxfqi(-0x1.0000000000000000p+63L, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000000000000000LL))) + return 1; + if (test__fixxfqi(-0x1.FFFFFFFFFFFFFFFCp+62L, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000000000000001LL))) + return 1; + if (test__fixxfqi(-0x1.FFFFFFFFFFFFFFF8p+62L, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000000000000002LL))) + return 1; + + if (test__fixxfqi(0x1.FFFFFFFFFFFFFFFEp+126L, make_qi(0, 0, 0x7FFFFFFFFFFFFFFFLL, + 0x8000000000000000LL))) + return 1; + if (test__fixxfqi(0x1.FFFFFFFFFFFFFFFCp+126L, make_qi(0, 0, 0x7FFFFFFFFFFFFFFFLL, + 0x0000000000000000LL))) + + return 1; + + if (test__fixxfqi(-0x1.0000000000000000p+127L, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000000000000000LL, + 0x0000000000000000LL))) + return 1; + if (test__fixxfqi(-0x1.FFFFFFFFFFFFFFFEp+126L, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000000000000000LL, + 0x8000000000000000LL))) + return 1; + if (test__fixxfqi(-0x1.FFFFFFFFFFFFFFFCp+126L, make_qi(0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, + 0x8000000000000001LL, + 0x0000000000000000LL))) + return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_fixxfqi_test.reference_output b/SingleSource/Regression/C/BitInt_fixxfqi_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_fixxfqi_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_floatqidf_test.c b/SingleSource/Regression/C/BitInt_floatqidf_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatqidf_test.c @@ -0,0 +1,178 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + signed long long t3; + } s; +} twords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + twords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +double __floatqidf(_BitInt(256) a); + +int test__floatqidf(_BitInt(256) a, double expected) +{ + double x = a; + if (x != expected) + { + twords at; + at.all = a; + printf("error in __floatqidf(0x%.16llX%.16llX%.16llX%.16llX) = %a, expected %a\n", + at.s.t3, at.s.t2, at.s.t1, at.s.t0, x, expected); + } + return x != expected; +} + +int test__floatqidfNaN(_BitInt(256) a, double expected) +{ + double x = a; + if (!(x != expected)) + { + twords at; + at.all = a; + printf("error in __floatqidf(0x%.16llX%.16llX) = %a, expected %a\n", + at.s.t1, at.s.t0, x, expected); + } + return !(x != expected); +} + +int main() +{ + if (test__floatqidf(0, 0.0)) + return 1; + + if (test__floatqidf(1, 1.0)) + return 1; + if (test__floatqidf(2, 2.0)) + return 1; + if (test__floatqidf(20, 20.0)) + return 1; + if (test__floatqidf(-1, -1.0)) + return 1; + if (test__floatqidf(-2, -2.0)) + return 1; + + if (test__floatqidf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62)) + return 1; + if (test__floatqidf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62)) + return 1; + if (test__floatqidf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62)) + return 1; + if (test__floatqidf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62)) + return 1; + + if (test__floatqidf(make_qi(0x8000008000000000LL, 0, 0, 0), -0x1.FFFFFEp+254)) // 256 specific + return 1; + if (test__floatqidf(make_qi(0x8000000000000800LL, 0, 0, 0), -0x1.FFFFFFFFFFFFEp+254)) // 256 specific + return 1; + if (test__floatqidf(make_qi(0x8000010000000000LL, 0, 0, 0), -0x1.FFFFFCp+254)) // 256 specific + return 1; + if (test__floatqidf(make_qi(0x8000000000001000LL, 0, 0, 0), -0x1.FFFFFFFFFFFFCp+254)) // 256 specific + return 1; + + if (test__floatqidf(make_qi(0x8000000000000000LL, 0, 0, 0), -0x1.000000p+255)) // 256 specific + return 1; + if (test__floatqidf(make_qi(0x8000000000000001LL, 0, 0, 0), -0x1.000000p+255)) // 256 specific + return 1; + + if (test__floatqidf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50)) + return 1; + + if (test__floatqidf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50)) + return 1; + if (test__floatqidf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50)) + return 1; + if (test__floatqidf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50)) + return 1; + if (test__floatqidf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50)) + return 1; + if (test__floatqidf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50)) + return 1; + + if (test__floatqidf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50)) + return 1; + if (test__floatqidf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50)) + return 1; + if (test__floatqidf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50)) + return 1; + if (test__floatqidf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50)) + return 1; + if (test__floatqidf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50)) + return 1; + + if (test__floatqidf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496Dp+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496Fp+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496Fp+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496Fp+57)) + return 1; + if (test__floatqidf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57)) + return 1; + + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496Dp+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496Fp+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496Fp+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496Fp+121)) + return 1; + if (test__floatqidf(make_qi(0, 0, 0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121)) + return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_floatqidf_test.reference_output b/SingleSource/Regression/C/BitInt_floatqidf_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatqidf_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_floatqisf_test.c b/SingleSource/Regression/C/BitInt_floatqisf_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatqisf_test.c @@ -0,0 +1,140 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + signed long long t3; + } s; +} twords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + twords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__floatqisf(_BitInt(256) a, float expected) +{ + float x = a; + if (x != expected) + { + twords at; + at.all = a; + printf("error in __floatqisf(0x%.16llX%.16llX) = %a, expected %a\n", + at.s.t1, at.s.t0, x, expected); + } + return x != expected; +} + +int test__floatqisfNaN(_BitInt(256) a, float expected) +{ + float x = a; + if (!(x != expected)) + { + twords at; + at.all = a; + printf("error in __floatqisf(0x%.16llX%.16llX) = %a, expected %a\n", + at.s.t1, at.s.t0, x, expected); + } + return !(x != expected); +} + +int main() +{ + if (test__floatqisf(0, 0.0F)) + return 1; + + if (test__floatqisf(1, 1.0F)) + return 1; + if (test__floatqisf(2, 2.0F)) + return 1; + if (test__floatqisf(-1, -1.0F)) + return 1; + if (test__floatqisf(-2, -2.0F)) + return 1; + + if (test__floatqisf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62F)) + return 1; + if (test__floatqisf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62F)) + return 1; + + if (test__floatqisf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, 0x8000008000000000LL), + -0x1.FFFFFEp+62F)) + return 1; + if (test__floatqisf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, 0x8000010000000000LL), + -0x1.FFFFFCp+62F)) + return 1; + + if (test__floatqisf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, 0x8000000000000000LL), + -0x1.000000p+63F)) + return 1; + if (test__floatqisf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, + 0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL), + -0x1.000000p+63F)) + return 1; + + if (test__floatqisf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50F)) + return 1; + + if (test__floatqisf(0x0007FB72EA000000LL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatqisf(0x0007FB72EB000000LL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatqisf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatqisf(0x0007FB72EC000000LL, 0x1.FEDCBCp+50F)) + return 1; + if (test__floatqisf(0x0007FB72E8000001LL, 0x1.FEDCBAp+50F)) + return 1; + + if (test__floatqisf(0x0007FB72E6000000LL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatqisf(0x0007FB72E7000000LL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatqisf(0x0007FB72E7FFFFFFLL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatqisf(0x0007FB72E4000001LL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatqisf(0x0007FB72E4000000LL, 0x1.FEDCB8p+50F)) + return 1; + + if (test__floatqisf(make_qi(0, 0, 0x0007FB72E8000000LL, 0), 0x1.FEDCBAp+114F)) + return 1; + + if (test__floatqisf(make_qi(0, 0, 0x0007FB72EA000000LL, 0), 0x1.FEDCBAp+114F)) + return 1; + if (test__floatqisf(make_qi(0, 0, 0x0007FB72EB000000LL, 0), 0x1.FEDCBAp+114F)) + return 1; + if (test__floatqisf(make_qi(0, 0, 0x0007FB72EBFFFFFFLL, 0), 0x1.FEDCBAp+114F)) + return 1; + if (test__floatqisf(make_qi(0, 0, 0x0007FB72EC000000LL, 0), 0x1.FEDCBCp+114F)) + return 1; + if (test__floatqisf(make_qi(0, 0, 0x0007FB72E8000001LL, 0), 0x1.FEDCBAp+114F)) + return 1; + + if (test__floatqisf(make_qi(0, 0, 0x0007FB72E6000000LL, 0), 0x1.FEDCBAp+114F)) + return 1; + if (test__floatqisf(make_qi(0, 0, 0x0007FB72E7000000LL, 0), 0x1.FEDCBAp+114F)) + return 1; + if (test__floatqisf(make_qi(0, 0, 0x0007FB72E7FFFFFFLL, 0), 0x1.FEDCBAp+114F)) + return 1; + if (test__floatqisf(make_qi(0, 0, 0x0007FB72E4000001LL, 0), 0x1.FEDCBAp+114F)) + return 1; + if (test__floatqisf(make_qi(0, 0, 0x0007FB72E4000000LL, 0), 0x1.FEDCB8p+114F)) + return 1; + // FIXME: O2 failed due to FE opts. + // if (test__floatqisfNaN(make_qi(0, 1, 0x0007FB72E4000000LL, 0), make_qi(0, 1, 0x0007FB72E4000000LL, 0))) + // return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_floatqisf_test.reference_output b/SingleSource/Regression/C/BitInt_floatqisf_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatqisf_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_floatqitf_test.c b/SingleSource/Regression/C/BitInt_floatqitf_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatqitf_test.c @@ -0,0 +1,193 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + signed long long t3; + } s; +} twords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + twords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__floatqitf(_BitInt(256) a, __float128 expected) { + __float128 x = a; + if (x != expected) { + twords at; + at.all = a; + printf("error in __floatqitf(0x%.16llX%.16llX%.16llX%.16llX) = %LA, expected %LA\n", + at.s.t3, at.s.t2, at.s.t1, at.s.t0, (long double)x, (long double)expected); + } + return x != expected; +} + +int main() { + if (test__floatqitf(0, 0.0)) + return 1; + + if (test__floatqitf(1, 1.0)) + return 1; + if (test__floatqitf(2, 2.0)) + return 1; + if (test__floatqitf(20, 20.0)) + return 1; + if (test__floatqitf(-1, -1.0)) + return 1; + if (test__floatqitf(-2, -2.0)) + return 1; + if (test__floatqitf(-20, -20.0)) + return 1; + + if (test__floatqitf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62)) + return 1; + if (test__floatqitf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62)) + return 1; + if (test__floatqitf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62)) + return 1; + if (test__floatqitf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62)) + return 1; + + if (test__floatqitf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000008000000000LL, 0), -0x1.FFFFFEp+126)) + return 1; + if (test__floatqitf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000000000000800LL, 0), -0x1.FFFFFFFFFFFFEp+126)) + return 1; + if (test__floatqitf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000010000000000LL, 0), -0x1.FFFFFCp+126)) + return 1; + if (test__floatqitf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000000000001000LL, 0), -0x1.FFFFFFFFFFFFCp+126)) + return 1; + + if (test__floatqitf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000000000000000LL, 0), -0x1.000000p+127)) + return 1; + if (test__floatqitf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL, 0), -0x1.FFFFFFFFFFFFFFFCp+126L)) + return 1; + + if (test__floatqitf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50)) + return 1; + + if (test__floatqitf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50)) + return 1; + if (test__floatqitf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50)) + return 1; + if (test__floatqitf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50)) + return 1; + if (test__floatqitf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50)) + return 1; + if (test__floatqitf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50)) + return 1; + + if (test__floatqitf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50)) + return 1; + if (test__floatqitf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50)) + return 1; + if (test__floatqitf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50)) + return 1; + if (test__floatqitf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50)) + return 1; + if (test__floatqitf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50)) + return 1; + + if (test__floatqitf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqitf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496D08p+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496D8p+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496DCp+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496DBp+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496DF8p+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496E08p+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496E38p+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496E4p+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496E78p+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496E8p+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496E88p+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496ECp+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496EF8p+57L)) + return 1; + if (test__floatqitf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57)) + return 1; + + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496D08p+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496D8p+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496DCp+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496DBp+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496DF8p+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496E08p+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496E38p+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496E4p+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496E78p+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496E8p+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496E88p+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496ECp+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496EF8p+121L)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121L)) + return 1; + + if (test__floatqitf(make_qi(0, 0, 0, 0xFFFFFFFFFFFFFFFFLL), 0x1.FFFFFFFFFFFFFFFEp+63L)) + return 1; + + if (test__floatqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC2801LL), + 0x1.23456789ABCDEF0123456789ABC3p+124q)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC3000LL), + 0x1.23456789ABCDEF0123456789ABC3p+124q)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC37FFLL), + 0x1.23456789ABCDEF0123456789ABC3p+124q)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC3800LL), + 0x1.23456789ABCDEF0123456789ABC4p+124q)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC4000LL), + 0x1.23456789ABCDEF0123456789ABC4p+124q)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC47FFLL), + 0x1.23456789ABCDEF0123456789ABC4p+124q)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC4800LL), + 0x1.23456789ABCDEF0123456789ABC4p+124q)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC4801LL), + 0x1.23456789ABCDEF0123456789ABC5p+124q)) + return 1; + if (test__floatqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC57FFLL), + 0x1.23456789ABCDEF0123456789ABC5p+124q)) + return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_floatqitf_test.reference_output b/SingleSource/Regression/C/BitInt_floatqitf_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatqitf_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_floatqixf_test.c b/SingleSource/Regression/C/BitInt_floatqixf_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatqixf_test.c @@ -0,0 +1,196 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + signed long long t3; + } s; +} twords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + twords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__floatqixf(_BitInt(256) a, long double expected) +{ + long double x = a; + if (x != expected) + { + twords at; + at.all = a; + printf("error in __floatqixf(0x%.16llX%.16llX%.16llX%.16llX) = %LA, expected %LA\n", + at.s.t3, at.s.t2, at.s.t1, at.s.t0, x, expected); + } + return x != expected; +} + +int main() +{ + if (test__floatqixf(0, 0.0)) + return 1; + + if (test__floatqixf(1, 1.0)) + return 1; + if (test__floatqixf(2, 2.0)) + return 1; + if (test__floatqixf(20, 20.0)) + return 1; + if (test__floatqixf(-1, -1.0)) + return 1; + if (test__floatqixf(-2, -2.0)) + return 1; + if (test__floatqixf(-20, -20.0)) + return 1; + + if (test__floatqixf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62)) + return 1; + if (test__floatqixf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62)) + return 1; + if (test__floatqixf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62)) + return 1; + if (test__floatqixf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62)) + return 1; + + if (test__floatqixf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000008000000000LL, 0), -0x1.FFFFFEp+126)) + return 1; + if (test__floatqixf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000000000000800LL, 0), -0x1.FFFFFFFFFFFFEp+126)) + return 1; + if (test__floatqixf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000010000000000LL, 0), -0x1.FFFFFCp+126)) + return 1; + if (test__floatqixf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000000000001000LL, 0), -0x1.FFFFFFFFFFFFCp+126)) + return 1; + + if (test__floatqixf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000000000000000LL, 0), -0x1.000000p+127)) + return 1; + if (test__floatqixf(make_qi(0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL, 0x8000000000000001LL, 0), -0x1.FFFFFFFFFFFFFFFCp+126L)) + return 1; + + if (test__floatqixf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50)) + return 1; + + if (test__floatqixf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50)) + return 1; + if (test__floatqixf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50)) + return 1; + if (test__floatqixf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50)) + return 1; + if (test__floatqixf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50)) + return 1; + if (test__floatqixf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50)) + return 1; + + if (test__floatqixf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50)) + return 1; + if (test__floatqixf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50)) + return 1; + if (test__floatqixf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50)) + return 1; + if (test__floatqixf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50)) + return 1; + if (test__floatqixf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50)) + return 1; + + if (test__floatqixf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatqixf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496D08p+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496D8p+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496DCp+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496DBp+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496DF8p+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496E08p+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496E38p+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496E4p+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496E78p+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496E8p+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496E88p+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496ECp+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496EF8p+57L)) + return 1; + if (test__floatqixf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57)) + return 1; + + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496D08p+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496D8p+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496DCp+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496DBp+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496DF8p+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496E08p+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496E38p+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496E4p+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496E78p+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496E8p+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496E88p+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496ECp+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496EF8p+121L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121L)) + return 1; + + if (test__floatqixf(make_qi(0, 0, 0, 0xFFFFFFFFFFFFFFFFLL), 0x1.FFFFFFFFFFFFFFFEp+63L)) + return 1; + + if (test__floatqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456100000000001LL), + 0x1.2345678901234562p+108L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456200000000000LL), + 0x1.2345678901234562p+108L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x0000123456789012LL, 0x34562FFFFFFFFFFFLL), + 0x1.2345678901234562p+108L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456300000000000LL), + 0x1.2345678901234564p+108L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456400000000000LL), + 0x1.2345678901234564p+108L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x0000123456789012LL, 0x34564FFFFFFFFFFFLL), + 0x1.2345678901234564p+108L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456500000000000LL), + 0x1.2345678901234564p+108L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456500000000001LL), + 0x1.2345678901234566p+108L)) + return 1; + if (test__floatqixf(make_qi(0, 0, 0x0000123456789012LL, 0x34566FFFFFFFFFFFLL), + 0x1.2345678901234566p+108L)) + return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_floatqixf_test.reference_output b/SingleSource/Regression/C/BitInt_floatqixf_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatqixf_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_floatunqidf_test.c b/SingleSource/Regression/C/BitInt_floatunqidf_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatunqidf_test.c @@ -0,0 +1,159 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + unsigned long long t3; + } s; +} utwords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + utwords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__floatunqidf(unsigned _BitInt(256) a, double expected) +{ + double x = a; + if (x != expected) + { + utwords at; + at.all = a; + printf("error in __floatunqidf(0x%.16llX%.16llX%.16llX%.16llX) = %a, expected %a\n", + at.s.t3, at.s.t2, at.s.t1, at.s.t0, x, expected); + } + return x != expected; +} + +int main() +{ + if (test__floatunqidf(0, 0.0)) + return 1; + + if (test__floatunqidf(1, 1.0)) + return 1; + if (test__floatunqidf(2, 2.0)) + return 1; + if (test__floatunqidf(20, 20.0)) + return 1; + + if (test__floatunqidf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62)) + return 1; + if (test__floatunqidf(0x7FFFFFFFFFFFF800LL, 0x1.FFFFFFFFFFFFEp+62)) + return 1; + if (test__floatunqidf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62)) + return 1; + if (test__floatunqidf(0x7FFFFFFFFFFFF000LL, 0x1.FFFFFFFFFFFFCp+62)) + return 1; + + if (test__floatunqidf(make_qi(0, 0, 0x8000008000000000LL, 0), 0x1.000001p+127)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x8000000000000800LL, 0), 0x1.0000000000001p+127)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x8000010000000000LL, 0), 0x1.000002p+127)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x8000000000001000LL, 0), 0x1.0000000000002p+127)) + return 1; + + if (test__floatunqidf(make_qi(0, 0, 0x8000000000000000LL, 0), 0x1.000000p+127)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x8000000000000001LL, 0), 0x1.0000000000000002p+127)) + return 1; + + if (test__floatunqidf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50)) + return 1; + + if (test__floatunqidf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50)) + return 1; + if (test__floatunqidf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50)) + return 1; + if (test__floatunqidf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50)) + return 1; + if (test__floatunqidf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50)) + return 1; + if (test__floatunqidf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50)) + return 1; + + if (test__floatunqidf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50)) + return 1; + if (test__floatunqidf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50)) + return 1; + if (test__floatunqidf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50)) + return 1; + if (test__floatunqidf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50)) + return 1; + if (test__floatunqidf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50)) + return 1; + + if (test__floatunqidf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496Dp+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496Fp+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496Fp+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496Fp+57)) + return 1; + if (test__floatunqidf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57)) + return 1; + + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496Dp+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496Ep+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496Fp+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496Fp+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496Fp+121)) + return 1; + if (test__floatunqidf(make_qi(0, 0, 0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121)) + return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_floatunqidf_test.reference_output b/SingleSource/Regression/C/BitInt_floatunqidf_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatunqidf_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_floatunqisf_test.c b/SingleSource/Regression/C/BitInt_floatunqisf_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatunqisf_test.c @@ -0,0 +1,149 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + unsigned long long t3; + } s; +} utwords; + +static __inline _BitInt(256) make_qi(long long t3, long long t2, + long long t1, long long t0) { + utwords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__floatunqisf(unsigned _BitInt(256) a, float expected) +{ + float x = a; + if (x != expected) + { + utwords at; + at.all = a; + printf("error in __floatunqisf(0x%.16llX%.16llX%.16llX%.16llX) = %a, expected %a\n", + at.s.t3, at.s.t2, at.s.t1, at.s.t0, x, expected); + } + return x != expected; +} + +int main() +{ + if (test__floatunqisf(0, 0.0F)) + return 1; + + if (test__floatunqisf(1, 1.0F)) + return 1; + if (test__floatunqisf(2, 2.0F)) + return 1; + if (test__floatunqisf(20, 20.0F)) + return 1; + + if (test__floatunqisf(0x7FFFFF8000000000LL, 0x1.FFFFFEp+62F)) + return 1; + if (test__floatunqisf(0x7FFFFF0000000000LL, 0x1.FFFFFCp+62F)) + return 1; + + if (test__floatunqisf(make_qi(0, 0, 0x8000008000000000LL, 0), 0x1.000001p+127F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x8000000000000800LL, 0), 0x1.0p+127F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x8000010000000000LL, 0), 0x1.000002p+127F)) + return 1; + + if (test__floatunqisf(make_qi(0, 0, 0x8000000000000000LL, 0), 0x1.000000p+127F)) + return 1; + + if (test__floatunqisf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50F)) + return 1; + + if (test__floatunqisf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50F)) + return 1; + if (test__floatunqisf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50F)) + return 1; + + if (test__floatunqisf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50F)) + return 1; + + if (test__floatunqisf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50F)) + return 1; + if (test__floatunqisf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50F)) + return 1; + if (test__floatunqisf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50F)) + return 1; + + if (test__floatunqisf(0xFFFFFFFFFFFFFFFELL, 0x1p+64F)) + return 1; + if (test__floatunqisf(0xFFFFFFFFFFFFFFFFLL, 0x1p+64F)) + return 1; + + if (test__floatunqisf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50F)) + return 1; + + if (test__floatunqisf(0x0007FB72EA000000LL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatunqisf(0x0007FB72EB000000LL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatunqisf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatunqisf(0x0007FB72EC000000LL, 0x1.FEDCBCp+50F)) + return 1; + if (test__floatunqisf(0x0007FB72E8000001LL, 0x1.FEDCBAp+50F)) + return 1; + + if (test__floatunqisf(0x0007FB72E6000000LL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatunqisf(0x0007FB72E7000000LL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatunqisf(0x0007FB72E7FFFFFFLL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatunqisf(0x0007FB72E4000001LL, 0x1.FEDCBAp+50F)) + return 1; + if (test__floatunqisf(0x0007FB72E4000000LL, 0x1.FEDCB8p+50F)) + return 1; + + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCB90000000000001LL), + 0x1.FEDCBAp+76F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCBA0000000000000LL), + 0x1.FEDCBAp+76F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCBAFFFFFFFFFFFFFLL), + 0x1.FEDCBAp+76F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCBB0000000000000LL), + 0x1.FEDCBCp+76F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCBB0000000000001LL), + 0x1.FEDCBCp+76F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCBBFFFFFFFFFFFFFLL), + 0x1.FEDCBCp+76F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCBC0000000000000LL), + 0x1.FEDCBCp+76F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCBC0000000000001LL), + 0x1.FEDCBCp+76F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCBD0000000000000LL), + 0x1.FEDCBCp+76F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCBD0000000000001LL), + 0x1.FEDCBEp+76F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCBDFFFFFFFFFFFFFLL), + 0x1.FEDCBEp+76F)) + return 1; + if (test__floatunqisf(make_qi(0, 0, 0x0000000000001FEDLL, 0xCBE0000000000000LL), + 0x1.FEDCBEp+76F)) + return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_floatunqisf_test.reference_output b/SingleSource/Regression/C/BitInt_floatunqisf_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatunqisf_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_floatunqitf_test.c b/SingleSource/Regression/C/BitInt_floatunqitf_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatunqitf_test.c @@ -0,0 +1,200 @@ +#include + +typedef union { + unsigned _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + unsigned long long t3; + } s; +} utwords; + +static __inline _BitInt(256) make_qi(unsigned long long t3, unsigned long long t2, + unsigned long long t1, unsigned long long t0) { + utwords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__floatunqitf(unsigned _BitInt(256) a, __float128 expected) { + __float128 x = a; + if (x != expected) { + utwords at; + at.all = a; + printf("error in __floatunqitf(0x%.16llX%.16llX%.16llX%.16llX) = %LA, expected %LA\n", + at.s.t3, at.s.t2, at.s.t1, at.s.t0, (long double)x, (long double)expected); + } + return x != expected; +} + +int main() { + if (test__floatunqitf(0, 0.0)) + return 1; + + if (test__floatunqitf(1, 1.0)) + return 1; + if (test__floatunqitf(2, 2.0)) + return 1; + if (test__floatunqitf(20, 20.0)) + return 1; + + if (test__floatunqitf(0x7FFFFF8000000000ULL, 0x1.FFFFFEp+62)) + return 1; + if (test__floatunqitf(0x7FFFFFFFFFFFF800ULL, 0x1.FFFFFFFFFFFFEp+62)) + return 1; + if (test__floatunqitf(0x7FFFFF0000000000ULL, 0x1.FFFFFCp+62)) + return 1; + if (test__floatunqitf(0x7FFFFFFFFFFFF000ULL, 0x1.FFFFFFFFFFFFCp+62)) + return 1; + if (test__floatunqitf(0x7FFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFEp+59L)) + return 1; + if (test__floatunqitf(0xFFFFFFFFFFFFFFFEULL, 0xF.FFFFFFFFFFFFFFEp+60L)) + return 1; + if (test__floatunqitf(0xFFFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFFp+60L)) + return 1; + + if (test__floatunqitf(0x8000008000000000ULL, 0x8.000008p+60)) + return 1; + if (test__floatunqitf(0x8000000000000800ULL, 0x8.0000000000008p+60)) + return 1; + if (test__floatunqitf(0x8000010000000000ULL, 0x8.00001p+60)) + return 1; + if (test__floatunqitf(0x8000000000001000ULL, 0x8.000000000001p+60)) + return 1; + + if (test__floatunqitf(0x8000000000000000ULL, 0x8p+60)) + return 1; + if (test__floatunqitf(0x8000000000000001ULL, 0x8.000000000000001p+60L)) + return 1; + + if (test__floatunqitf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50)) + return 1; + + if (test__floatunqitf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50)) + return 1; + if (test__floatunqitf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50)) + return 1; + if (test__floatunqitf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50)) + return 1; + if (test__floatunqitf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50)) + return 1; + if (test__floatunqitf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50)) + return 1; + + if (test__floatunqitf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50)) + return 1; + if (test__floatunqitf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50)) + return 1; + if (test__floatunqitf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50)) + return 1; + if (test__floatunqitf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50)) + return 1; + if (test__floatunqitf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50)) + return 1; + + if (test__floatunqitf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqitf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496D08p+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496D8p+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496DCp+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496DBp+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496DF8p+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496E08p+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496E38p+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496E4p+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496E78p+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496E8p+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496E88p+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496ECp+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496EF8p+57L)) + return 1; + if (test__floatunqitf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57)) + return 1; + + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496D08p+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496D8p+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496DCp+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496DBp+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496DF8p+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496E08p+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496E38p+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496E4p+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496E78p+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496E8p+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496E88p+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496ECp+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496EF8p+121L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121L)) + return 1; + + if (test__floatunqitf(make_qi(0, 0, 0, 0xFFFFFFFFFFFFFFFFLL), 0x1.FFFFFFFFFFFFFFFEp+63L)) + return 1; + + if (test__floatunqitf(make_qi(0, 0, 0xFFFFFFFFFFFFFFFFLL, 0x0000000000000000LL), + 0x1.FFFFFFFFFFFFFFFEp+127L)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), + 0x1.0000000000000000p+128L)) + return 1; + + if (test__floatunqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC2801LL), + 0x1.23456789ABCDEF0123456789ABC3p+124q)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC3000LL), + 0x1.23456789ABCDEF0123456789ABC3p+124q)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC37FFLL), + 0x1.23456789ABCDEF0123456789ABC3p+124q)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC3800LL), + 0x1.23456789ABCDEF0123456789ABC4p+124q)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC4000LL), + 0x1.23456789ABCDEF0123456789ABC4p+124q)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC47FFLL), + 0x1.23456789ABCDEF0123456789ABC4p+124q)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC4800LL), + 0x1.23456789ABCDEF0123456789ABC4p+124q)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC4801LL), + 0x1.23456789ABCDEF0123456789ABC5p+124q)) + return 1; + if (test__floatunqitf(make_qi(0, 0, 0x123456789ABCDEF0LL, 0x123456789ABC57FFLL), + 0x1.23456789ABCDEF0123456789ABC5p+124q)) + return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_floatunqitf_test.reference_output b/SingleSource/Regression/C/BitInt_floatunqitf_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatunqitf_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/BitInt_floatunqixf_test.c b/SingleSource/Regression/C/BitInt_floatunqixf_test.c new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatunqixf_test.c @@ -0,0 +1,203 @@ +#include + +typedef union { + _BitInt(256) all; + struct { + unsigned long long t0; + unsigned long long t1; + unsigned long long t2; + unsigned long long t3; + } s; +} utwords; + +static __inline _BitInt(256) make_qi(unsigned long long t3, unsigned long long t2, + unsigned long long t1, unsigned long long t0) { + utwords r; + r.s.t3 = t3; + r.s.t2 = t2; + r.s.t1 = t1; + r.s.t0 = t0; + return r.all; +} + +int test__floatunqixf(unsigned _BitInt(256) a, long double expected) +{ + long double x = a; + if (x != expected) + { + utwords at; + at.all = a; + printf("error in __floatunqixf(0x%.16llX%.16llX%.16llX%.16llX) = %LA, expected %LA\n", + at.s.t3, at.s.t2, at.s.t1, at.s.t0, x, expected); + } + return x != expected; +} + +int main() +{ + if (test__floatunqixf(0, 0.0)) + return 1; + + if (test__floatunqixf(1, 1.0)) + return 1; + if (test__floatunqixf(2, 2.0)) + return 1; + if (test__floatunqixf(20, 20.0)) + return 1; + + if (test__floatunqixf(0x7FFFFF8000000000ULL, 0x1.FFFFFEp+62)) + return 1; + if (test__floatunqixf(0x7FFFFFFFFFFFF800ULL, 0x1.FFFFFFFFFFFFEp+62)) + return 1; + if (test__floatunqixf(0x7FFFFF0000000000ULL, 0x1.FFFFFCp+62)) + return 1; + if (test__floatunqixf(0x7FFFFFFFFFFFF000ULL, 0x1.FFFFFFFFFFFFCp+62)) + return 1; + if (test__floatunqixf(0x7FFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFEp+59L)) + return 1; + if (test__floatunqixf(0xFFFFFFFFFFFFFFFEULL, 0xF.FFFFFFFFFFFFFFEp+60L)) + return 1; + if (test__floatunqixf(0xFFFFFFFFFFFFFFFFULL, 0xF.FFFFFFFFFFFFFFFp+60L)) + return 1; + + if (test__floatunqixf(0x8000008000000000ULL, 0x8.000008p+60)) + return 1; + if (test__floatunqixf(0x8000000000000800ULL, 0x8.0000000000008p+60)) + return 1; + if (test__floatunqixf(0x8000010000000000ULL, 0x8.00001p+60)) + return 1; + if (test__floatunqixf(0x8000000000001000ULL, 0x8.000000000001p+60)) + return 1; + + if (test__floatunqixf(0x8000000000000000ULL, 0x8p+60)) + return 1; + if (test__floatunqixf(0x8000000000000001ULL, 0x8.000000000000001p+60L)) + return 1; + + if (test__floatunqixf(0x0007FB72E8000000LL, 0x1.FEDCBAp+50)) + return 1; + + if (test__floatunqixf(0x0007FB72EA000000LL, 0x1.FEDCBA8p+50)) + return 1; + if (test__floatunqixf(0x0007FB72EB000000LL, 0x1.FEDCBACp+50)) + return 1; + if (test__floatunqixf(0x0007FB72EBFFFFFFLL, 0x1.FEDCBAFFFFFFCp+50)) + return 1; + if (test__floatunqixf(0x0007FB72EC000000LL, 0x1.FEDCBBp+50)) + return 1; + if (test__floatunqixf(0x0007FB72E8000001LL, 0x1.FEDCBA0000004p+50)) + return 1; + + if (test__floatunqixf(0x0007FB72E6000000LL, 0x1.FEDCB98p+50)) + return 1; + if (test__floatunqixf(0x0007FB72E7000000LL, 0x1.FEDCB9Cp+50)) + return 1; + if (test__floatunqixf(0x0007FB72E7FFFFFFLL, 0x1.FEDCB9FFFFFFCp+50)) + return 1; + if (test__floatunqixf(0x0007FB72E4000001LL, 0x1.FEDCB90000004p+50)) + return 1; + if (test__floatunqixf(0x0007FB72E4000000LL, 0x1.FEDCB9p+50)) + return 1; + + if (test__floatunqixf(0x023479FD0E092DC0LL, 0x1.1A3CFE870496Ep+57)) + return 1; + if (test__floatunqixf(0x023479FD0E092DA1LL, 0x1.1A3CFE870496D08p+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DB0LL, 0x1.1A3CFE870496D8p+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DB8LL, 0x1.1A3CFE870496DCp+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DB6LL, 0x1.1A3CFE870496DBp+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DBFLL, 0x1.1A3CFE870496DF8p+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DC1LL, 0x1.1A3CFE870496E08p+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DC7LL, 0x1.1A3CFE870496E38p+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DC8LL, 0x1.1A3CFE870496E4p+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DCFLL, 0x1.1A3CFE870496E78p+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DD0LL, 0x1.1A3CFE870496E8p+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DD1LL, 0x1.1A3CFE870496E88p+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DD8LL, 0x1.1A3CFE870496ECp+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DDFLL, 0x1.1A3CFE870496EF8p+57L)) + return 1; + if (test__floatunqixf(0x023479FD0E092DE0LL, 0x1.1A3CFE870496Fp+57)) + return 1; + + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DC0LL, 0), 0x1.1A3CFE870496Ep+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DA1LL, 1), 0x1.1A3CFE870496D08p+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DB0LL, 2), 0x1.1A3CFE870496D8p+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DB8LL, 3), 0x1.1A3CFE870496DCp+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DB6LL, 4), 0x1.1A3CFE870496DBp+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DBFLL, 5), 0x1.1A3CFE870496DF8p+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DC1LL, 6), 0x1.1A3CFE870496E08p+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DC7LL, 7), 0x1.1A3CFE870496E38p+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DC8LL, 8), 0x1.1A3CFE870496E4p+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DCFLL, 9), 0x1.1A3CFE870496E78p+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DD0LL, 0), 0x1.1A3CFE870496E8p+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DD1LL, 11), 0x1.1A3CFE870496E88p+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DD8LL, 12), 0x1.1A3CFE870496ECp+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DDFLL, 13), 0x1.1A3CFE870496EF8p+121L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x023479FD0E092DE0LL, 14), 0x1.1A3CFE870496Fp+121L)) + return 1; + + if (test__floatunqixf(make_qi(0, 0, 0, 0xFFFFFFFFFFFFFFFFLL), 0x1.FFFFFFFFFFFFFFFEp+63L)) + return 1; + + if (test__floatunqixf(make_qi(0, 0, 0xFFFFFFFFFFFFFFFFLL, 0x0000000000000000LL), + 0x1.FFFFFFFFFFFFFFFEp+127L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0xFFFFFFFFFFFFFFFFLL, 0xFFFFFFFFFFFFFFFFLL), + 0x1.0000000000000000p+128L)) + return 1; + + if (test__floatunqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456100000000001LL), + 0x1.2345678901234562p+108L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456200000000000LL), + 0x1.2345678901234562p+108L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x0000123456789012LL, 0x34562FFFFFFFFFFFLL), + 0x1.2345678901234562p+108L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456300000000000LL), + 0x1.2345678901234564p+108L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456400000000000LL), + 0x1.2345678901234564p+108L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x0000123456789012LL, 0x34564FFFFFFFFFFFLL), + 0x1.2345678901234564p+108L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456500000000000LL), + 0x1.2345678901234564p+108L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x0000123456789012LL, 0x3456500000000001LL), + 0x1.2345678901234566p+108L)) + return 1; + if (test__floatunqixf(make_qi(0, 0, 0x0000123456789012LL, 0x34566FFFFFFFFFFFLL), + 0x1.2345678901234566p+108L)) + return 1; + printf("passed\n"); + return 0; +} diff --git a/SingleSource/Regression/C/BitInt_floatunqixf_test.reference_output b/SingleSource/Regression/C/BitInt_floatunqixf_test.reference_output new file mode 100644 --- /dev/null +++ b/SingleSource/Regression/C/BitInt_floatunqixf_test.reference_output @@ -0,0 +1,2 @@ +passed +exit 0 diff --git a/SingleSource/Regression/C/Makefile b/SingleSource/Regression/C/Makefile --- a/SingleSource/Regression/C/Makefile +++ b/SingleSource/Regression/C/Makefile @@ -26,6 +26,22 @@ 2008-01-07-LongDouble \ badidx \ bigstack \ + BitInt_fixdfqi_test \ + BitInt_fixsfqi_test \ + BitInt_fixtfqi_test \ + BitInt_fixunsdfqi_test \ + BitInt_fixunssfqi_test \ + BitInt_fixunstfqi_test \ + BitInt_fixunsxfqi_test \ + BitInt_fixxfqi_test \ + BitInt_floatqidf_test \ + BitInt_floatqisf_test \ + BitInt_floatqitf_test \ + BitInt_floatqixf_test \ + BitInt_floatunqidf_test \ + BitInt_floatunqisf_test \ + BitInt_floatunqitf_test \ + BitInt_floatunqixf_test \ callargs \ casts \ compare \