target-ppc: use float32_is_any_nan()

Submitted by Aurelien Jarno on Jan. 2, 2011, 12:06 p.m.

Details

Message ID 1293970009-2028-1-git-send-email-aurelien@aurel32.net
State New
Headers show

Commit Message

Aurelien Jarno Jan. 2, 2011, 12:06 p.m.
Use the new function float32_is_any_nan() instead of
float32_is_quiet_nan() || float32_is_signaling_nan().

Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 target-ppc/op_helper.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

Comments

Alexander Graf Jan. 5, 2011, 4:59 p.m.
On 02.01.2011, at 13:06, Aurelien Jarno wrote:

> Use the new function float32_is_any_nan() instead of
> float32_is_quiet_nan() || float32_is_signaling_nan().
> 
> Cc: Alexander Graf <agraf@suse.de>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

I frankly have very little knowledge of FP stuff. Is any_nan really equal to quiet_nan || signaling_nan or would it cover more cases?


Alex
Nathan Froyd Jan. 5, 2011, 5:04 p.m.
On Sun, Jan 02, 2011 at 01:06:49PM +0100, Aurelien Jarno wrote:
> Use the new function float32_is_any_nan() instead of
> float32_is_quiet_nan() || float32_is_signaling_nan().
> 
> Cc: Alexander Graf <agraf@suse.de>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

Reviewed-by: Nathan Froyd <froydnj@codesourcery.com>

> @@ -1938,7 +1938,7 @@ target_ulong helper_dlmzb (target_ulong high, target_ulong low, uint32_t update_
>  /* If X is a NaN, store the corresponding QNaN into RESULT.  Otherwise,
>   * execute the following block.  */
>  #define DO_HANDLE_NAN(result, x)                \
> -    if (float32_is_quiet_nan(x) || float32_is_signaling_nan(x)) {     \
> +    if (float32_is_any_nan(x)) {                                \
>          CPU_FloatU __f;                                         \
>          __f.f = x;                                              \
>          __f.l = __f.l | (1 << 22);  /* Set QNaN bit. */         \

If you were looking for other cleanups, this could stand a
maybe_silence_nan.

-Nathan
Peter Maydell Jan. 5, 2011, 5:14 p.m.
On 5 January 2011 16:59, Alexander Graf <agraf@suse.de> wrote:
>
> On 02.01.2011, at 13:06, Aurelien Jarno wrote:
>
>> Use the new function float32_is_any_nan() instead of
>> float32_is_quiet_nan() || float32_is_signaling_nan().
>>
>> Cc: Alexander Graf <agraf@suse.de>
>> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
>
> I frankly have very little knowledge of FP stuff. Is any_nan really equal to quiet_nan || signaling_nan or would it cover more cases?

It is exactly equivalent -- all NaNs are either signalling or quiet.

(If you want to check this you don't need to know anything about floating
point, all three functions are just acting on 32 bit values so you could
in theory identify all the bit patterns they return true or false on...)

-- PMM
Alexander Graf Jan. 5, 2011, 5:19 p.m.
On 05.01.2011, at 18:14, Peter Maydell wrote:

> On 5 January 2011 16:59, Alexander Graf <agraf@suse.de> wrote:
>> 
>> On 02.01.2011, at 13:06, Aurelien Jarno wrote:
>> 
>>> Use the new function float32_is_any_nan() instead of
>>> float32_is_quiet_nan() || float32_is_signaling_nan().
>>> 
>>> Cc: Alexander Graf <agraf@suse.de>
>>> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
>> 
>> I frankly have very little knowledge of FP stuff. Is any_nan really equal to quiet_nan || signaling_nan or would it cover more cases?
> 
> It is exactly equivalent -- all NaNs are either signalling or quiet.
> 
> (If you want to check this you don't need to know anything about floating
> point, all three functions are just acting on 32 bit values so you could
> in theory identify all the bit patterns they return true or false on...)

Yeah, reading on through the FP parts of the spec I realized that too :). Thanks for the clarification.

Acked-by: Alexander Graf <agraf@suse.de>


Alex

Patch hide | download patch | download mbox

diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index 5ded1c1..89be0f4 100644
--- a/target-ppc/op_helper.c
+++ b/target-ppc/op_helper.c
@@ -1938,7 +1938,7 @@  target_ulong helper_dlmzb (target_ulong high, target_ulong low, uint32_t update_
 /* If X is a NaN, store the corresponding QNaN into RESULT.  Otherwise,
  * execute the following block.  */
 #define DO_HANDLE_NAN(result, x)                \
-    if (float32_is_quiet_nan(x) || float32_is_signaling_nan(x)) {     \
+    if (float32_is_any_nan(x)) {                                \
         CPU_FloatU __f;                                         \
         __f.f = x;                                              \
         __f.l = __f.l | (1 << 22);  /* Set QNaN bit. */         \
@@ -2283,8 +2283,7 @@  void helper_vcmpbfp_dot (ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
         float_status s = env->vec_status;                               \
         set_float_rounding_mode(float_round_to_zero, &s);               \
         for (i = 0; i < ARRAY_SIZE(r->f); i++) {                        \
-            if (float32_is_quiet_nan(b->f[i]) ||                              \
-                float32_is_signaling_nan(b->f[i])) {                    \
+            if (float32_is_any_nan(b->f[i])) {                          \
                 r->element[i] = 0;                                      \
             } else {                                                    \
                 float64 t = float32_to_float64(b->f[i], &s);            \