qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 18/20] fpu/softfloat: re-factor scalbn


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v2 18/20] fpu/softfloat: re-factor scalbn
Date: Fri, 12 Jan 2018 16:31:52 +0000

On 9 January 2018 at 12:22, Alex Bennée <address@hidden> wrote:
> This is one of the simpler manipulations you could make to a floating
> point number.
>
> Signed-off-by: Alex Bennée <address@hidden>
> Reviewed-by: Richard Henderson <address@hidden>
> ---
>  fpu/softfloat.c         | 104 
> +++++++++++++++---------------------------------
>  include/fpu/softfloat.h |   1 +
>  2 files changed, 32 insertions(+), 73 deletions(-)
>
> diff --git a/fpu/softfloat.c b/fpu/softfloat.c
> index bb68d77f72..3647f6ca03 100644
> --- a/fpu/softfloat.c
> +++ b/fpu/softfloat.c
> @@ -1663,6 +1663,37 @@ float64 uint16_to_float64(uint16_t a, float_status 
> *status)
>      return uint64_to_float64(a, status);
>  }
>
> +/* Multiply A by 2 raised to the power N.  */
> +static decomposed_parts scalbn_decomposed(decomposed_parts a, int n,
> +                                          float_status *s)
> +{
> +    if (a.cls == float_class_normal) {
> +        a.exp += n;
> +    }
> +    return a;
> +}
> +
> +float16 float16_scalbn(float16 a, int n, float_status *status)
> +{
> +    decomposed_parts pa = float16_unpack_canonical(a, status);
> +    decomposed_parts pr = scalbn_decomposed(pa, n, status);
> +    return float16_round_pack_canonical(pr, status);
> +}
> +
> +float32 float32_scalbn(float32 a, int n, float_status *status)
> +{
> +    decomposed_parts pa = float32_unpack_canonical(a, status);
> +    decomposed_parts pr = scalbn_decomposed(pa, n, status);
> +    return float32_round_pack_canonical(pr, status);
> +}
> +
> +float64 float64_scalbn(float64 a, int n, float_status *status)
> +{
> +    decomposed_parts pa = float64_unpack_canonical(a, status);
> +    decomposed_parts pr = scalbn_decomposed(pa, n, status);
> +    return float64_round_pack_canonical(pr, status);
> +}

The old code used propagateFloat32NaN(a, a, status) if the
input was a NaN, to cause us to raise the invalid flag,
maybe return a default NaN, maybe silence the NaN. I can't
see where the new code is doing this?

thanks
-- PMM



reply via email to

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