1 // REQUIRES: target-is-powerpc64le
2 // RUN: %clang_builtins %s %librt -o %t && %run %t
7 #include "fixunstfti_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 __uint128_t
__fixunstfti(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->
34 * uint128 conversion, and check for errors between results. */
35 computedResult
= __fixunstfti(ldInput
.ld
);
37 if (computedResult
!= expectedResult
) {
38 printf("Error for __fixunstfti at input %La = ( %a , %a ):\n", ldInput
.ld
,
39 ldInput
.d
[0], ldInput
.d
[1]);
40 printf("\tExpected __uint128_t: 0x%016llx 0x%016llx\n",
41 (unsigned long long)(expectedResult
>> 64),
42 (unsigned long long)expectedResult
);
43 printf("\tComputed __uint128_t: 0x%016llx 0x%016llx\n\n",
44 (unsigned long long)(computedResult
>> 64),
45 (unsigned long long)computedResult
);