diff options
author | Joseph Myers | 2020-05-07 02:44:14 +0200 |
---|---|---|
committer | Paolo Bonzini | 2020-06-10 18:10:17 +0200 |
commit | 0d48b436327955c69e2eb53f88aba9aa1e0dbaa0 (patch) | |
tree | 213a5ebda7167b9e886062d49a02a7d593d72bb3 /tests/tcg/i386/test-i386-fscale.c | |
parent | target/i386: implement special cases for fxtract (diff) | |
download | qemu-0d48b436327955c69e2eb53f88aba9aa1e0dbaa0.tar.gz qemu-0d48b436327955c69e2eb53f88aba9aa1e0dbaa0.tar.xz qemu-0d48b436327955c69e2eb53f88aba9aa1e0dbaa0.zip |
target/i386: fix fscale handling of signaling NaN
The implementation of the fscale instruction returns a NaN exponent
unchanged. Fix it to return a quiet NaN when the provided exponent is
a signaling NaN.
Signed-off-by: Joseph Myers <joseph@codesourcery.com>
Message-Id: <alpine.DEB.2.21.2005070043330.18350@digraph.polyomino.org.uk>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/tcg/i386/test-i386-fscale.c')
-rw-r--r-- | tests/tcg/i386/test-i386-fscale.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/tcg/i386/test-i386-fscale.c b/tests/tcg/i386/test-i386-fscale.c new file mode 100644 index 0000000000..aecac5125f --- /dev/null +++ b/tests/tcg/i386/test-i386-fscale.c @@ -0,0 +1,37 @@ +/* Test fscale instruction. */ + +#include <stdint.h> +#include <stdio.h> + +union u { + struct { uint64_t sig; uint16_t sign_exp; } s; + long double ld; +}; + +volatile long double ld_res; + +int isnan_ld(long double x) +{ + union u tmp = { .ld = x }; + return ((tmp.s.sign_exp & 0x7fff) == 0x7fff && + (tmp.s.sig >> 63) != 0 && + (tmp.s.sig << 1) != 0); +} + +int issignaling_ld(long double x) +{ + union u tmp = { .ld = x }; + return isnan_ld(x) && (tmp.s.sig & UINT64_C(0x4000000000000000)) == 0; +} + +int main(void) +{ + int ret = 0; + __asm__ volatile ("fscale" : "=t" (ld_res) : + "0" (2.5L), "u" (__builtin_nansl(""))); + if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) { + printf("FAIL: fscale snan\n"); + ret = 1; + } + return ret; +} |