1 // RUN: %clang_builtins %s %librt -o %t && %run %t
2 // REQUIRES: librt_has_multf3
6 #if __LDBL_MANT_DIG__ == 113
12 COMPILER_RT_ABI
long double __multf3(long double a
, long double b
);
14 int test__multf3(long double a
, long double b
,
15 uint64_t expectedHi
, uint64_t expectedLo
)
17 long double x
= __multf3(a
, b
);
18 int ret
= compareResultF128(x
, expectedHi
, expectedLo
);
21 printf("error in test__multf3(%.20Lf, %.20Lf) = %.20Lf, "
22 "expected %.20Lf\n", a
, b
, x
,
23 fromRep128(expectedHi
, expectedLo
));
28 char assumption_1
[sizeof(long double) * CHAR_BIT
== 128] = {0};
34 #if __LDBL_MANT_DIG__ == 113
36 if (test__multf3(makeQNaN128(),
37 0x1.23456789abcdefp
+5L,
38 UINT64_C(0x7fff800000000000),
42 if (test__multf3(makeNaN128(UINT64_C(0x800030000000)),
43 0x1.23456789abcdefp
+5L,
44 UINT64_C(0x7fff800000000000),
48 if (test__multf3(makeInf128(),
49 0x1.23456789abcdefp
+5L,
50 UINT64_C(0x7fff000000000000),
54 if (test__multf3(0x1.2eab345678439abcdefea56782346p
+5L,
55 0x1.edcb34a235253948765432134674fp
-1L,
56 UINT64_C(0x400423e7f9e3c9fc),
57 UINT64_C(0xd906c2c2a85777c4)))
59 if (test__multf3(0x1.353e45674d89abacc3a2ebf3ff4ffp
-50L,
60 0x1.ed8764648369535adf4be3214567fp
-9L,
61 UINT64_C(0x3fc52a163c6223fc),
62 UINT64_C(0xc94c4bf0430768b4)))
64 if (test__multf3(0x1.234425696abcad34a35eeffefdcbap
+456L,
65 0x451.ed98d76e5d46e5f24323dff21ffp
+600L,
66 UINT64_C(0x44293a91de5e0e94),
67 UINT64_C(0xe8ed17cc2cdf64ac)))
69 if (test__multf3(0x1.4356473c82a9fabf2d22ace345defp
-234L,
70 0x1.eda98765476743ab21da23d45678fp
-455L,
71 UINT64_C(0x3d4f37c1a3137cae),
72 UINT64_C(0xfc6807048bc2836a)))
75 if (test__multf3(0x1.23456734245345p
-10000L,
76 0x1.edcba524498724p
-6497L,
80 // test carry between lo and hi in widening multiply
81 if (test__multf3(0x0.7fffffffffffffffffffffffffffp
-16382L,
82 0x1.7fffffffffffffffffffffffffffp
+1L,
83 UINT64_C(0x00017fffffffffff),
84 UINT64_C(0xfffffffffffffffc)))