[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7.2.3 15/30] softfloat: Fix the incorrect computation in float32
From: |
Michael Tokarev |
Subject: |
[PATCH v7.2.3 15/30] softfloat: Fix the incorrect computation in float32_exp2 |
Date: |
Wed, 17 May 2023 12:10:27 +0300 |
From: Shivaprasad G Bhat <sbhat@linux.ibm.com>
The float32_exp2 function is computing wrong exponent of 2.
For example, with the following set of values {0.1, 2.0, 2.0, -1.0},
the expected output would be {1.071773, 4.000000, 4.000000, 0.500000}.
Instead, the function is computing {1.119102, 3.382044, 3.382044, -0.191022}
Looking at the code, the float32_exp2() attempts to do this
2 3 4 5 n
x x x x x x x
e = 1 + --- + --- + --- + --- + --- + ... + --- + ...
1! 2! 3! 4! 5! n!
But because of the typo it ends up doing
x x x x x x x
e = 1 + --- + --- + --- + --- + --- + ... + --- + ...
1! 2! 3! 4! 5! n!
This is because instead of the xnp which holds the numerator, parts_muladd
is using the xp which is just 'x'. Commit '572c4d862ff2' refactored this
function, and mistakenly used xp instead of xnp.
Cc: qemu-stable@nongnu.org
Fixes: 572c4d862ff2 "softfloat: Convert float32_exp2 to FloatParts"
Partially-Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1623
Reported-By: Luca Barbato (https://gitlab.com/lu-zero)
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit 1098cc3fcf952763fc9fd72c1c8fda30a18cc8ea)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
fpu/softfloat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index c7454c3eb1..108f9cb224 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -5135,7 +5135,7 @@ float32 float32_exp2(float32 a, float_status *status)
float64_unpack_canonical(&rp, float64_one, status);
for (i = 0 ; i < 15 ; i++) {
float64_unpack_canonical(&tp, float32_exp2_coefficients[i], status);
- rp = *parts_muladd(&tp, &xp, &rp, 0, status);
+ rp = *parts_muladd(&tp, &xnp, &rp, 0, status);
xnp = *parts_mul(&xnp, &xp, status);
}
--
2.39.2
- [PATCH v7.2.3 12/30] target/arm: Define and use new load_cpu_field_low32(), (continued)
- [PATCH v7.2.3 12/30] target/arm: Define and use new load_cpu_field_low32(), Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 13/30] hw/sd/allwinner-sdhost: Correctly byteswap descriptor fields, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 14/30] hw/net/allwinner-sun8i-emac: Correctly byteswap descriptor fields, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 19/30] accel/tcg: Fix atomic_mmu_lookup for reads, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 17/30] block: Fix use after free in blockdev_mark_auto_del(), Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 16/30] meson: leave unnecessary modules out of the build, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 18/30] target/riscv: Fix itrigger when icount is used, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 22/30] tcg: ppc64: Fix mask generation for vextractdm, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 20/30] ui: Fix pixel colour channel order for PNG screenshots, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 24/30] virtio: fix reachable assertion due to stale value of cached region size, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 15/30] softfloat: Fix the incorrect computation in float32_exp2,
Michael Tokarev <=
- [PATCH v7.2.3 21/30] async: Suppress GCC13 false positive in aio_bh_poll(), Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 23/30] hw/virtio/vhost-user: avoid using unitialized errp, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 26/30] target/s390x: Fix EXECUTE of relative branches, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 25/30] block/monitor: Fix crash when executing HMP commit, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 29/30] Revert "vhost-user: Monitor slave channel in vhost_user_read()", Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 27/30] 9pfs/xen: Fix segfault on shutdown, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 28/30] xen/pt: reserve PCI slot 2 for Intel igd-passthru, Michael Tokarev, 2023/05/17
- [PATCH v7.2.3 30/30] Revert "vhost-user: Introduce nested event loop in vhost_user_read()", Michael Tokarev, 2023/05/17