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