From: Florian Krohm Date: Mon, 22 Sep 2025 15:31:12 +0000 (+0000) Subject: s390: Remove none/tests/s390x/tcxb, add none/tests/s390x/bfp-tdc X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b1f875b63d6a07115dfba571c6dcc1f280c0b1f4;p=thirdparty%2Fvalgrind.git s390: Remove none/tests/s390x/tcxb, add none/tests/s390x/bfp-tdc tcxb was busted. Part of fixing https://bugs.kde.org/show_bug.cgi?id=509572 --- diff --git a/none/tests/s390x/Makefile.am b/none/tests/s390x/Makefile.am index c1909da396..57dbb55db0 100644 --- a/none/tests/s390x/Makefile.am +++ b/none/tests/s390x/Makefile.am @@ -2,14 +2,14 @@ include $(top_srcdir)/Makefile.tool-tests.am dist_noinst_SCRIPTS = filter_stderr bfp-emit.pl -INSN_TESTS = clc clcle cvb cvd icm lpr tcxb lam_stam xc mvst add sub mul \ +INSN_TESTS = clc clcle cvb cvd icm lpr lam_stam xc mvst add sub mul \ and or xor insert div srst fold_And16 flogr sub_EI add_EI \ and_EI or_EI xor_EI insert_EI mul_GE add_GE condloadstore \ op_exception fgx stck stckf stcke stfle cksm mvcl clcl troo \ trto trot trtt tr tre cij cgij clij clgij crj cgrj clrj clgrj \ cs csg cds cdsg cu21 cu21_1 cu24 cu24_1 cu42 cu12 cu12_1 \ ex_sig ex_clone cu14 cu14_1 cu41 fpconv ecag fpext_warn \ - rounding-1 rounding-2 rounding-3 rounding-4 rounding-5 bfp-1 \ + bfp-tdc rounding-1 rounding-2 rounding-3 rounding-4 rounding-5 bfp-1 \ bfp-2 bfp-3 bfp-4 srnm srnmb comp-1 comp-2 exrl tmll tm stmg \ ex clst mvc test_fork test_sig rounding-6 rxsbg popcnt \ high-word traps \ diff --git a/none/tests/s390x/bfp-tdc.c b/none/tests/s390x/bfp-tdc.c new file mode 100644 index 0000000000..a8b6769efc --- /dev/null +++ b/none/tests/s390x/bfp-tdc.c @@ -0,0 +1,140 @@ +/* TEST DATA CLASS + + Test for subnormal numbers is missing. I do not know how */ +#include +#include // NAN +#include // DBL_MIN +#include + +#define ZERO_P (1 << 11) +#define ZERO_N (1 << 10) +#define NORM_P (1 << 9) +#define NORM_N (1 << 8) +#define SUBNORM_P (1 << 7) +#define SUBNORM_N (1 << 6) +#define INF_P (1 << 5) +#define INF_N (1 << 4) +#define QNAN_P (1 << 3) +#define QNAN_N (1 << 2) +#define SNAN_P (1 << 1) +#define SNAN_N (1 << 0) + +static struct what { + unsigned bitno; + unsigned mask; + const char *str; +} whatsit[] = { + { 63, SNAN_N, "Signaling Nan with sign bit negative" }, + { 62, SNAN_P, "Signaling Nan with sign bit posative" }, + { 61, QNAN_N, "Quiet Nan with sign bit negative" }, + { 60, QNAN_P, "Quiet Nan with sign bit posative" }, + { 59, INF_N, "Infinity with sign bit negative" }, + { 58, INF_P, "Infinity with sign bit positive" }, + { 57, SUBNORM_N, "Subnormal number with sign bit negative" }, + { 56, SUBNORM_N, "Subnormal number with sign bit positive" }, + { 55, NORM_N, "Normal number with sign bit negative" }, + { 54, NORM_P, "Normal number with sign bit positive" }, + { 53, ZERO_N, "Zero with sign bit negative" }, + { 52, ZERO_P, "Zero with sign bit positive" } +}; + +#define TDC(insn, type, value, m) \ + ({ \ + int cc; \ + type r1 = value; \ + \ + __asm__ volatile(#insn " %[r1],0(%[mask])\n\t" \ + "ipm %[psw]\n\t" \ + "srl %[psw],28\n\t" \ + : [psw]"+d"(cc) \ + : [r1]"f"(r1), [mask]"a"(m) \ + : "cc"); \ + cc; \ + }) + +static void +do_tceb(float value) +{ + for (int i = 0; i < sizeof(whatsit) / sizeof(*whatsit); ++i) { + int ccv = TDC(tceb, float, value, whatsit[i].mask); + if (ccv == 1) + printf("value = %f\t\tcc = %d %s\n", value, ccv, + whatsit[i].str); + } +} + +static void +do_tcdb(double value) +{ + for (int i = 0; i < sizeof(whatsit) / sizeof(*whatsit); ++i) { + int ccv = TDC(tcdb, double, value, whatsit[i].mask); + if (ccv == 1) + printf("value = %f\t\tcc = %d %s\n", value, ccv, + whatsit[i].str); + } +} + +static void +do_tcxb(long double value) +{ + for (int i = 0; i < sizeof(whatsit) / sizeof(*whatsit); ++i) { + int ccv = TDC(tcxb, long double, value, whatsit[i].mask); + if (ccv == 1) + printf("value = %Lf\t\tcc = %d %s\n", value, ccv, + whatsit[i].str); + } +} + +int +main(void) +{ + assert(sizeof(long double) == 16); + + printf("32-bit tests\n"); + do_tceb(0.0f); + do_tceb(-0.0f); + do_tceb(3.0f); + do_tceb(-3.0f); + do_tceb(NAN); + do_tceb(-NAN); + do_tceb(INFINITY); + do_tceb(-INFINITY); + do_tceb(__builtin_nansf("")); + do_tceb(-__builtin_nansf("")); + do_tceb(FLT_MIN / 2); + do_tceb(-FLT_MIN / 2); + + printf("\n64-bit tests\n"); + do_tcdb(0.0); + do_tcdb(-0.0); + do_tcdb(3.0); + do_tcdb(-3.0); + do_tcdb(NAN); + do_tcdb(-NAN); + do_tcdb(INFINITY); + do_tcdb(-INFINITY); + do_tcdb(__builtin_nans("")); + do_tcdb(-__builtin_nans("")); + do_tcdb(DBL_MIN / 2); + do_tcdb(-DBL_MIN / 2); + + printf("\n128-bit tests\n"); + do_tcxb(0.0L); + do_tcxb(-0.0L); + do_tcxb(3.0L); + do_tcxb(-3.0L); + do_tcxb(NAN); + do_tcxb(-NAN); + do_tcxb(INFINITY); + do_tcxb(-INFINITY); + do_tcxb(__builtin_nansl("")); + do_tcxb(-__builtin_nansl("")); +#if 0 + /* Figuring out subnormal numbers for 128-bit BFP is left as + an exercise.. */ + do_tcdb(LDBL_MIN / 2); + do_tcdb(-LDBL_MIN / 2); +#endif + + return 0; +} diff --git a/none/tests/s390x/tcxb.stderr.exp b/none/tests/s390x/bfp-tdc.stderr.exp similarity index 100% rename from none/tests/s390x/tcxb.stderr.exp rename to none/tests/s390x/bfp-tdc.stderr.exp diff --git a/none/tests/s390x/bfp-tdc.stdout.exp b/none/tests/s390x/bfp-tdc.stdout.exp new file mode 100644 index 0000000000..032287b590 --- /dev/null +++ b/none/tests/s390x/bfp-tdc.stdout.exp @@ -0,0 +1,39 @@ +32-bit tests +value = 0.000000 cc = 1 Zero with sign bit positive +value = -0.000000 cc = 1 Zero with sign bit negative +value = 3.000000 cc = 1 Normal number with sign bit positive +value = -3.000000 cc = 1 Normal number with sign bit negative +value = nan cc = 1 Quiet Nan with sign bit posative +value = -nan cc = 1 Quiet Nan with sign bit negative +value = inf cc = 1 Infinity with sign bit positive +value = -inf cc = 1 Infinity with sign bit negative +value = nan cc = 1 Signaling Nan with sign bit posative +value = -nan cc = 1 Signaling Nan with sign bit negative +value = -0.000000 cc = 1 Subnormal number with sign bit negative +value = -0.000000 cc = 1 Subnormal number with sign bit positive + +64-bit tests +value = 0.000000 cc = 1 Zero with sign bit positive +value = -0.000000 cc = 1 Zero with sign bit negative +value = 3.000000 cc = 1 Normal number with sign bit positive +value = -3.000000 cc = 1 Normal number with sign bit negative +value = nan cc = 1 Quiet Nan with sign bit posative +value = -nan cc = 1 Quiet Nan with sign bit negative +value = inf cc = 1 Infinity with sign bit positive +value = -inf cc = 1 Infinity with sign bit negative +value = nan cc = 1 Signaling Nan with sign bit posative +value = -nan cc = 1 Signaling Nan with sign bit negative +value = -0.000000 cc = 1 Subnormal number with sign bit negative +value = -0.000000 cc = 1 Subnormal number with sign bit positive + +128-bit tests +value = 0.000000 cc = 1 Zero with sign bit positive +value = -0.000000 cc = 1 Zero with sign bit negative +value = 3.000000 cc = 1 Normal number with sign bit positive +value = -3.000000 cc = 1 Normal number with sign bit negative +value = nan cc = 1 Quiet Nan with sign bit posative +value = -nan cc = 1 Quiet Nan with sign bit negative +value = inf cc = 1 Infinity with sign bit positive +value = -inf cc = 1 Infinity with sign bit negative +value = nan cc = 1 Signaling Nan with sign bit posative +value = -nan cc = 1 Signaling Nan with sign bit negative diff --git a/none/tests/s390x/bfp-tdc.vgtest b/none/tests/s390x/bfp-tdc.vgtest new file mode 100644 index 0000000000..306de25ab1 --- /dev/null +++ b/none/tests/s390x/bfp-tdc.vgtest @@ -0,0 +1 @@ +prog: bfp-tdc diff --git a/none/tests/s390x/tcxb.c b/none/tests/s390x/tcxb.c deleted file mode 100644 index 4ff031f865..0000000000 --- a/none/tests/s390x/tcxb.c +++ /dev/null @@ -1,95 +0,0 @@ -/* test data class tests for float, double, long double: TCEB, TCDB, TCXB */ -#include -#include - -static int tcxb(long double f, long long num) -{ - int match; - - asm volatile(" tcxb %1,0(%2)\n" - "ipm %0\n" - "srl %0,28\n" - : "=d" (match) - : "f" (f), "a" (num) - : "cc"); - return match; -} - -static int tcdb(double f, long long num) -{ - int match; - - asm volatile(" tcdb %1,0(%2)\n" - "ipm %0\n" - "srl %0,28\n" - : "=d" (match) - : "f" (f), "a" (num) - : "cc"); - return match; -} - -static int tceb(float f, long long num) -{ - int match; - - asm volatile(" tceb %1,0(%2)\n" - "ipm %0\n" - "srl %0,28\n" - : "=d" (match) - : "f" (f), "a" (num) - : "cc"); - return match; -} - -int main() -{ - int i; - - for (i = 0; i < 64; i++) { - if (sizeof (long double) == 16) { - /* long double 128 bit */ - printf("%d", tcxb(+0.0l, 1UL<