qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/4] softfloat: fix floatx80 pseudo-denormal comparisons
@ 2020-05-01  0:39 Joseph Myers
  2020-05-01 19:07 ` Alex Bennée
  0 siblings, 1 reply; 6+ messages in thread
From: Joseph Myers @ 2020-05-01  0:39 UTC (permalink / raw)
  To: qemu-devel

The softfloat floatx80 comparisons fail to allow for pseudo-denormals,
which should compare equal to corresponding values with biased
exponent 1 rather than 0.  Add an adjustment for that case when
comparing numbers with the same sign.

Note that this fix only changes floatx80_compare_internal, not the
other more specific comparison operations.  That is the only
comparison function for floatx80 used in the i386 port, which is the
only supported port with these pseudo-denormal semantics.

Signed-off-by: Joseph Myers <joseph@codesourcery.com>
---
 fpu/softfloat.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 6094d267b5..8e9c714e6f 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -7966,6 +7966,11 @@ static inline int floatx80_compare_internal(floatx80 a, floatx80 b,
             return 1 - (2 * aSign);
         }
     } else {
+        /* Normalize pseudo-denormals before comparison.  */
+        if ((a.high & 0x7fff) == 0 && a.low & UINT64_C(0x8000000000000000))
+            ++a.high;
+        if ((b.high & 0x7fff) == 0 && b.low & UINT64_C(0x8000000000000000))
+            ++b.high;
         if (a.low == b.low && a.high == b.high) {
             return float_relation_equal;
         } else {
-- 
2.17.1


-- 
Joseph S. Myers
joseph@codesourcery.com


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-05-02 19:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-01  0:39 [PATCH 3/4] softfloat: fix floatx80 pseudo-denormal comparisons Joseph Myers
2020-05-01 19:07 ` Alex Bennée
2020-05-01 19:12   ` Joseph Myers
2020-05-01 19:31     ` Alex Bennée
2020-05-01 21:01       ` Joseph Myers
2020-05-02 19:07         ` Alex Bennée

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).