summaryrefslogtreecommitdiffstats
path: root/tests/tcg/i386
diff options
context:
space:
mode:
authorJoseph Myers2020-05-07 02:44:57 +0200
committerPaolo Bonzini2020-06-10 18:10:17 +0200
commitb40eec96b26028b68c3594fbf34b6d6f029df26a (patch)
tree9d102ee76ffb044cc3fe3612d37e634c85cc3c05 /tests/tcg/i386
parenttarget/i386: fix fscale handling of signaling NaN (diff)
downloadqemu-b40eec96b26028b68c3594fbf34b6d6f029df26a.tar.gz
qemu-b40eec96b26028b68c3594fbf34b6d6f029df26a.tar.xz
qemu-b40eec96b26028b68c3594fbf34b6d6f029df26a.zip
target/i386: fix fscale handling of invalid exponent encodings
The fscale implementation does not check for invalid encodings in the exponent operand, thus treating them like INT_MIN (the value returned for invalid encodings by floatx80_to_int32_round_to_zero). Fix it to treat them similarly to signaling NaN exponents, thus generating a quiet NaN result. Signed-off-by: Joseph Myers <joseph@codesourcery.com> Message-Id: <alpine.DEB.2.21.2005070044190.18350@digraph.polyomino.org.uk> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/tcg/i386')
-rw-r--r--tests/tcg/i386/test-i386-fscale.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/tcg/i386/test-i386-fscale.c b/tests/tcg/i386/test-i386-fscale.c
index aecac5125f..b65a055d0a 100644
--- a/tests/tcg/i386/test-i386-fscale.c
+++ b/tests/tcg/i386/test-i386-fscale.c
@@ -8,6 +8,11 @@ union u {
long double ld;
};
+volatile union u ld_invalid_1 = { .s = { 1, 1234 } };
+volatile union u ld_invalid_2 = { .s = { 0, 1234 } };
+volatile union u ld_invalid_3 = { .s = { 0, 0x7fff } };
+volatile union u ld_invalid_4 = { .s = { (UINT64_C(1) << 63) - 1, 0x7fff } };
+
volatile long double ld_res;
int isnan_ld(long double x)
@@ -33,5 +38,29 @@ int main(void)
printf("FAIL: fscale snan\n");
ret = 1;
}
+ __asm__ volatile ("fscale" : "=t" (ld_res) :
+ "0" (2.5L), "u" (ld_invalid_1.ld));
+ if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) {
+ printf("FAIL: fscale invalid 1\n");
+ ret = 1;
+ }
+ __asm__ volatile ("fscale" : "=t" (ld_res) :
+ "0" (2.5L), "u" (ld_invalid_2.ld));
+ if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) {
+ printf("FAIL: fscale invalid 2\n");
+ ret = 1;
+ }
+ __asm__ volatile ("fscale" : "=t" (ld_res) :
+ "0" (2.5L), "u" (ld_invalid_3.ld));
+ if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) {
+ printf("FAIL: fscale invalid 3\n");
+ ret = 1;
+ }
+ __asm__ volatile ("fscale" : "=t" (ld_res) :
+ "0" (2.5L), "u" (ld_invalid_4.ld));
+ if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) {
+ printf("FAIL: fscale invalid 4\n");
+ ret = 1;
+ }
return ret;
}