1 /* Test fxam instruction. */
7 struct { uint64_t sig
; uint16_t sign_exp
; } s
;
11 volatile union u ld_pseudo_m16382
= { .s
= { UINT64_C(1) << 63, 0 } };
12 volatile union u ld_pseudo_nm16382
= { .s
= { UINT64_C(1) << 63, 0x8000 } };
13 volatile union u ld_invalid_1
= { .s
= { 1, 1234 } };
14 volatile union u ld_invalid_2
= { .s
= { 0, 1234 } };
15 volatile union u ld_invalid_3
= { .s
= { 0, 0x7fff } };
16 volatile union u ld_invalid_4
= { .s
= { (UINT64_C(1) << 63) - 1, 0x7fff } };
17 volatile union u ld_invalid_n1
= { .s
= { 1, 0x8123 } };
18 volatile union u ld_invalid_n2
= { .s
= { 0, 0x8123 } };
19 volatile union u ld_invalid_n3
= { .s
= { 0, 0xffff } };
20 volatile union u ld_invalid_n4
= { .s
= { (UINT64_C(1) << 63) - 1, 0xffff } };
26 #define FLAGS (C0 | C1 | C2 | C3)
32 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (0.0L));
33 if ((sw
& FLAGS
) != C3
) {
37 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (-0.0L));
38 if ((sw
& FLAGS
) != (C3
| C1
)) {
42 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (1.0L));
43 if ((sw
& FLAGS
) != C2
) {
44 printf("FAIL: +normal\n");
47 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (-1.0L));
48 if ((sw
& FLAGS
) != (C2
| C1
)) {
49 printf("FAIL: -normal\n");
52 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (__builtin_infl()));
53 if ((sw
& FLAGS
) != (C2
| C0
)) {
54 printf("FAIL: +inf\n");
57 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (-__builtin_infl()));
58 if ((sw
& FLAGS
) != (C2
| C1
| C0
)) {
59 printf("FAIL: -inf\n");
62 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (__builtin_nanl("")));
63 if ((sw
& FLAGS
) != C0
) {
64 printf("FAIL: +nan\n");
67 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (-__builtin_nanl("")));
68 if ((sw
& FLAGS
) != (C1
| C0
)) {
69 printf("FAIL: -nan\n");
72 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (__builtin_nansl("")));
73 if ((sw
& FLAGS
) != C0
) {
74 printf("FAIL: +snan\n");
77 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (-__builtin_nansl("")));
78 if ((sw
& FLAGS
) != (C1
| C0
)) {
79 printf("FAIL: -snan\n");
82 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (0x1p
-16445L));
83 if ((sw
& FLAGS
) != (C3
| C2
)) {
84 printf("FAIL: +denormal\n");
87 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (-0x1p
-16445L));
88 if ((sw
& FLAGS
) != (C3
| C2
| C1
)) {
89 printf("FAIL: -denormal\n");
92 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (ld_pseudo_m16382
.ld
));
93 if ((sw
& FLAGS
) != (C3
| C2
)) {
94 printf("FAIL: +pseudo-denormal\n");
97 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (ld_pseudo_nm16382
.ld
));
98 if ((sw
& FLAGS
) != (C3
| C2
| C1
)) {
99 printf("FAIL: -pseudo-denormal\n");
102 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (ld_invalid_1
.ld
));
103 if ((sw
& FLAGS
) != 0) {
104 printf("FAIL: +invalid 1\n");
107 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (ld_invalid_n1
.ld
));
108 if ((sw
& FLAGS
) != C1
) {
109 printf("FAIL: -invalid 1\n");
112 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (ld_invalid_2
.ld
));
113 if ((sw
& FLAGS
) != 0) {
114 printf("FAIL: +invalid 2\n");
117 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (ld_invalid_n2
.ld
));
118 if ((sw
& FLAGS
) != C1
) {
119 printf("FAIL: -invalid 2\n");
122 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (ld_invalid_3
.ld
));
123 if ((sw
& FLAGS
) != 0) {
124 printf("FAIL: +invalid 3\n");
127 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (ld_invalid_n3
.ld
));
128 if ((sw
& FLAGS
) != C1
) {
129 printf("FAIL: -invalid 3\n");
132 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (ld_invalid_4
.ld
));
133 if ((sw
& FLAGS
) != 0) {
134 printf("FAIL: +invalid 4\n");
137 __asm__
volatile ("fxam\nfnstsw" : "=a" (sw
) : "t" (ld_invalid_n4
.ld
));
138 if ((sw
& FLAGS
) != C1
) {
139 printf("FAIL: -invalid 4\n");