1*7c3d14c8STreehugger Robot //===--------------- divtf3_test.c - Test __divtf3 ------------------------===//
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 __divtf3 for the compiler_rt library.
11*7c3d14c8STreehugger Robot //
12*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
13*7c3d14c8STreehugger Robot
14*7c3d14c8STreehugger Robot #include "int_lib.h"
15*7c3d14c8STreehugger Robot #include <stdio.h>
16*7c3d14c8STreehugger Robot
17*7c3d14c8STreehugger Robot #if __LDBL_MANT_DIG__ == 113
18*7c3d14c8STreehugger Robot
19*7c3d14c8STreehugger Robot #include "fp_test.h"
20*7c3d14c8STreehugger Robot
21*7c3d14c8STreehugger Robot // Returns: a / b
22*7c3d14c8STreehugger Robot COMPILER_RT_ABI long double __divtf3(long double a, long double b);
23*7c3d14c8STreehugger Robot
test__divtf3(long double a,long double b,uint64_t expectedHi,uint64_t expectedLo)24*7c3d14c8STreehugger Robot int test__divtf3(long double a, long double b,
25*7c3d14c8STreehugger Robot uint64_t expectedHi, uint64_t expectedLo)
26*7c3d14c8STreehugger Robot {
27*7c3d14c8STreehugger Robot long double x = __divtf3(a, b);
28*7c3d14c8STreehugger Robot int ret = compareResultLD(x, expectedHi, expectedLo);
29*7c3d14c8STreehugger Robot
30*7c3d14c8STreehugger Robot if (ret){
31*7c3d14c8STreehugger Robot printf("error in test__divtf3(%.20Lf, %.20Lf) = %.20Lf, "
32*7c3d14c8STreehugger Robot "expected %.20Lf\n", a, b, x,
33*7c3d14c8STreehugger Robot fromRep128(expectedHi, expectedLo));
34*7c3d14c8STreehugger Robot }
35*7c3d14c8STreehugger Robot return ret;
36*7c3d14c8STreehugger Robot }
37*7c3d14c8STreehugger Robot
38*7c3d14c8STreehugger Robot char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
39*7c3d14c8STreehugger Robot
40*7c3d14c8STreehugger Robot #endif
41*7c3d14c8STreehugger Robot
main()42*7c3d14c8STreehugger Robot int main()
43*7c3d14c8STreehugger Robot {
44*7c3d14c8STreehugger Robot #if __LDBL_MANT_DIG__ == 113
45*7c3d14c8STreehugger Robot // qNaN / any = qNaN
46*7c3d14c8STreehugger Robot if (test__divtf3(makeQNaN128(),
47*7c3d14c8STreehugger Robot 0x1.23456789abcdefp+5L,
48*7c3d14c8STreehugger Robot UINT64_C(0x7fff800000000000),
49*7c3d14c8STreehugger Robot UINT64_C(0x0)))
50*7c3d14c8STreehugger Robot return 1;
51*7c3d14c8STreehugger Robot // NaN / any = NaN
52*7c3d14c8STreehugger Robot if (test__divtf3(makeNaN128(UINT64_C(0x800030000000)),
53*7c3d14c8STreehugger Robot 0x1.23456789abcdefp+5L,
54*7c3d14c8STreehugger Robot UINT64_C(0x7fff800000000000),
55*7c3d14c8STreehugger Robot UINT64_C(0x0)))
56*7c3d14c8STreehugger Robot return 1;
57*7c3d14c8STreehugger Robot // inf / any = inf
58*7c3d14c8STreehugger Robot if (test__divtf3(makeInf128(),
59*7c3d14c8STreehugger Robot 0x1.23456789abcdefp+5L,
60*7c3d14c8STreehugger Robot UINT64_C(0x7fff000000000000),
61*7c3d14c8STreehugger Robot UINT64_C(0x0)))
62*7c3d14c8STreehugger Robot return 1;
63*7c3d14c8STreehugger Robot // any / any
64*7c3d14c8STreehugger Robot if (test__divtf3(0x1.a23b45362464523375893ab4cdefp+5L,
65*7c3d14c8STreehugger Robot 0x1.eedcbaba3a94546558237654321fp-1L,
66*7c3d14c8STreehugger Robot UINT64_C(0x4004b0b72924d407),
67*7c3d14c8STreehugger Robot UINT64_C(0x0717e84356c6eba2)))
68*7c3d14c8STreehugger Robot return 1;
69*7c3d14c8STreehugger Robot if (test__divtf3(0x1.a2b34c56d745382f9abf2c3dfeffp-50L,
70*7c3d14c8STreehugger Robot 0x1.ed2c3ba15935332532287654321fp-9L,
71*7c3d14c8STreehugger Robot UINT64_C(0x3fd5b2af3f828c9b),
72*7c3d14c8STreehugger Robot UINT64_C(0x40e51f64cde8b1f2)))
73*7c3d14c8STreehugger Robot return 15;
74*7c3d14c8STreehugger Robot if (test__divtf3(0x1.2345f6aaaa786555f42432abcdefp+456L,
75*7c3d14c8STreehugger Robot 0x1.edacbba9874f765463544dd3621fp+6400L,
76*7c3d14c8STreehugger Robot UINT64_C(0x28c62e15dc464466),
77*7c3d14c8STreehugger Robot UINT64_C(0xb5a07586348557ac)))
78*7c3d14c8STreehugger Robot return 1;
79*7c3d14c8STreehugger Robot if (test__divtf3(0x1.2d3456f789ba6322bc665544edefp-234L,
80*7c3d14c8STreehugger Robot 0x1.eddcdba39f3c8b7a36564354321fp-4455L,
81*7c3d14c8STreehugger Robot UINT64_C(0x507b38442b539266),
82*7c3d14c8STreehugger Robot UINT64_C(0x22ce0f1d024e1252)))
83*7c3d14c8STreehugger Robot return 1;
84*7c3d14c8STreehugger Robot if (test__divtf3(0x1.2345f6b77b7a8953365433abcdefp+234L,
85*7c3d14c8STreehugger Robot 0x1.edcba987d6bb3aa467754354321fp-4055L,
86*7c3d14c8STreehugger Robot UINT64_C(0x50bf2e02f0798d36),
87*7c3d14c8STreehugger Robot UINT64_C(0x5e6fcb6b60044078)))
88*7c3d14c8STreehugger Robot return 1;
89*7c3d14c8STreehugger Robot
90*7c3d14c8STreehugger Robot #else
91*7c3d14c8STreehugger Robot printf("skipped\n");
92*7c3d14c8STreehugger Robot
93*7c3d14c8STreehugger Robot #endif
94*7c3d14c8STreehugger Robot return 0;
95*7c3d14c8STreehugger Robot }
96