1 /* Test fxtract 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_invalid_1
= { .s
= { 1, 1234 } };
13 volatile union u ld_invalid_2
= { .s
= { 0, 1234 } };
14 volatile union u ld_invalid_3
= { .s
= { 0, 0x7fff } };
15 volatile union u ld_invalid_4
= { .s
= { (UINT64_C(1) << 63) - 1, 0x7fff } };
17 volatile long double ld_sig
, ld_exp
;
19 int isnan_ld(long double x
)
21 union u tmp
= { .ld
= x
};
22 return ((tmp
.s
.sign_exp
& 0x7fff) == 0x7fff &&
23 (tmp
.s
.sig
>> 63) != 0 &&
24 (tmp
.s
.sig
<< 1) != 0);
27 int issignaling_ld(long double x
)
29 union u tmp
= { .ld
= x
};
30 return isnan_ld(x
) && (tmp
.s
.sig
& UINT64_C(0x4000000000000000)) == 0;
36 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) : "0" (2.5L));
37 if (ld_sig
!= 1.25L || ld_exp
!= 1.0L) {
38 printf("FAIL: fxtract 2.5\n");
41 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) : "0" (0.0L));
42 if (ld_sig
!= 0.0L || __builtin_copysignl(1.0L, ld_sig
) != 1.0L ||
43 ld_exp
!= -__builtin_infl()) {
44 printf("FAIL: fxtract 0.0\n");
47 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) : "0" (-0.0L));
48 if (ld_sig
!= -0.0L || __builtin_copysignl(1.0L, ld_sig
) != -1.0L ||
49 ld_exp
!= -__builtin_infl()) {
50 printf("FAIL: fxtract -0.0\n");
53 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) :
54 "0" (__builtin_infl()));
55 if (ld_sig
!= __builtin_infl() || ld_exp
!= __builtin_infl()) {
56 printf("FAIL: fxtract inf\n");
59 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) :
60 "0" (-__builtin_infl()));
61 if (ld_sig
!= -__builtin_infl() || ld_exp
!= __builtin_infl()) {
62 printf("FAIL: fxtract -inf\n");
65 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) :
66 "0" (__builtin_nanl("")));
67 if (!isnan_ld(ld_sig
) || issignaling_ld(ld_sig
) ||
68 !isnan_ld(ld_exp
) || issignaling_ld(ld_exp
)) {
69 printf("FAIL: fxtract qnan\n");
72 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) :
73 "0" (__builtin_nansl("")));
74 if (!isnan_ld(ld_sig
) || issignaling_ld(ld_sig
) ||
75 !isnan_ld(ld_exp
) || issignaling_ld(ld_exp
)) {
76 printf("FAIL: fxtract snan\n");
79 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) :
81 if (ld_sig
!= 1.0L || ld_exp
!= -16445.0L) {
82 printf("FAIL: fxtract subnormal\n");
85 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) :
86 "0" (ld_pseudo_m16382
.ld
));
87 if (ld_sig
!= 1.0L || ld_exp
!= -16382.0L) {
88 printf("FAIL: fxtract pseudo\n");
91 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) :
92 "0" (ld_invalid_1
.ld
));
93 if (!isnan_ld(ld_sig
) || issignaling_ld(ld_sig
) ||
94 !isnan_ld(ld_exp
) || issignaling_ld(ld_exp
)) {
95 printf("FAIL: fxtract invalid 1\n");
98 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) :
99 "0" (ld_invalid_2
.ld
));
100 if (!isnan_ld(ld_sig
) || issignaling_ld(ld_sig
) ||
101 !isnan_ld(ld_exp
) || issignaling_ld(ld_exp
)) {
102 printf("FAIL: fxtract invalid 2\n");
105 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) :
106 "0" (ld_invalid_3
.ld
));
107 if (!isnan_ld(ld_sig
) || issignaling_ld(ld_sig
) ||
108 !isnan_ld(ld_exp
) || issignaling_ld(ld_exp
)) {
109 printf("FAIL: fxtract invalid 3\n");
112 __asm__
volatile ("fxtract" : "=t" (ld_sig
), "=u" (ld_exp
) :
113 "0" (ld_invalid_4
.ld
));
114 if (!isnan_ld(ld_sig
) || issignaling_ld(ld_sig
) ||
115 !isnan_ld(ld_exp
) || issignaling_ld(ld_exp
)) {
116 printf("FAIL: fxtract invalid 4\n");