From d2ab89e97a868f5472e3089ab1c3bbf38fa3446d Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 14 Oct 2023 20:30:50 +0200 Subject: [PATCH] snan: Avoid test failures with CC="gcc -mfpmath=387". * tests/test-snan-1.c (main): Treat x86_64 CPU with __FLT_EVAL_METHOD__ == 2 like i386 CPU. Update comments. * tests/test-snan-2.c (main): Likewise. --- ChangeLog | 7 +++++++ tests/test-snan-1.c | 16 +++++++--------- tests/test-snan-2.c | 36 +++++++++++++++++------------------- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3abc21c442..eb1271eb65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-10-14 Bruno Haible + + snan: Avoid test failures with CC="gcc -mfpmath=387". + * tests/test-snan-1.c (main): Treat x86_64 CPU with + __FLT_EVAL_METHOD__ == 2 like i386 CPU. Update comments. + * tests/test-snan-2.c (main): Likewise. + 2023-10-14 Bruno Haible snan: Fix the value of SNaNl() on i386, x86_64, ia64 CPUs. diff --git a/tests/test-snan-1.c b/tests/test-snan-1.c index fc8fc99e31..911d20bd70 100644 --- a/tests/test-snan-1.c +++ b/tests/test-snan-1.c @@ -61,15 +61,13 @@ main () long double volatile nanl = SNaNl (); /* Check that the values are really signalling. */ - /* These tests do not work on 32-bit x86 processors, although the - "Intel 64 and IA-32 Architectures Software Developer's Manual" and - "IA-32 Intel Architecture Software Developer's Manual", each in - sections - 4.8.3.4 NaNs - 4.8.3.5 Operating on SNaNs and QNaNs - 4.8.3.6 Using SNaNs and QNaNs in Applications - claim that it should work. */ - #if !(defined __i386 || defined _M_IX86) + /* These tests do not work on 32-bit x86 processors, as well as + on x86_64 processors with CC="gcc -mfpmath=387", because loading SNaNf() + or SNaNd() into a 387 FPU register already converted it to a quiet NaN. + See + for details. */ + #if !((defined __i386 || defined _M_IX86) \ + || ((defined __x86_64__ || defined _M_X64) && __FLT_EVAL_METHOD__ == 2)) /* This test does not work on AIX 7.1 with the xlc compiler, even with the compiler options -qfloat=fenv -qfloat=nans -qfloat=spnans. */ #if !(defined _AIX && defined __xlC__) diff --git a/tests/test-snan-2.c b/tests/test-snan-2.c index 42927d6077..4ddd3ac9b1 100644 --- a/tests/test-snan-2.c +++ b/tests/test-snan-2.c @@ -65,15 +65,13 @@ main (int argc, char *argv[]) switch (argv[1][0]) { case 'f': - /* This test does not work on 32-bit x86 processors, although the - "Intel 64 and IA-32 Architectures Software Developer's Manual" and - "IA-32 Intel Architecture Software Developer's Manual", each in - sections - 4.8.3.4 NaNs - 4.8.3.5 Operating on SNaNs and QNaNs - 4.8.3.6 Using SNaNs and QNaNs in Applications - claim that it should work. */ - #if !(defined __i386 || defined _M_IX86) + /* This test does not work on 32-bit x86 processors, as well as + on x86_64 processors with CC="gcc -mfpmath=387", because loading + SNaNf() into a 387 FPU register already converted it to a quiet NaN. + See + for details. */ + #if !((defined __i386 || defined _M_IX86) \ + || ((defined __x86_64__ || defined _M_X64) && __FLT_EVAL_METHOD__ == 2)) /* This test does not work on AIX 7.1 with the xlc compiler, even with the compiler options -qfloat=fenv -qfloat=nans -qfloat=spnans. */ #if !(defined _AIX && defined __xlC__) @@ -89,15 +87,13 @@ main (int argc, char *argv[]) break; case 'd': - /* This test does not work on 32-bit x86 processors, although the - "Intel 64 and IA-32 Architectures Software Developer's Manual" and - "IA-32 Intel Architecture Software Developer's Manual", each in - sections - 4.8.3.4 NaNs - 4.8.3.5 Operating on SNaNs and QNaNs - 4.8.3.6 Using SNaNs and QNaNs in Applications - claim that it should work. */ - #if !(defined __i386 || defined _M_IX86) + /* This test does not work on 32-bit x86 processors, as well as + on x86_64 processors with CC="gcc -mfpmath=387", because loading + SNaNd() into a 387 FPU register already converted it to a quiet NaN. + See + for details. */ + #if !((defined __i386 || defined _M_IX86) \ + || ((defined __x86_64__ || defined _M_X64) && __FLT_EVAL_METHOD__ == 2)) resultd = nand + 42.0; #else fputs ("Skipping test: known failure on this platform\n", stderr); @@ -125,7 +121,9 @@ main (int argc, char *argv[]) || ((defined __FreeBSD__ || defined __NetBSD__ || defined __OpenBSD__) && (defined __aarch64__ || defined __sparc__))) \ && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE) \ || (defined __CYGWIN__ && defined __i386) \ - || ((defined __i386 || defined _M_IX86) && HAVE_SAME_LONG_DOUBLE_AS_DOUBLE)) + || (((defined __i386 || defined _M_IX86) \ + || ((defined __x86_64__ || defined _M_X64) && __FLT_EVAL_METHOD__ == 2)) \ + && HAVE_SAME_LONG_DOUBLE_AS_DOUBLE)) resultl = nanl + 42.0L; #else fputs ("Skipping test: known failure on this platform\n", stderr); -- 2.39.5