From 707a61b1b61bee0f407a35b310f0f5d8a8cdb9a0 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 14 Oct 2023 21:50:49 +0200 Subject: [PATCH] totalorder*: Fix test failures on SH4. * lib/snan.h: Update comment. * lib/totalorderf.c (totalorderf): On sh4, invert bit 22 before comparing two NaNs. * lib/totalorder.c (totalorder): On sh4, invert bit 51 before comparing two NaNs. * lib/totalorderl.c (totalorderl): On sh4, invert bit 51 or 47 of the xhi, yhi parts before comparing two NaNs. --- ChangeLog | 9 +++++++++ lib/snan.h | 2 +- lib/totalorder.c | 2 +- lib/totalorderf.c | 2 +- lib/totalorderl.c | 4 ++-- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 60f9cbd63a..2bb7e48799 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2023-10-14 Bruno Haible + totalorder*: Fix test failures on SH4. + * lib/snan.h: Update comment. + * lib/totalorderf.c (totalorderf): On sh4, invert bit 22 before + comparing two NaNs. + * lib/totalorder.c (totalorder): On sh4, invert bit 51 before comparing + two NaNs. + * lib/totalorderl.c (totalorderl): On sh4, invert bit 51 or 47 of the + xhi, yhi parts before comparing two NaNs. + totalorder*: Fix test failures on PA-RISC and MIPS CPUs. * lib/totalorderf.c (totalorderf): On hppa and mips, invert bit 22 before comparing two NaNs. diff --git a/lib/snan.h b/lib/snan.h index ebf88ab0c5..abd95318d7 100644 --- a/lib/snan.h +++ b/lib/snan.h @@ -32,7 +32,7 @@ This bit is * == 0 to indicate a quiet NaN or Infinity, == 1 to indicate a signalling NaN, - on these CPUs: hppa, mips. + on these CPUs: hppa, mips, sh4. * == 1 to indicate a quiet NaN, == 0 to indicate a signalling NaN or Infinity, on all other CPUs. diff --git a/lib/totalorder.c b/lib/totalorder.c index edbcd6998b..ee90ebb1f9 100644 --- a/lib/totalorder.c +++ b/lib/totalorder.c @@ -46,7 +46,7 @@ totalorder (double const *x, double const *y) /* At this point, *X and *Y are NaNs with the same sign bit. */ unsigned long long extended_sign = -!!xs; -#if defined __hppa || defined __mips__ +#if defined __hppa || defined __mips__ || defined __sh__ /* Invert the most significant bit of the mantissa field. Cf. snan.h. */ extended_sign ^= (1ULL << 51); #endif diff --git a/lib/totalorderf.c b/lib/totalorderf.c index 4cbfa06ffd..fa2a1245de 100644 --- a/lib/totalorderf.c +++ b/lib/totalorderf.c @@ -46,7 +46,7 @@ totalorderf (float const *x, float const *y) /* At this point, *X and *Y are NaNs with the same sign bit. */ unsigned int extended_sign = -!!xs; -#if defined __hppa || defined __mips__ +#if defined __hppa || defined __mips__ || defined __sh__ /* Invert the most significant bit of the mantissa field. Cf. snan.h. */ extended_sign ^= (1U << 22); #endif diff --git a/lib/totalorderl.c b/lib/totalorderl.c index 6982762a0f..a06e70d55f 100644 --- a/lib/totalorderl.c +++ b/lib/totalorderl.c @@ -55,7 +55,7 @@ totalorderl (long double const *x, long double const *y) if (sizeof (long double) <= sizeof (unsigned long long)) { -#if defined __hppa || defined __mips__ +#if defined __hppa || defined __mips__ || defined __sh__ /* Invert the most significant bit of the mantissa field. Cf. snan.h. */ extended_sign ^= (1ULL << 51); #endif @@ -67,7 +67,7 @@ totalorderl (long double const *x, long double const *y) } unsigned long long extended_sign_hi = extended_sign; -#if defined __hppa || defined __mips__ +#if defined __hppa || defined __mips__ || defined __sh__ /* Invert the most significant bit of the mantissa field. Cf. snan.h. */ extended_sign_hi ^= (1ULL << (LDBL_MANT_DIG == 106 -- 2.39.5