1 // REQUIRES: target-is-powerpc64le
2 // RUN: %clang_builtins %s %librt -o %t && %run %t
5 * Test case execution for: long double __floattitf (__int128_t)
6 * Conversion from 128 bit integer to long double (IBM double-double).
12 #include "floattitf_test.h"
14 /* The long double representation, with the high and low portions of
15 * the long double, and the corresponding bit patterns of each double. */
18 double d
[2]; /* [0] is the high double, [1] is the low double. */
19 unsigned long long ull
[2]; /* High and low doubles as 64-bit integers. */
22 long double __floattitf(__int128_t
);
24 int main(int argc
, char *argv
[]) {
25 /* Necessary long double and 128 bit integer declarations used to
26 * compare computed and expected high and low portions of the
27 * IBM double-double. */
28 ldUnion expectedLongDouble
;
29 ldUnion computedLongDouble
;
32 for (int i
= 0; i
< numTests
; ++i
) {
33 /* Set the expected high and low values of the long double,
34 * and the 128 bit integer input to be converted. */
35 expectedLongDouble
.d
[0] = tests
[i
].hi
;
36 expectedLongDouble
.d
[1] = tests
[i
].lo
;
37 result128
= tests
[i
].input128
;
39 /* Get the computed long double from the int128->long double conversion
40 * and check for errors between high and low portions. */
41 computedLongDouble
.ld
= __floattitf(result128
);
43 if ((computedLongDouble
.d
[0] != expectedLongDouble
.d
[0]) ||
44 (computedLongDouble
.d
[1] != expectedLongDouble
.d
[1])) {
46 printf("Error on __floattitf( 0x%016llx 0x%016llx ):\n",
47 (long long)(tests
[i
].input128
>> 64),
48 (long long)tests
[i
].input128
);
49 printf("\tExpected value - %La = ( %a, %a )\n", expectedLongDouble
.ld
,
50 expectedLongDouble
.d
[0], expectedLongDouble
.d
[1]);
51 printf("\tComputed value - %La = ( %a, %a )\n\n", computedLongDouble
.ld
,
52 computedLongDouble
.d
[0], computedLongDouble
.d
[1]);