[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~
- Re: [Qemu-devel] [PATCH v1 04/19] include/fpu/softfloat: implement float16_set_sign helper, (continued)
- [Qemu-devel] [PATCH v1 08/19] fpu/softfloat: move the extract functions to the top of the file, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 07/19] fpu/softfloat: improve comments on ARM NaN propagation, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 09/19] fpu/softfloat: define decompose structures, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 14/19] fpu/softfloat: re-factor round_to_int, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 19/19] fpu/softfloat: re-factor compare, Alex Bennée, 2017/12/11
- Re: [Qemu-devel] [PATCH v1 19/19] fpu/softfloat: re-factor compare,
Richard Henderson <=
- [Qemu-devel] [PATCH v1 17/19] fpu/softfloat: re-factor scalbn, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 10/19] fpu/softfloat: re-factor add/sub, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 13/19] fpu/softfloat: re-factor muladd, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 15/19] fpu/softfloat: re-factor float to int/uint, Alex Bennée, 2017/12/11
- [Qemu-devel] [PATCH v1 11/19] fpu/softfloat: re-factor mul, Alex Bennée, 2017/12/11