aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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 b65a055d0a..b953e7c563 100644
--- a/tests/tcg/i386/test-i386-fscale.c
+++ b/tests/tcg/i386/test-i386-fscale.c
@@ -31,6 +31,7 @@ int issignaling_ld(long double x)
int main(void)
{
+ short cw;
int ret = 0;
__asm__ volatile ("fscale" : "=t" (ld_res) :
"0" (2.5L), "u" (__builtin_nansl("")));
@@ -62,5 +63,33 @@ int main(void)
printf("FAIL: fscale invalid 4\n");
ret = 1;
}
+ __asm__ volatile ("fscale" : "=t" (ld_res) :
+ "0" (0.0L), "u" (__builtin_infl()));
+ if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) {
+ printf("FAIL: fscale 0 up inf\n");
+ ret = 1;
+ }
+ __asm__ volatile ("fscale" : "=t" (ld_res) :
+ "0" (__builtin_infl()), "u" (-__builtin_infl()));
+ if (!isnan_ld(ld_res) || issignaling_ld(ld_res)) {
+ printf("FAIL: fscale inf down inf\n");
+ ret = 1;
+ }
+ /* Set round-downward. */
+ __asm__ volatile ("fnstcw %0" : "=m" (cw));
+ cw = (cw & ~0xc00) | 0x400;
+ __asm__ volatile ("fldcw %0" : : "m" (cw));
+ __asm__ volatile ("fscale" : "=t" (ld_res) :
+ "0" (1.0L), "u" (__builtin_infl()));
+ if (ld_res != __builtin_infl()) {
+ printf("FAIL: fscale finite up inf\n");
+ ret = 1;
+ }
+ __asm__ volatile ("fscale" : "=t" (ld_res) :
+ "0" (-1.0L), "u" (-__builtin_infl()));
+ if (ld_res != -0.0L || __builtin_copysignl(1.0L, ld_res) != -1.0L) {
+ printf("FAIL: fscale finite down inf\n");
+ ret = 1;
+ }
return ret;
}