1*7c3d14c8STreehugger Robot //===--------------- subtf3_test.c - Test __subtf3 ------------------------===//
2*7c3d14c8STreehugger Robot //
3*7c3d14c8STreehugger Robot // The LLVM Compiler Infrastructure
4*7c3d14c8STreehugger Robot //
5*7c3d14c8STreehugger Robot // This file is dual licensed under the MIT and the University of Illinois Open
6*7c3d14c8STreehugger Robot // Source Licenses. See LICENSE.TXT for details.
7*7c3d14c8STreehugger Robot //
8*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
9*7c3d14c8STreehugger Robot //
10*7c3d14c8STreehugger Robot // This file tests __subtf3 for the compiler_rt library.
11*7c3d14c8STreehugger Robot //
12*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
13*7c3d14c8STreehugger Robot
14*7c3d14c8STreehugger Robot #include <stdio.h>
15*7c3d14c8STreehugger Robot
16*7c3d14c8STreehugger Robot #if __LDBL_MANT_DIG__ == 113
17*7c3d14c8STreehugger Robot
18*7c3d14c8STreehugger Robot #include "fp_test.h"
19*7c3d14c8STreehugger Robot
20*7c3d14c8STreehugger Robot // Returns: a - b
21*7c3d14c8STreehugger Robot COMPILER_RT_ABI long double __subtf3(long double a, long double b);
22*7c3d14c8STreehugger Robot
test__subtf3(long double a,long double b,uint64_t expectedHi,uint64_t expectedLo)23*7c3d14c8STreehugger Robot int test__subtf3(long double a, long double b,
24*7c3d14c8STreehugger Robot uint64_t expectedHi, uint64_t expectedLo)
25*7c3d14c8STreehugger Robot {
26*7c3d14c8STreehugger Robot long double x = __subtf3(a, b);
27*7c3d14c8STreehugger Robot int ret = compareResultLD(x, expectedHi, expectedLo);
28*7c3d14c8STreehugger Robot
29*7c3d14c8STreehugger Robot if (ret){
30*7c3d14c8STreehugger Robot printf("error in test__subtf3(%.20Lf, %.20Lf) = %.20Lf, "
31*7c3d14c8STreehugger Robot "expected %.20Lf\n", a, b, x,
32*7c3d14c8STreehugger Robot fromRep128(expectedHi, expectedLo));
33*7c3d14c8STreehugger Robot }
34*7c3d14c8STreehugger Robot return ret;
35*7c3d14c8STreehugger Robot }
36*7c3d14c8STreehugger Robot
37*7c3d14c8STreehugger Robot char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
38*7c3d14c8STreehugger Robot
39*7c3d14c8STreehugger Robot #endif
40*7c3d14c8STreehugger Robot
main()41*7c3d14c8STreehugger Robot int main()
42*7c3d14c8STreehugger Robot {
43*7c3d14c8STreehugger Robot #if __LDBL_MANT_DIG__ == 113
44*7c3d14c8STreehugger Robot // qNaN - any = qNaN
45*7c3d14c8STreehugger Robot if (test__subtf3(makeQNaN128(),
46*7c3d14c8STreehugger Robot 0x1.23456789abcdefp+5L,
47*7c3d14c8STreehugger Robot UINT64_C(0x7fff800000000000),
48*7c3d14c8STreehugger Robot UINT64_C(0x0)))
49*7c3d14c8STreehugger Robot return 1;
50*7c3d14c8STreehugger Robot // NaN - any = NaN
51*7c3d14c8STreehugger Robot if (test__subtf3(makeNaN128(UINT64_C(0x800030000000)),
52*7c3d14c8STreehugger Robot 0x1.23456789abcdefp+5L,
53*7c3d14c8STreehugger Robot UINT64_C(0x7fff800000000000),
54*7c3d14c8STreehugger Robot UINT64_C(0x0)))
55*7c3d14c8STreehugger Robot return 1;
56*7c3d14c8STreehugger Robot // inf - any = inf
57*7c3d14c8STreehugger Robot if (test__subtf3(makeInf128(),
58*7c3d14c8STreehugger Robot 0x1.23456789abcdefp+5L,
59*7c3d14c8STreehugger Robot UINT64_C(0x7fff000000000000),
60*7c3d14c8STreehugger Robot UINT64_C(0x0)))
61*7c3d14c8STreehugger Robot return 1;
62*7c3d14c8STreehugger Robot // any - any
63*7c3d14c8STreehugger Robot if (test__subtf3(0x1.234567829a3bcdef5678ade36734p+5L,
64*7c3d14c8STreehugger Robot 0x1.ee9d7c52354a6936ab8d7654321fp-1L,
65*7c3d14c8STreehugger Robot UINT64_C(0x40041b8af1915166),
66*7c3d14c8STreehugger Robot UINT64_C(0xa44a7bca780a166c)))
67*7c3d14c8STreehugger Robot return 1;
68*7c3d14c8STreehugger Robot
69*7c3d14c8STreehugger Robot #else
70*7c3d14c8STreehugger Robot printf("skipped\n");
71*7c3d14c8STreehugger Robot
72*7c3d14c8STreehugger Robot #endif
73*7c3d14c8STreehugger Robot return 0;
74*7c3d14c8STreehugger Robot }
75