target/mips/rel6_translate: Change license to GNU LGPL v2.1 (or later)
[qemu/ar7.git] / tests / tcg / i386 / test-i386-pseudo-denormal.c
blob00d510cf4a105197308cdedbfa1674d1454af6ff
1 /* Test pseudo-denormal operations. */
3 #include <stdint.h>
4 #include <stdio.h>
6 union u {
7 struct { uint64_t sig; uint16_t sign_exp; } s;
8 long double ld;
9 };
11 volatile union u ld_pseudo_m16382 = { .s = { UINT64_C(1) << 63, 0 } };
13 volatile long double ld_res;
15 int main(void)
17 short cw;
18 int ret = 0;
19 ld_res = ld_pseudo_m16382.ld + ld_pseudo_m16382.ld;
20 if (ld_res != 0x1p-16381L) {
21 printf("FAIL: pseudo-denormal add\n");
22 ret = 1;
24 if (ld_pseudo_m16382.ld != 0x1p-16382L) {
25 printf("FAIL: pseudo-denormal compare\n");
26 ret = 1;
28 /* Set round-upward. */
29 __asm__ volatile ("fnstcw %0" : "=m" (cw));
30 cw = (cw & ~0xc00) | 0x800;
31 __asm__ volatile ("fldcw %0" : : "m" (cw));
32 __asm__ ("frndint" : "=t" (ld_res) : "0" (ld_pseudo_m16382.ld));
33 if (ld_res != 1.0L) {
34 printf("FAIL: pseudo-denormal round-to-integer\n");
35 ret = 1;
37 return ret;