[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/11] target/arm: Use float64_to_int32_modulo for FJCVTZS
From: |
Richard Henderson |
Subject: |
[PULL 08/11] target/arm: Use float64_to_int32_modulo for FJCVTZS |
Date: |
Sat, 1 Jul 2023 08:55:07 +0200 |
The standard floating point results are provided by the generic routine.
We only need handle the extra Z flag result afterward.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20230527141910.1885950-5-richard.henderson@linaro.org>
---
target/arm/vfp_helper.c | 71 +++++++----------------------------------
1 file changed, 12 insertions(+), 59 deletions(-)
diff --git a/target/arm/vfp_helper.c b/target/arm/vfp_helper.c
index 36906db8e0..789bba36cc 100644
--- a/target/arm/vfp_helper.c
+++ b/target/arm/vfp_helper.c
@@ -1120,68 +1120,21 @@ const FloatRoundMode arm_rmode_to_sf_map[] = {
uint64_t HELPER(fjcvtzs)(float64 value, void *vstatus)
{
float_status *status = vstatus;
- uint32_t exp, sign;
- uint64_t frac;
- uint32_t inexact = 1; /* !Z */
+ uint32_t inexact, frac;
+ uint32_t e_old, e_new;
- sign = extract64(value, 63, 1);
- exp = extract64(value, 52, 11);
- frac = extract64(value, 0, 52);
+ e_old = get_float_exception_flags(status);
+ set_float_exception_flags(0, status);
+ frac = float64_to_int32_modulo(value, float_round_to_zero, status);
+ e_new = get_float_exception_flags(status);
+ set_float_exception_flags(e_old | e_new, status);
- if (exp == 0) {
- /* While not inexact for IEEE FP, -0.0 is inexact for JavaScript. */
- inexact = sign;
- if (frac != 0) {
- if (status->flush_inputs_to_zero) {
- float_raise(float_flag_input_denormal, status);
- } else {
- float_raise(float_flag_inexact, status);
- inexact = 1;
- }
- }
- frac = 0;
- } else if (exp == 0x7ff) {
- /* This operation raises Invalid for both NaN and overflow (Inf). */
- float_raise(float_flag_invalid, status);
- frac = 0;
+ if (value == float64_chs(float64_zero)) {
+ /* While not inexact for IEEE FP, -0.0 is inexact for JavaScript. */
+ inexact = 1;
} else {
- int true_exp = exp - 1023;
- int shift = true_exp - 52;
-
- /* Restore implicit bit. */
- frac |= 1ull << 52;
-
- /* Shift the fraction into place. */
- if (shift >= 0) {
- /* The number is so large we must shift the fraction left. */
- if (shift >= 64) {
- /* The fraction is shifted out entirely. */
- frac = 0;
- } else {
- frac <<= shift;
- }
- } else if (shift > -64) {
- /* Normal case -- shift right and notice if bits shift out. */
- inexact = (frac << (64 + shift)) != 0;
- frac >>= -shift;
- } else {
- /* The fraction is shifted out entirely. */
- frac = 0;
- }
-
- /* Notice overflow or inexact exceptions. */
- if (true_exp > 31 || frac > (sign ? 0x80000000ull : 0x7fffffff)) {
- /* Overflow, for which this operation raises invalid. */
- float_raise(float_flag_invalid, status);
- inexact = 1;
- } else if (inexact) {
- float_raise(float_flag_inexact, status);
- }
-
- /* Honor the sign. */
- if (sign) {
- frac = -frac;
- }
+ /* Normal inexact or overflow or NaN */
+ inexact = e_new & (float_flag_inexact | float_flag_invalid);
}
/* Pack the result and the env->ZF representation of Z together. */
--
2.34.1
- [PULL 00/11] tcg and misc patch queue, Richard Henderson, 2023/07/01
- [PULL 01/11] ui/dbus: fix build errors in dbus_update_gl_cb and dbus_call_update_gl, Richard Henderson, 2023/07/01
- [PULL 04/11] accel/tcg: Assert one page in tb_invalidate_phys_page_range__locked, Richard Henderson, 2023/07/01
- [PULL 03/11] accel/tcg: Fix start page passed to tb_invalidate_phys_page_range__locked, Richard Henderson, 2023/07/01
- [PULL 07/11] target/alpha: Use float64_to_int64_modulo for CVTTQ, Richard Henderson, 2023/07/01
- [PULL 08/11] target/arm: Use float64_to_int32_modulo for FJCVTZS,
Richard Henderson <=
- [PULL 09/11] tcg: Reduce tcg_assert_listed_vecop() scope, Richard Henderson, 2023/07/01
- [PULL 05/11] fpu: Add float64_to_int{32,64}_modulo, Richard Henderson, 2023/07/01
- [PULL 02/11] audio: dbus requires pixman, Richard Henderson, 2023/07/01
- [PULL 06/11] tests/tcg/alpha: Add test for cvttq, Richard Henderson, 2023/07/01
- [PULL 11/11] linux-user: Avoid mmap of the last byte of the reserved_va, Richard Henderson, 2023/07/01
- [PULL 10/11] target/nios2 : Explicitly ask for target-endian loads and stores, Richard Henderson, 2023/07/01
- Re: [PULL 00/11] tcg and misc patch queue, Philippe Mathieu-Daudé, 2023/07/01