qemu-arm
[Top][All Lists]
Advanced

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

Re: [Qemu-arm] [RFC PATCH 20/30] softfloat: half-precision compare funct


From: Richard Henderson
Subject: Re: [Qemu-arm] [RFC PATCH 20/30] softfloat: half-precision compare functions
Date: Mon, 16 Oct 2017 17:06:18 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 10/13/2017 09:24 AM, Alex Bennée wrote:
> +int float16_eq(float16 a, float16 b, float_status *status)
> +{
> +    uint32_t av, bv;
> +    a = float16_squash_input_denormal(a, status);
> +    b = float16_squash_input_denormal(b, status);
> +
> +    if (    ( ( extractFloat16Exp( a ) == 0x1F ) && extractFloat16Frac( a ) )
> +         || ( ( extractFloat16Exp( b ) == 0x1F ) && extractFloat16Frac( b ) )

float16_is_any_nan

> +       ) {
> +        float_raise(float_flag_invalid, status);
> +        return 0;
> +    }
> +    av = float16_val(a);
> +    bv = float16_val(b);
> +    return ( av == bv ) || ( (uint32_t) ( ( av | bv )<<1 ) == 0 );

For this trick to work you have to truncate to uint16_t not uint32_t.
It might be easier to read as

  a == b || float16_is_zero(a | b)

That said, I wonder if it wouldn't be better to implement all of these in terms
of float16_compare, rather than duplicating all of this code.


r~



reply via email to

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