[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH RFC] target/arm: Implement SVE2 FLOGB
From: |
Richard Henderson |
Subject: |
Re: [PATCH RFC] target/arm: Implement SVE2 FLOGB |
Date: |
Thu, 30 Apr 2020 10:43:44 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
On 4/30/20 10:20 AM, Stephen Long wrote:
> +DO_ZPZ_FP(flogb_s, float32, H1_4, float32_log2)
> +DO_ZPZ_FP(flogb_d, float64, , float64_log2)
Please read the instruction description more carefully. The result is not the
full log2 of the input:
> This instruction returns the signed integer base 2 logarithm of each
> floating-point input element | X | after normalization. This is the unbiased
> exponent of X used in the representation of the floating-point value, such
> that, for positive X , X = significand × 2 exponent.
Please look at Library pseudocode for aarch64/functions/sve/FPLogB in the
manual.
You then use the helpers from softfloat.h like so
if (float32_is_normal(x)) {
// extract exponent and remove bias
return extract32(x, 23, 8) - 127;
} else if (float32_is_infinity(x)) {
return INT32_MAX;
} else if (float32_is_any_nan(x) || float32_is_zero(x)) {
return INT32_MIN;
} else {
// denormal
// extract fraction, normalize vs 2**-127.
int shift = 9 - clz32(extract32(0, 23));
return -127 - shift + 1;
}
r~