qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] softfloat: Simplify `float128_is_*_nan' functions


From: Maciej W. Rozycki
Subject: [Qemu-devel] [PATCH] softfloat: Simplify `float128_is_*_nan' functions
Date: Fri, 12 Dec 2014 19:38:40 +0000
User-agent: Alpine 1.10 (DEB 962 2008-03-14)

Don't make separate checks for the trailing significand to be non-zero 
where the check for the quiet bit being 1 already covers it.

The point of the whole expression is to tell inifinities and NaN data 
apart while also checking for the expected value of the quiet bit, and 
the quiet bit being 1 in the floating-point datum examined (whether it 
denotes a qNaN or an sNaN) already makes the datum encoded a NaN rather
than an infinity.

Signed-off-by: Maciej W. Rozycki <address@hidden>
---
Peter,

 This is the cleanup I mentioned yesterday.  It makes 128-bit float 
handling similar to how 16-bit, 32-bit and 64-bit ones already are 
handled.  This is based on the observation that whenever:

(a.high << 1) >= 0xffff000000000000

returns true:

a.high & 0x0000ffffffffffffULL

also does and therefore the RHS of the && expression always evaluates to 
true if the LHS does (the reverse is obviously not always the case).

 It applies on top of: https://patchwork.ozlabs.org/patch/420645/

  Maciej

qemu-softfloat-float128-nan.diff
Index: qemu-git-trunk/fpu/softfloat-specialize.h
===================================================================
--- qemu-git-trunk.orig/fpu/softfloat-specialize.h      2014-12-11 
21:50:59.000000000 +0000
+++ qemu-git-trunk/fpu/softfloat-specialize.h   2014-12-11 21:57:30.338965285 
+0000
@@ -1154,8 +1154,7 @@ int float128_is_quiet_nan(float128 a STA
     int __attribute__ ((unused)) x, y;
     x = (((a.high >> 47) & 0xffff) == 0xfffe)
         && (a.low || (a.high & 0x00007fffffffffffULL));
-    y = ((a.high << 1) >= 0xffff000000000000)
-        && (a.low || (a.high & 0x0000ffffffffffffULL));
+    y = (a.high << 1) >= 0xffff000000000000;
 #if SNAN_BIT_IS_VARIABLE
     return STATUS(nan2008_mode) ? y : x;
 #elif SNAN_BIT_IS_ONE
@@ -1173,8 +1172,7 @@ int float128_is_quiet_nan(float128 a STA
 int float128_is_signaling_nan(float128 a STATUS_PARAM)
 {
     int __attribute__ ((unused)) x, y;
-    x = ((a.high << 1) >= 0xffff000000000000)
-        && (a.low || (a.high & 0x0000ffffffffffffULL));
+    x = (a.high << 1) >= 0xffff000000000000;
     y = (((a.high >> 47) & 0xFFFF) == 0xFFFE)
         && (a.low || (a.high & LIT64(0x00007FFFFFFFFFFF)));
 #if SNAN_BIT_IS_VARIABLE



reply via email to

[Prev in Thread] Current Thread [Next in Thread]