1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_multf3
3 //===--------------- multf3_test.c - Test __multf3 ------------------------===//
5 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
6 // See https://llvm.org/LICENSE.txt for license information.
7 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9 //===----------------------------------------------------------------------===//
11 // This file tests __multf3 for the compiler_rt library.
13 //===----------------------------------------------------------------------===//
17 #if __LDBL_MANT_DIG__ == 113
23 COMPILER_RT_ABI
long double __multf3(long double a
, long double b
);
25 int test__multf3(long double a
, long double b
,
26 uint64_t expectedHi
, uint64_t expectedLo
)
28 long double x
= __multf3(a
, b
);
29 int ret
= compareResultLD(x
, expectedHi
, expectedLo
);
32 printf("error in test__multf3(%.20Lf, %.20Lf) = %.20Lf, "
33 "expected %.20Lf\n", a
, b
, x
,
34 fromRep128(expectedHi
, expectedLo
));
39 char assumption_1
[sizeof(long double) * CHAR_BIT
== 128] = {0};
45 #if __LDBL_MANT_DIG__ == 113
47 if (test__multf3(makeQNaN128(),
48 0x1.23456789abcdefp
+5L,
49 UINT64_C(0x7fff800000000000),
53 if (test__multf3(makeNaN128(UINT64_C(0x800030000000)),
54 0x1.23456789abcdefp
+5L,
55 UINT64_C(0x7fff800000000000),
59 if (test__multf3(makeInf128(),
60 0x1.23456789abcdefp
+5L,
61 UINT64_C(0x7fff000000000000),
65 if (test__multf3(0x1.2eab345678439abcdefea56782346p
+5L,
66 0x1.edcb34a235253948765432134674fp
-1L,
67 UINT64_C(0x400423e7f9e3c9fc),
68 UINT64_C(0xd906c2c2a85777c4)))
70 if (test__multf3(0x1.353e45674d89abacc3a2ebf3ff4ffp
-50L,
71 0x1.ed8764648369535adf4be3214567fp
-9L,
72 UINT64_C(0x3fc52a163c6223fc),
73 UINT64_C(0xc94c4bf0430768b4)))
75 if (test__multf3(0x1.234425696abcad34a35eeffefdcbap
+456L,
76 0x451.ed98d76e5d46e5f24323dff21ffp
+600L,
77 UINT64_C(0x44293a91de5e0e94),
78 UINT64_C(0xe8ed17cc2cdf64ac)))
80 if (test__multf3(0x1.4356473c82a9fabf2d22ace345defp
-234L,
81 0x1.eda98765476743ab21da23d45678fp
-455L,
82 UINT64_C(0x3d4f37c1a3137cae),
83 UINT64_C(0xfc6807048bc2836a)))
86 if (test__multf3(0x1.23456734245345p
-10000L,
87 0x1.edcba524498724p
-6497L,