1 /* Test floating-point exceptions. */
8 struct { uint64_t sig
; uint16_t sign_exp
; } s
;
13 volatile double d_res
;
14 volatile long double ld_res
;
15 volatile long double ld_res2
;
17 volatile union u ld_invalid_1
= { .s
= { 1, 1234 } };
18 volatile float f_snan
= __builtin_nansf("");
19 volatile double d_snan
= __builtin_nans("");
20 volatile long double ld_third
= 1.0L / 3.0L;
21 volatile long double ld_snan
= __builtin_nansl("");
22 volatile long double ld_nan
= __builtin_nanl("");
23 volatile long double ld_inf
= __builtin_infl();
24 volatile long double ld_ninf
= -__builtin_infl();
25 volatile long double ld_one
= 1.0L;
26 volatile long double ld_zero
= 0.0L;
27 volatile long double ld_nzero
= -0.0L;
28 volatile long double ld_min
= LDBL_MIN
;
29 volatile long double ld_max
= LDBL_MAX
;
30 volatile long double ld_nmax
= -LDBL_MAX
;
37 #define EXC (IE | ZE | OE | UE | PE)
42 unsigned char out
[10];
48 __asm__
volatile ("fnclex");
50 __asm__
volatile ("fnstsw" : "=a" (sw
));
51 if ((sw
& EXC
) != IE
) {
52 printf("FAIL: widen float snan\n");
55 __asm__
volatile ("fnclex");
57 __asm__
volatile ("fnstsw" : "=a" (sw
));
58 if ((sw
& EXC
) != IE
) {
59 printf("FAIL: widen double snan\n");
63 __asm__
volatile ("fnclex");
65 __asm__
volatile ("fnstsw" : "=a" (sw
));
66 if ((sw
& EXC
) != (UE
| PE
)) {
67 printf("FAIL: narrow float underflow\n");
70 __asm__
volatile ("fnclex");
72 __asm__
volatile ("fnstsw" : "=a" (sw
));
73 if ((sw
& EXC
) != (UE
| PE
)) {
74 printf("FAIL: narrow double underflow\n");
78 __asm__
volatile ("fnclex");
80 __asm__
volatile ("fnstsw" : "=a" (sw
));
81 if ((sw
& EXC
) != (OE
| PE
)) {
82 printf("FAIL: narrow float overflow\n");
85 __asm__
volatile ("fnclex");
87 __asm__
volatile ("fnstsw" : "=a" (sw
));
88 if ((sw
& EXC
) != (OE
| PE
)) {
89 printf("FAIL: narrow double overflow\n");
93 __asm__
volatile ("fnclex");
95 __asm__
volatile ("fnstsw" : "=a" (sw
));
96 if ((sw
& EXC
) != PE
) {
97 printf("FAIL: narrow float inexact\n");
100 __asm__
volatile ("fnclex");
102 __asm__
volatile ("fnstsw" : "=a" (sw
));
103 if ((sw
& EXC
) != PE
) {
104 printf("FAIL: narrow double inexact\n");
108 __asm__
volatile ("fnclex");
110 __asm__
volatile ("fnstsw" : "=a" (sw
));
111 if ((sw
& EXC
) != IE
) {
112 printf("FAIL: narrow float snan\n");
115 __asm__
volatile ("fnclex");
117 __asm__
volatile ("fnstsw" : "=a" (sw
));
118 if ((sw
& EXC
) != IE
) {
119 printf("FAIL: narrow double snan\n");
123 __asm__
volatile ("fnclex");
124 f_res
= ld_invalid_1
.ld
;
125 __asm__
volatile ("fnstsw" : "=a" (sw
));
126 if ((sw
& EXC
) != IE
) {
127 printf("FAIL: narrow float invalid\n");
130 __asm__
volatile ("fnclex");
131 d_res
= ld_invalid_1
.ld
;
132 __asm__
volatile ("fnstsw" : "=a" (sw
));
133 if ((sw
& EXC
) != IE
) {
134 printf("FAIL: narrow double invalid\n");
138 __asm__
volatile ("fnclex");
139 __asm__
volatile ("frndint" : "=t" (ld_res
) : "0" (ld_min
));
140 __asm__
volatile ("fnstsw" : "=a" (sw
));
141 if ((sw
& EXC
) != PE
) {
142 printf("FAIL: frndint min\n");
145 __asm__
volatile ("fnclex");
146 __asm__
volatile ("frndint" : "=t" (ld_res
) : "0" (ld_snan
));
147 __asm__
volatile ("fnstsw" : "=a" (sw
));
148 if ((sw
& EXC
) != IE
) {
149 printf("FAIL: frndint snan\n");
152 __asm__
volatile ("fnclex");
153 __asm__
volatile ("frndint" : "=t" (ld_res
) : "0" (ld_invalid_1
.ld
));
154 __asm__
volatile ("fnstsw" : "=a" (sw
));
155 if ((sw
& EXC
) != IE
) {
156 printf("FAIL: frndint invalid\n");
160 __asm__
volatile ("fnclex");
161 __asm__
volatile ("fcom" : : "t" (ld_nan
), "u" (ld_zero
));
162 __asm__
volatile ("fnstsw" : "=a" (sw
));
163 if ((sw
& EXC
) != IE
) {
164 printf("FAIL: fcom nan\n");
167 __asm__
volatile ("fnclex");
168 __asm__
volatile ("fucom" : : "t" (ld_nan
), "u" (ld_zero
));
169 __asm__
volatile ("fnstsw" : "=a" (sw
));
170 if ((sw
& EXC
) != 0) {
171 printf("FAIL: fucom nan\n");
174 __asm__
volatile ("fnclex");
175 __asm__
volatile ("fucom" : : "t" (ld_snan
), "u" (ld_zero
));
176 __asm__
volatile ("fnstsw" : "=a" (sw
));
177 if ((sw
& EXC
) != IE
) {
178 printf("FAIL: fucom snan\n");
181 __asm__
volatile ("fnclex");
182 __asm__
volatile ("fucom" : : "t" (1.0L), "u" (ld_invalid_1
.ld
));
183 __asm__
volatile ("fnstsw" : "=a" (sw
));
184 if ((sw
& EXC
) != IE
) {
185 printf("FAIL: fucom invalid\n");
189 __asm__
volatile ("fnclex");
190 ld_res
= ld_max
+ ld_max
;
191 __asm__
volatile ("fnstsw" : "=a" (sw
));
192 if ((sw
& EXC
) != (OE
| PE
)) {
193 printf("FAIL: add overflow\n");
196 __asm__
volatile ("fnclex");
197 ld_res
= ld_max
+ ld_min
;
198 __asm__
volatile ("fnstsw" : "=a" (sw
));
199 if ((sw
& EXC
) != PE
) {
200 printf("FAIL: add inexact\n");
203 __asm__
volatile ("fnclex");
204 ld_res
= ld_inf
+ ld_ninf
;
205 __asm__
volatile ("fnstsw" : "=a" (sw
));
206 if ((sw
& EXC
) != IE
) {
207 printf("FAIL: add inf -inf\n");
210 __asm__
volatile ("fnclex");
211 ld_res
= ld_snan
+ ld_third
;
212 __asm__
volatile ("fnstsw" : "=a" (sw
));
213 if ((sw
& EXC
) != IE
) {
214 printf("FAIL: add snan\n");
217 __asm__
volatile ("fnclex");
218 ld_res
= ld_third
+ ld_invalid_1
.ld
;
219 __asm__
volatile ("fnstsw" : "=a" (sw
));
220 if ((sw
& EXC
) != IE
) {
221 printf("FAIL: add invalid\n");
225 __asm__
volatile ("fnclex");
226 ld_res
= ld_max
- ld_nmax
;
227 __asm__
volatile ("fnstsw" : "=a" (sw
));
228 if ((sw
& EXC
) != (OE
| PE
)) {
229 printf("FAIL: sub overflow\n");
232 __asm__
volatile ("fnclex");
233 ld_res
= ld_max
- ld_min
;
234 __asm__
volatile ("fnstsw" : "=a" (sw
));
235 if ((sw
& EXC
) != PE
) {
236 printf("FAIL: sub inexact\n");
239 __asm__
volatile ("fnclex");
240 ld_res
= ld_inf
- ld_inf
;
241 __asm__
volatile ("fnstsw" : "=a" (sw
));
242 if ((sw
& EXC
) != IE
) {
243 printf("FAIL: sub inf inf\n");
246 __asm__
volatile ("fnclex");
247 ld_res
= ld_snan
- ld_third
;
248 __asm__
volatile ("fnstsw" : "=a" (sw
));
249 if ((sw
& EXC
) != IE
) {
250 printf("FAIL: sub snan\n");
253 __asm__
volatile ("fnclex");
254 ld_res
= ld_third
- ld_invalid_1
.ld
;
255 __asm__
volatile ("fnstsw" : "=a" (sw
));
256 if ((sw
& EXC
) != IE
) {
257 printf("FAIL: sub invalid\n");
261 __asm__
volatile ("fnclex");
262 ld_res
= ld_max
* ld_max
;
263 __asm__
volatile ("fnstsw" : "=a" (sw
));
264 if ((sw
& EXC
) != (OE
| PE
)) {
265 printf("FAIL: mul overflow\n");
268 __asm__
volatile ("fnclex");
269 ld_res
= ld_third
* ld_third
;
270 __asm__
volatile ("fnstsw" : "=a" (sw
));
271 if ((sw
& EXC
) != PE
) {
272 printf("FAIL: mul inexact\n");
275 __asm__
volatile ("fnclex");
276 ld_res
= ld_min
* ld_min
;
277 __asm__
volatile ("fnstsw" : "=a" (sw
));
278 if ((sw
& EXC
) != (UE
| PE
)) {
279 printf("FAIL: mul underflow\n");
282 __asm__
volatile ("fnclex");
283 ld_res
= ld_inf
* ld_zero
;
284 __asm__
volatile ("fnstsw" : "=a" (sw
));
285 if ((sw
& EXC
) != IE
) {
286 printf("FAIL: mul inf 0\n");
289 __asm__
volatile ("fnclex");
290 ld_res
= ld_snan
* ld_third
;
291 __asm__
volatile ("fnstsw" : "=a" (sw
));
292 if ((sw
& EXC
) != IE
) {
293 printf("FAIL: mul snan\n");
296 __asm__
volatile ("fnclex");
297 ld_res
= ld_third
* ld_invalid_1
.ld
;
298 __asm__
volatile ("fnstsw" : "=a" (sw
));
299 if ((sw
& EXC
) != IE
) {
300 printf("FAIL: mul invalid\n");
304 __asm__
volatile ("fnclex");
305 ld_res
= ld_max
/ ld_min
;
306 __asm__
volatile ("fnstsw" : "=a" (sw
));
307 if ((sw
& EXC
) != (OE
| PE
)) {
308 printf("FAIL: div overflow\n");
311 __asm__
volatile ("fnclex");
312 ld_res
= ld_one
/ ld_third
;
313 __asm__
volatile ("fnstsw" : "=a" (sw
));
314 if ((sw
& EXC
) != PE
) {
315 printf("FAIL: div inexact\n");
318 __asm__
volatile ("fnclex");
319 ld_res
= ld_min
/ ld_max
;
320 __asm__
volatile ("fnstsw" : "=a" (sw
));
321 if ((sw
& EXC
) != (UE
| PE
)) {
322 printf("FAIL: div underflow\n");
325 __asm__
volatile ("fnclex");
326 ld_res
= ld_one
/ ld_zero
;
327 __asm__
volatile ("fnstsw" : "=a" (sw
));
328 if ((sw
& EXC
) != ZE
) {
329 printf("FAIL: div 1 0\n");
332 __asm__
volatile ("fnclex");
333 ld_res
= ld_inf
/ ld_zero
;
334 __asm__
volatile ("fnstsw" : "=a" (sw
));
335 if ((sw
& EXC
) != 0) {
336 printf("FAIL: div inf 0\n");
339 __asm__
volatile ("fnclex");
340 ld_res
= ld_nan
/ ld_zero
;
341 __asm__
volatile ("fnstsw" : "=a" (sw
));
342 if ((sw
& EXC
) != 0) {
343 printf("FAIL: div nan 0\n");
346 __asm__
volatile ("fnclex");
347 ld_res
= ld_zero
/ ld_zero
;
348 __asm__
volatile ("fnstsw" : "=a" (sw
));
349 if ((sw
& EXC
) != IE
) {
350 printf("FAIL: div 0 0\n");
353 __asm__
volatile ("fnclex");
354 ld_res
= ld_inf
/ ld_inf
;
355 __asm__
volatile ("fnstsw" : "=a" (sw
));
356 if ((sw
& EXC
) != IE
) {
357 printf("FAIL: div inf inf\n");
360 __asm__
volatile ("fnclex");
361 ld_res
= ld_snan
/ ld_third
;
362 __asm__
volatile ("fnstsw" : "=a" (sw
));
363 if ((sw
& EXC
) != IE
) {
364 printf("FAIL: div snan\n");
367 __asm__
volatile ("fnclex");
368 ld_res
= ld_third
/ ld_invalid_1
.ld
;
369 __asm__
volatile ("fnstsw" : "=a" (sw
));
370 if ((sw
& EXC
) != IE
) {
371 printf("FAIL: div invalid\n");
375 __asm__
volatile ("fnclex");
376 __asm__
volatile ("fsqrt" : "=t" (ld_res
) : "0" (ld_max
));
377 __asm__
volatile ("fnstsw" : "=a" (sw
));
378 if ((sw
& EXC
) != PE
) {
379 printf("FAIL: fsqrt inexact\n");
382 __asm__
volatile ("fnclex");
383 __asm__
volatile ("fsqrt" : "=t" (ld_res
) : "0" (ld_nmax
));
384 __asm__
volatile ("fnstsw" : "=a" (sw
));
385 if ((sw
& EXC
) != IE
) {
386 printf("FAIL: fsqrt -max\n");
389 __asm__
volatile ("fnclex");
390 __asm__
volatile ("fsqrt" : "=t" (ld_res
) : "0" (ld_ninf
));
391 __asm__
volatile ("fnstsw" : "=a" (sw
));
392 if ((sw
& EXC
) != IE
) {
393 printf("FAIL: fsqrt -inf\n");
396 __asm__
volatile ("fnclex");
397 __asm__
volatile ("fsqrt" : "=t" (ld_res
) : "0" (ld_snan
));
398 __asm__
volatile ("fnstsw" : "=a" (sw
));
399 if ((sw
& EXC
) != IE
) {
400 printf("FAIL: fsqrt snan\n");
403 __asm__
volatile ("fnclex");
404 __asm__
volatile ("fsqrt" : "=t" (ld_res
) : "0" (ld_invalid_1
.ld
));
405 __asm__
volatile ("fnstsw" : "=a" (sw
));
406 if ((sw
& EXC
) != IE
) {
407 printf("FAIL: fsqrt invalid\n");
410 __asm__
volatile ("fnclex");
411 __asm__
volatile ("fsqrt" : "=t" (ld_res
) : "0" (ld_nzero
));
412 __asm__
volatile ("fnstsw" : "=a" (sw
));
413 if ((sw
& EXC
) != 0) {
414 printf("FAIL: fsqrt -0\n");
417 __asm__
volatile ("fnclex");
418 __asm__
volatile ("fsqrt" : "=t" (ld_res
) : "0" (-__builtin_nanl("")));
419 __asm__
volatile ("fnstsw" : "=a" (sw
));
420 if ((sw
& EXC
) != 0) {
421 printf("FAIL: fsqrt -nan\n");
425 __asm__
volatile ("fnclex");
426 __asm__
volatile ("fistp %0" : "=m" (res_16
) : "t" (1.5L) : "st");
427 __asm__
volatile ("fnstsw" : "=a" (sw
));
428 if ((sw
& EXC
) != PE
) {
429 printf("FAIL: fistp inexact\n");
432 __asm__
volatile ("fnclex");
433 __asm__
volatile ("fistp %0" : "=m" (res_16
) : "t" (32767.5L) : "st");
434 __asm__
volatile ("fnstsw" : "=a" (sw
));
435 if ((sw
& EXC
) != IE
) {
436 printf("FAIL: fistp 32767.5\n");
439 __asm__
volatile ("fnclex");
440 __asm__
volatile ("fistp %0" : "=m" (res_16
) : "t" (-32768.51L) : "st");
441 __asm__
volatile ("fnstsw" : "=a" (sw
));
442 if ((sw
& EXC
) != IE
) {
443 printf("FAIL: fistp -32768.51\n");
446 __asm__
volatile ("fnclex");
447 __asm__
volatile ("fistp %0" : "=m" (res_16
) : "t" (ld_nan
) : "st");
448 __asm__
volatile ("fnstsw" : "=a" (sw
));
449 if ((sw
& EXC
) != IE
) {
450 printf("FAIL: fistp nan\n");
453 __asm__
volatile ("fnclex");
454 __asm__
volatile ("fistp %0" : "=m" (res_16
) : "t" (ld_invalid_1
.ld
) :
456 __asm__
volatile ("fnstsw" : "=a" (sw
));
457 if ((sw
& EXC
) != IE
) {
458 printf("FAIL: fistp invalid\n");
462 __asm__
volatile ("fnclex");
463 __asm__
volatile ("fistpl %0" : "=m" (res_32
) : "t" (1.5L) : "st");
464 __asm__
volatile ("fnstsw" : "=a" (sw
));
465 if ((sw
& EXC
) != PE
) {
466 printf("FAIL: fistpl inexact\n");
469 __asm__
volatile ("fnclex");
470 __asm__
volatile ("fistpl %0" : "=m" (res_32
) : "t" (2147483647.5L) :
472 __asm__
volatile ("fnstsw" : "=a" (sw
));
473 if ((sw
& EXC
) != IE
) {
474 printf("FAIL: fistpl 2147483647.5\n");
477 __asm__
volatile ("fnclex");
478 __asm__
volatile ("fistpl %0" : "=m" (res_32
) : "t" (-2147483648.51L) :
480 __asm__
volatile ("fnstsw" : "=a" (sw
));
481 if ((sw
& EXC
) != IE
) {
482 printf("FAIL: fistpl -2147483648.51\n");
485 __asm__
volatile ("fnclex");
486 __asm__
volatile ("fistpl %0" : "=m" (res_32
) : "t" (ld_nan
) : "st");
487 __asm__
volatile ("fnstsw" : "=a" (sw
));
488 if ((sw
& EXC
) != IE
) {
489 printf("FAIL: fistpl nan\n");
492 __asm__
volatile ("fnclex");
493 __asm__
volatile ("fistpl %0" : "=m" (res_32
) : "t" (ld_invalid_1
.ld
) :
495 __asm__
volatile ("fnstsw" : "=a" (sw
));
496 if ((sw
& EXC
) != IE
) {
497 printf("FAIL: fistpl invalid\n");
501 __asm__
volatile ("fnclex");
502 __asm__
volatile ("fistpll %0" : "=m" (res_64
) : "t" (1.5L) : "st");
503 __asm__
volatile ("fnstsw" : "=a" (sw
));
504 if ((sw
& EXC
) != PE
) {
505 printf("FAIL: fistpll inexact\n");
508 __asm__
volatile ("fnclex");
509 __asm__
volatile ("fistpll %0" : "=m" (res_64
) : "t" (0x1p
63) :
511 __asm__
volatile ("fnstsw" : "=a" (sw
));
512 if ((sw
& EXC
) != IE
) {
513 printf("FAIL: fistpll 0x1p63\n");
516 __asm__
volatile ("fnclex");
517 __asm__
volatile ("fistpll %0" : "=m" (res_64
) : "t" (-0x1.1p63L
) :
519 __asm__
volatile ("fnstsw" : "=a" (sw
));
520 if ((sw
& EXC
) != IE
) {
521 printf("FAIL: fistpll -0x1.1p63\n");
524 __asm__
volatile ("fnclex");
525 __asm__
volatile ("fistpll %0" : "=m" (res_64
) : "t" (ld_nan
) : "st");
526 __asm__
volatile ("fnstsw" : "=a" (sw
));
527 if ((sw
& EXC
) != IE
) {
528 printf("FAIL: fistpll nan\n");
531 __asm__
volatile ("fnclex");
532 __asm__
volatile ("fistpll %0" : "=m" (res_64
) : "t" (ld_invalid_1
.ld
) :
534 __asm__
volatile ("fnstsw" : "=a" (sw
));
535 if ((sw
& EXC
) != IE
) {
536 printf("FAIL: fistpll invalid\n");
540 __asm__
volatile ("fnclex");
541 __asm__
volatile ("fisttp %0" : "=m" (res_16
) : "t" (1.5L) : "st");
542 __asm__
volatile ("fnstsw" : "=a" (sw
));
543 if ((sw
& EXC
) != PE
) {
544 printf("FAIL: fisttp inexact\n");
547 __asm__
volatile ("fnclex");
548 __asm__
volatile ("fisttp %0" : "=m" (res_16
) : "t" (32768.0L) : "st");
549 __asm__
volatile ("fnstsw" : "=a" (sw
));
550 if ((sw
& EXC
) != IE
) {
551 printf("FAIL: fisttp 32768\n");
554 __asm__
volatile ("fnclex");
555 __asm__
volatile ("fisttp %0" : "=m" (res_16
) : "t" (32768.5L) : "st");
556 __asm__
volatile ("fnstsw" : "=a" (sw
));
557 if ((sw
& EXC
) != IE
) {
558 printf("FAIL: fisttp 32768.5\n");
561 __asm__
volatile ("fnclex");
562 __asm__
volatile ("fisttp %0" : "=m" (res_16
) : "t" (-32769.0L) : "st");
563 __asm__
volatile ("fnstsw" : "=a" (sw
));
564 if ((sw
& EXC
) != IE
) {
565 printf("FAIL: fisttp -32769\n");
568 __asm__
volatile ("fnclex");
569 __asm__
volatile ("fisttp %0" : "=m" (res_16
) : "t" (-32769.5L) : "st");
570 __asm__
volatile ("fnstsw" : "=a" (sw
));
571 if ((sw
& EXC
) != IE
) {
572 printf("FAIL: fisttp -32769.5\n");
575 __asm__
volatile ("fnclex");
576 __asm__
volatile ("fisttp %0" : "=m" (res_16
) : "t" (ld_nan
) : "st");
577 __asm__
volatile ("fnstsw" : "=a" (sw
));
578 if ((sw
& EXC
) != IE
) {
579 printf("FAIL: fisttp nan\n");
582 __asm__
volatile ("fnclex");
583 __asm__
volatile ("fisttp %0" : "=m" (res_16
) : "t" (ld_invalid_1
.ld
) :
585 __asm__
volatile ("fnstsw" : "=a" (sw
));
586 if ((sw
& EXC
) != IE
) {
587 printf("FAIL: fisttp invalid\n");
591 __asm__
volatile ("fnclex");
592 __asm__
volatile ("fisttpl %0" : "=m" (res_32
) : "t" (1.5L) : "st");
593 __asm__
volatile ("fnstsw" : "=a" (sw
));
594 if ((sw
& EXC
) != PE
) {
595 printf("FAIL: fisttpl inexact\n");
598 __asm__
volatile ("fnclex");
599 __asm__
volatile ("fisttpl %0" : "=m" (res_32
) : "t" (2147483648.0L) :
601 __asm__
volatile ("fnstsw" : "=a" (sw
));
602 if ((sw
& EXC
) != IE
) {
603 printf("FAIL: fisttpl 2147483648\n");
606 __asm__
volatile ("fnclex");
607 __asm__
volatile ("fisttpl %0" : "=m" (res_32
) : "t" (-2147483649.0L) :
609 __asm__
volatile ("fnstsw" : "=a" (sw
));
610 if ((sw
& EXC
) != IE
) {
611 printf("FAIL: fisttpl -2147483649\n");
614 __asm__
volatile ("fnclex");
615 __asm__
volatile ("fisttpl %0" : "=m" (res_32
) : "t" (ld_nan
) : "st");
616 __asm__
volatile ("fnstsw" : "=a" (sw
));
617 if ((sw
& EXC
) != IE
) {
618 printf("FAIL: fisttpl nan\n");
621 __asm__
volatile ("fnclex");
622 __asm__
volatile ("fisttpl %0" : "=m" (res_32
) : "t" (ld_invalid_1
.ld
) :
624 __asm__
volatile ("fnstsw" : "=a" (sw
));
625 if ((sw
& EXC
) != IE
) {
626 printf("FAIL: fisttpl invalid\n");
630 __asm__
volatile ("fnclex");
631 __asm__
volatile ("fisttpll %0" : "=m" (res_64
) : "t" (1.5L) : "st");
632 __asm__
volatile ("fnstsw" : "=a" (sw
));
633 if ((sw
& EXC
) != PE
) {
634 printf("FAIL: fisttpll inexact\n");
637 __asm__
volatile ("fnclex");
638 __asm__
volatile ("fisttpll %0" : "=m" (res_64
) : "t" (0x1p
63) :
640 __asm__
volatile ("fnstsw" : "=a" (sw
));
641 if ((sw
& EXC
) != IE
) {
642 printf("FAIL: fisttpll 0x1p63\n");
645 __asm__
volatile ("fnclex");
646 __asm__
volatile ("fisttpll %0" : "=m" (res_64
) : "t" (-0x1.1p63L
) :
648 __asm__
volatile ("fnstsw" : "=a" (sw
));
649 if ((sw
& EXC
) != IE
) {
650 printf("FAIL: fisttpll -0x1.1p63\n");
653 __asm__
volatile ("fnclex");
654 __asm__
volatile ("fisttpll %0" : "=m" (res_64
) : "t" (ld_nan
) : "st");
655 __asm__
volatile ("fnstsw" : "=a" (sw
));
656 if ((sw
& EXC
) != IE
) {
657 printf("FAIL: fisttpll nan\n");
660 __asm__
volatile ("fnclex");
661 __asm__
volatile ("fisttpll %0" : "=m" (res_64
) : "t" (ld_invalid_1
.ld
) :
663 __asm__
volatile ("fnstsw" : "=a" (sw
));
664 if ((sw
& EXC
) != IE
) {
665 printf("FAIL: fisttpll invalid\n");
669 __asm__
volatile ("fnclex");
670 __asm__
volatile ("fxtract" : "=t" (ld_res
), "=u" (ld_res2
) :
672 __asm__
volatile ("fnstsw" : "=a" (sw
));
673 if ((sw
& EXC
) != ZE
) {
674 printf("FAIL: fxtract 0\n");
677 __asm__
volatile ("fnclex");
678 __asm__
volatile ("fxtract" : "=t" (ld_res
), "=u" (ld_res2
) :
680 __asm__
volatile ("fnstsw" : "=a" (sw
));
681 if ((sw
& EXC
) != ZE
) {
682 printf("FAIL: fxtract -0\n");
685 __asm__
volatile ("fnclex");
686 __asm__
volatile ("fxtract" : "=t" (ld_res
), "=u" (ld_res2
) :
688 __asm__
volatile ("fnstsw" : "=a" (sw
));
689 if ((sw
& EXC
) != 0) {
690 printf("FAIL: fxtract inf\n");
693 __asm__
volatile ("fnclex");
694 __asm__
volatile ("fxtract" : "=t" (ld_res
), "=u" (ld_res2
) :
696 __asm__
volatile ("fnstsw" : "=a" (sw
));
697 if ((sw
& EXC
) != 0) {
698 printf("FAIL: fxtract nan\n");
701 __asm__
volatile ("fnclex");
702 __asm__
volatile ("fxtract" : "=t" (ld_res
), "=u" (ld_res2
) :
704 __asm__
volatile ("fnstsw" : "=a" (sw
));
705 if ((sw
& EXC
) != IE
) {
706 printf("FAIL: fxtract snan\n");
709 __asm__
volatile ("fnclex");
710 __asm__
volatile ("fxtract" : "=t" (ld_res
), "=u" (ld_res2
) :
711 "0" (ld_invalid_1
.ld
));
712 __asm__
volatile ("fnstsw" : "=a" (sw
));
713 if ((sw
& EXC
) != IE
) {
714 printf("FAIL: fxtract invalid\n");
718 __asm__
volatile ("fnclex");
719 __asm__
volatile ("fscale" : "=t" (ld_res
) : "0" (ld_min
), "u" (ld_max
));
720 __asm__
volatile ("fnstsw" : "=a" (sw
));
721 if ((sw
& EXC
) != (OE
| PE
)) {
722 printf("FAIL: fscale overflow\n");
725 __asm__
volatile ("fnclex");
726 __asm__
volatile ("fscale" : "=t" (ld_res
) : "0" (ld_max
), "u" (ld_nmax
));
727 __asm__
volatile ("fnstsw" : "=a" (sw
));
728 if ((sw
& EXC
) != (UE
| PE
)) {
729 printf("FAIL: fscale underflow\n");
732 __asm__
volatile ("fnclex");
733 __asm__
volatile ("fscale" : "=t" (ld_res
) : "0" (ld_zero
), "u" (ld_inf
));
734 __asm__
volatile ("fnstsw" : "=a" (sw
));
735 if ((sw
& EXC
) != IE
) {
736 printf("FAIL: fscale 0 inf\n");
739 __asm__
volatile ("fnclex");
740 __asm__
volatile ("fscale" : "=t" (ld_res
) : "0" (ld_inf
), "u" (ld_ninf
));
741 __asm__
volatile ("fnstsw" : "=a" (sw
));
742 if ((sw
& EXC
) != IE
) {
743 printf("FAIL: fscale inf -inf\n");
746 __asm__
volatile ("fnclex");
747 __asm__
volatile ("fscale" : "=t" (ld_res
) : "0" (ld_one
), "u" (ld_snan
));
748 __asm__
volatile ("fnstsw" : "=a" (sw
));
749 if ((sw
& EXC
) != IE
) {
750 printf("FAIL: fscale 1 snan\n");
753 __asm__
volatile ("fnclex");
754 __asm__
volatile ("fscale" : "=t" (ld_res
) : "0" (ld_snan
), "u" (ld_nan
));
755 __asm__
volatile ("fnstsw" : "=a" (sw
));
756 if ((sw
& EXC
) != IE
) {
757 printf("FAIL: fscale snan nan\n");
760 __asm__
volatile ("fnclex");
761 __asm__
volatile ("fscale" : "=t" (ld_res
) :
762 "0" (ld_invalid_1
.ld
), "u" (ld_one
));
763 __asm__
volatile ("fnstsw" : "=a" (sw
));
764 if ((sw
& EXC
) != IE
) {
765 printf("FAIL: fscale invalid 1\n");
768 __asm__
volatile ("fnclex");
769 __asm__
volatile ("fscale" : "=t" (ld_res
) :
770 "0" (ld_invalid_1
.ld
), "u" (ld_nan
));
771 __asm__
volatile ("fnstsw" : "=a" (sw
));
772 if ((sw
& EXC
) != IE
) {
773 printf("FAIL: fscale invalid nan\n");
777 __asm__
volatile ("fnclex");
778 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (1.5L) :
780 __asm__
volatile ("fnstsw" : "=a" (sw
));
781 if ((sw
& EXC
) != PE
) {
782 printf("FAIL: fbstp 1.5\n");
785 __asm__
volatile ("fnclex");
786 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (999999999999999999.5L) :
788 __asm__
volatile ("fnstsw" : "=a" (sw
));
789 if ((sw
& EXC
) != IE
) {
790 printf("FAIL: fbstp 999999999999999999.5\n");
793 __asm__
volatile ("fnclex");
794 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (-1000000000000000000.0L) :
796 __asm__
volatile ("fnstsw" : "=a" (sw
));
797 if ((sw
& EXC
) != IE
) {
798 printf("FAIL: fbstp -1000000000000000000\n");
801 __asm__
volatile ("fnclex");
802 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (ld_inf
) : "st");
803 __asm__
volatile ("fnstsw" : "=a" (sw
));
804 if ((sw
& EXC
) != IE
) {
805 printf("FAIL: fbstp inf\n");
808 __asm__
volatile ("fnclex");
809 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (ld_nan
) : "st");
810 __asm__
volatile ("fnstsw" : "=a" (sw
));
811 if ((sw
& EXC
) != IE
) {
812 printf("FAIL: fbstp nan\n");
815 __asm__
volatile ("fnclex");
816 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (ld_snan
) : "st");
817 __asm__
volatile ("fnstsw" : "=a" (sw
));
818 if ((sw
& EXC
) != IE
) {
819 printf("FAIL: fbstp snan\n");
822 __asm__
volatile ("fnclex");
823 __asm__
volatile ("fbstp %0" : "=m" (out
) : "t" (ld_invalid_1
.ld
) : "st");
824 __asm__
volatile ("fnstsw" : "=a" (sw
));
825 if ((sw
& EXC
) != IE
) {
826 printf("FAIL: fbstp invalid\n");