On Fri, 30 Apr 2021 at 22:24, Richard Henderson
<[email protected]> wrote:
>
> From: Stephen Long <[email protected]>
>
> Signed-off-by: Stephen Long <[email protected]>
> Message-Id: <[email protected]>
> Signed-off-by: Richard Henderson <[email protected]>
> ---
> v2: Fixed esz index and c++ comments
> v3: Fixed denormal arithmetic and raise invalid.
> +static int64_t do_float64_logb_as_int(float64 a, float_status *s)
> +{
> + if (float64_is_normal(a)) {
> + return extract64(a, 52, 11) - 1023;
> + } else if (float64_is_infinity(a)) {
> + return INT64_MAX;
> + } else if (float64_is_any_nan(a) || float64_is_zero(a)) {
> + float_raise(float_flag_invalid, s);
> + return INT64_MIN;
> + } else {
> + /* denormal (see above) */
> + return -1023 + 12 - clz64(extract64(a, 0, 52));
> + }
> +}
These don't look like they're handling denormal inputs quite right:
* should raise the input-denormal exception
* should flush-to-zero if that is enabled
thanks
-- PMM