diff mbox series

[12/72] softfloat: fix return_nan vs default_nan_mode

Message ID 20210508014802.892561-13-richard.henderson@linaro.org
State Superseded
Headers show
Series Convert floatx80 and float128 to FloatParts | expand

Commit Message

Richard Henderson May 8, 2021, 1:47 a.m. UTC
Do not call parts_silence_nan when default_nan_mode is in
effect.  This will avoid an assert in a later patch.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 fpu/softfloat.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

-- 
2.25.1

Comments

Alex Bennée May 10, 2021, 3:12 p.m. UTC | #1
Richard Henderson <richard.henderson@linaro.org> writes:

> Do not call parts_silence_nan when default_nan_mode is in

> effect.  This will avoid an assert in a later patch.

>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


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


-- 
Alex Bennée
David Hildenbrand May 11, 2021, 10:12 a.m. UTC | #2
On 08.05.21 03:47, Richard Henderson wrote:
> Do not call parts_silence_nan when default_nan_mode is in

> effect.  This will avoid an assert in a later patch.

> 

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>   fpu/softfloat.c | 19 +++++++------------

>   1 file changed, 7 insertions(+), 12 deletions(-)

> 

> diff --git a/fpu/softfloat.c b/fpu/softfloat.c

> index b694e38522..6589f00b23 100644

> --- a/fpu/softfloat.c

> +++ b/fpu/softfloat.c

> @@ -892,21 +892,16 @@ static float64 float64_round_pack_canonical(FloatParts p, float_status *s)

>   

>   static FloatParts return_nan(FloatParts a, float_status *s)

>   {

> -    switch (a.cls) {

> -    case float_class_snan:

> +    g_assert(is_nan(a.cls));

> +    if (is_snan(a.cls)) {

>           float_raise(float_flag_invalid, s);

> -        a = parts_silence_nan(a, s);

> -        /* fall through */

> -    case float_class_qnan:

> -        if (s->default_nan_mode) {

> -            return parts_default_nan(s);

> +        if (!s->default_nan_mode) {

> +            return parts_silence_nan(a, s);

>           }

> -        break;

> -

> -    default:

> -        g_assert_not_reached();

> +    } else if (!s->default_nan_mode) {

> +        return a;

>       }

> -    return a;

> +    return parts_default_nan(s);

>   }

>   

>   static FloatParts pick_nan(FloatParts a, FloatParts b, float_status *s)

> 


Reviewed-by: David Hildenbrand <david@redhat.com>


-- 
Thanks,

David / dhildenb
diff mbox series

Patch

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index b694e38522..6589f00b23 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -892,21 +892,16 @@  static float64 float64_round_pack_canonical(FloatParts p, float_status *s)
 
 static FloatParts return_nan(FloatParts a, float_status *s)
 {
-    switch (a.cls) {
-    case float_class_snan:
+    g_assert(is_nan(a.cls));
+    if (is_snan(a.cls)) {
         float_raise(float_flag_invalid, s);
-        a = parts_silence_nan(a, s);
-        /* fall through */
-    case float_class_qnan:
-        if (s->default_nan_mode) {
-            return parts_default_nan(s);
+        if (!s->default_nan_mode) {
+            return parts_silence_nan(a, s);
         }
-        break;
-
-    default:
-        g_assert_not_reached();
+    } else if (!s->default_nan_mode) {
+        return a;
     }
-    return a;
+    return parts_default_nan(s);
 }
 
 static FloatParts pick_nan(FloatParts a, FloatParts b, float_status *s)