summaryrefslogtreecommitdiffstats
path: root/tests/tcg/i386
diff options
context:
space:
mode:
authorJoseph Myers2020-05-05 01:38:44 +0200
committerRichard Henderson2020-05-15 20:04:50 +0200
commit41602807766e253ccb6fb761f3ff12767f786e2c (patch)
tree45d0d63bc499fbe670848855eb250d3979da3ae9 /tests/tcg/i386
parentsoftfloat: silence sNaN for conversions to/from floatx80 (diff)
downloadqemu-41602807766e253ccb6fb761f3ff12767f786e2c.tar.gz
qemu-41602807766e253ccb6fb761f3ff12767f786e2c.tar.xz
qemu-41602807766e253ccb6fb761f3ff12767f786e2c.zip
softfloat: fix floatx80 pseudo-denormal addition / subtraction
The softfloat function addFloatx80Sigs, used for addition of values with the same sign and subtraction of values with opposite sign, fails to handle the case where the two values both have biased exponent zero and there is a carry resulting from adding the significands, which can occur if one or both values are pseudo-denormals (biased exponent zero, explicit integer bit 1). Add a check for that case, so making the results match those seen on x86 hardware for pseudo-denormals. Signed-off-by: Joseph Myers <joseph@codesourcery.com> Message-Id: <alpine.DEB.2.21.2005042337570.22972@digraph.polyomino.org.uk> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'tests/tcg/i386')
-rw-r--r--tests/tcg/i386/test-i386-pseudo-denormal.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/tcg/i386/test-i386-pseudo-denormal.c b/tests/tcg/i386/test-i386-pseudo-denormal.c
new file mode 100644
index 0000000000..cfa2a500b0
--- /dev/null
+++ b/tests/tcg/i386/test-i386-pseudo-denormal.c
@@ -0,0 +1,24 @@
+/* Test pseudo-denormal operations. */
+
+#include <stdint.h>
+#include <stdio.h>
+
+union u {
+ struct { uint64_t sig; uint16_t sign_exp; } s;
+ long double ld;
+};
+
+volatile union u ld_pseudo_m16382 = { .s = { UINT64_C(1) << 63, 0 } };
+
+volatile long double ld_res;
+
+int main(void)
+{
+ int ret = 0;
+ ld_res = ld_pseudo_m16382.ld + ld_pseudo_m16382.ld;
+ if (ld_res != 0x1p-16381L) {
+ printf("FAIL: pseudo-denormal add\n");
+ ret = 1;
+ }
+ return ret;
+}