1 // REQUIRES: target-is-powerpc64le
2 // RUN: %clang_builtins %s %librt -o %t && %run %t
7 #include "fixtfti_test.h"
9 // The long double representation, with the high and low portions of
10 // the long double, and the corresponding bit patterns of each double.
13 double d
[2]; // [0] is the high double, [1] is the low double.
14 unsigned long long ull
[2]; // High and low doubles as 64-bit integers.
17 __int128_t
__fixtfti(long double);
19 int main(int argc
, char *argv
[]) {
20 // Necessary long double and (unsigned) 128 bit integer
21 // declarations used to compare the computed and expected results
22 // from converting the IBM double-double to int128.
24 __uint128_t expectedResult
, computedResult
;
26 for (int i
= 0; i
< numTests
; ++i
) {
27 // Set the expected 128 bit integer and the high and low
28 // values of the long double input.
29 ldInput
.d
[0] = testList
[i
].hiInput
;
30 ldInput
.d
[1] = testList
[i
].loInput
;
31 expectedResult
= testList
[i
].result128
;
33 // Get the computed 128 bit integer from the long double to
34 // int128 conversion. Here we cast to unsigned int128 to
35 // get the bit pattern of the result.
36 computedResult
= (__uint128_t
) __fixtfti(ldInput
.ld
);
38 if (computedResult
!= expectedResult
) {
39 printf("Error for __fixtfti at input %La = ( %a , %a ):\n", ldInput
.ld
,
40 ldInput
.d
[0], ldInput
.d
[1]);
41 printf("\tExpected __int128_t: 0x%016llx 0x%016llx\n",
42 (unsigned long long)(expectedResult
>> 64),
43 (unsigned long long)expectedResult
);
44 printf("\tComputed __int128_t: 0x%016llx 0x%016llx\n\n",
45 (unsigned long long)(computedResult
>> 64),
46 (unsigned long long)computedResult
);