qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v1 19/19] fpu/softfloat: re-factor compare


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH v1 19/19] fpu/softfloat: re-factor compare
Date: Mon, 18 Dec 2017 15:26:31 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

On 12/11/2017 04:57 AM, Alex Bennée wrote:
> +    if (a.cls == float_class_zero || b.cls == float_class_zero) {
> +        if (a.cls == float_class_normal) {
> +            return a.sign ? float_relation_less : float_relation_greater;
> +        } else if (b.cls == float_class_normal) {
> +            return b.sign ? float_relation_greater : float_relation_less;
> +        } else if (a.cls == b.cls) {
> +            return float_relation_equal;
> +        }
> +    }

This misses out on infinity handling, which should be like normals.
Perhaps better as

    if (a.cls == float_class_zero) {
        if (b.cls == float_class_zero) {
            return float_relation_equal;
        }
        return b.sign ? float_relation_greater : float_relation_less;
    } else if (b.cls == float_class_zero) {
        return a.sign ? float_relation_less : float_relation_greater;
    }

> +    /* The only infinity we need to explicitly worry about is
> +     * comparing two together, otherwise the max_exp/sign details are
> +     * enough to compare to normal numbers
> +     */

I don't think it's wise to rely on the contents of .exp for float_class_inf.
Really, the only valid member for that type is sign.  Better as

    if (a.cls == float_class_inf) {
        if (b.cls == float_class_inf) {
            if (a.sign == b.sign) {
                return float_relation_equal;
            }
        }
        return a.sign ? float_relation_less : float_relation_greater;
    } else if (b.cls == float_class_inf) {
        return b.sign ? float_relation_less : float_relation_greater;
    }


r~



reply via email to

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