qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/3] target-arm: fix support for vrecpe.


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 2/3] target-arm: fix support for vrecpe.
Date: Thu, 17 Feb 2011 12:23:19 +0000

On 16 February 2011 17:59,  <address@hidden> wrote:
> From: Christophe Lyon <address@hidden>
>
> Now use the same algorithm as described in the ARM ARM.
>
> Signed-off-by: Christophe Lyon <address@hidden>

Mostly looks good, and seems to pass random testing.

> +    float_status *s = &env->vfp.standard_fp_status;
> +    float64 one = int64_to_float64(1, s);

You don't need to create a variable for this, float64_one
will do what you want.

> +    /* q = (int)(a * 512.0) */
> +    float64 x512 = int64_to_float64(512, s);
> +    float64 q = float64_mul(x512, a, s);
> +    int64_t q_int = float64_to_int64_round_to_zero(q, s);
> +
> +    /* r = 1.0 / (((double)q + 0.5) / 512.0) */
> +    q = int64_to_float64(q_int, s);
> +    float64 half = float64_div(one, int64_to_float64(2, s), s);

...and a runtime division just to get a constant 0.5?
Better to just make_float64() on the appropriate bit
pattern, I think.

>  float32 HELPER(recpe_f32)(float32 a, CPUState *env)
>  {
> -    float_status *s = &env->vfp.fp_status;
> -    float32 one = int32_to_float32(1, s);
> -    return float32_div(one, a, s);
> +    float_status *s = &env->vfp.standard_fp_status;
> +    float64 f64;
> +    uint32_t val32 = float32_val(a);
> +
> +    int result_exp;
> +    int a_exp = (val32  & 0x7f800000) >> 23;
> +    int sign = val32 & 0x80000000;
> +
> +    if (float32_is_any_nan(a)) {
> +        return float32_default_nan;

This won't set InvalidOp if the input is a signalling NaN.

-- PMM



reply via email to

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