diff mbox series

[RFC,09/30] softfloat: propagate signalling NaNs in MINMAX

Message ID 20171013162438.32458-10-alex.bennee@linaro.org
State Superseded
Headers show
Series v8.2 half-precision support (work-in-progress) | expand

Commit Message

Alex Bennée Oct. 13, 2017, 4:24 p.m. UTC
While a comparison between a QNaN and a number will return the number
it is not the same with a signaling NaN. In this case the SNaN will
"win" and after potentially raising an exception it will be quietened.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
 fpu/softfloat.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

-- 
2.14.1

Comments

Richard Henderson Oct. 15, 2017, 4:13 p.m. UTC | #1
On 10/13/2017 09:24 AM, Alex Bennée wrote:
> -            if (float ## s ## _is_quiet_nan(a, status) &&               \

> +            if (float ## s ## _is_signaling_nan(a, status) ||           \

> +                float ## s ## _is_signaling_nan(b, status)) {           \

> +                propagateFloat ## s ## NaN(a, b, status);               \


Missing a return here?


r~
diff mbox series

Patch

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 013b223947..6ab4b39c09 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -7684,6 +7684,7 @@  int float128_compare_quiet(float128 a, float128 b, float_status *status)
  * minnum() and maxnum() functions. These are similar to the min()
  * and max() functions but if one of the arguments is a QNaN and
  * the other is numerical then the numerical argument is returned.
+ * SNaNs will get quietened before being returned.
  * minnum() and maxnum correspond to the IEEE 754-2008 minNum()
  * and maxNum() operations. min() and max() are the typical min/max
  * semantics provided by many CPUs which predate that specification.
@@ -7704,11 +7705,14 @@  static inline float ## s float ## s ## _minmax(float ## s a, float ## s b,     \
     if (float ## s ## _is_any_nan(a) ||                                 \
         float ## s ## _is_any_nan(b)) {                                 \
         if (isieee) {                                                   \
-            if (float ## s ## _is_quiet_nan(a, status) &&               \
+            if (float ## s ## _is_signaling_nan(a, status) ||           \
+                float ## s ## _is_signaling_nan(b, status)) {           \
+                propagateFloat ## s ## NaN(a, b, status);               \
+            } else  if (float ## s ## _is_quiet_nan(a, status) &&       \
                 !float ## s ##_is_any_nan(b)) {                         \
                 return b;                                               \
             } else if (float ## s ## _is_quiet_nan(b, status) &&        \
-                       !float ## s ## _is_any_nan(a)) {                \
+                       !float ## s ## _is_any_nan(a)) {                 \
                 return a;                                               \
             }                                                           \
         }                                                               \