1 | // RUN: %clang_builtins %s %librt -o %t && %run %t |
---|---|

2 | // REQUIRES: librt_has_multf3 |

3 | |

4 | #include <stdio.h> |

5 | |

6 | #if __LDBL_MANT_DIG__ == 113 |

7 | |

8 | #include "int_lib.h" |

9 | #include "fp_test.h" |

10 | |

11 | // Returns: a * b |

12 | COMPILER_RT_ABI long double __multf3(long double a, long double b); |

13 | |

14 | int test__multf3(long double a, long double b, |

15 | uint64_t expectedHi, uint64_t expectedLo) |

16 | { |

17 | long double x = __multf3(a, b); |

18 | int ret = compareResultLD(x, expectedHi, expectedLo); |

19 | |

20 | if (ret){ |

21 | printf("error in test__multf3(%.20Lf, %.20Lf) = %.20Lf, " |

22 | "expected %.20Lf\n", a, b, x, |

23 | fromRep128(expectedHi, expectedLo)); |

24 | } |

25 | return ret; |

26 | } |

27 | |

28 | char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0}; |

29 | |

30 | #endif |

31 | |

32 | int main() |

33 | { |

34 | #if __LDBL_MANT_DIG__ == 113 |

35 | // qNaN * any = qNaN |

36 | if (test__multf3(makeQNaN128(), |

37 | 0x1.23456789abcdefp+5L, |

38 | UINT64_C(0x7fff800000000000), |

39 | UINT64_C(0x0))) |

40 | return 1; |

41 | // NaN * any = NaN |

42 | if (test__multf3(makeNaN128(UINT64_C(0x800030000000)), |

43 | 0x1.23456789abcdefp+5L, |

44 | UINT64_C(0x7fff800000000000), |

45 | UINT64_C(0x0))) |

46 | return 1; |

47 | // inf * any = inf |

48 | if (test__multf3(makeInf128(), |

49 | 0x1.23456789abcdefp+5L, |

50 | UINT64_C(0x7fff000000000000), |

51 | UINT64_C(0x0))) |

52 | return 1; |

53 | // any * any |

54 | if (test__multf3(0x1.2eab345678439abcdefea56782346p+5L, |

55 | 0x1.edcb34a235253948765432134674fp-1L, |

56 | UINT64_C(0x400423e7f9e3c9fc), |

57 | UINT64_C(0xd906c2c2a85777c4))) |

58 | return 1; |

59 | if (test__multf3(0x1.353e45674d89abacc3a2ebf3ff4ffp-50L, |

60 | 0x1.ed8764648369535adf4be3214567fp-9L, |

61 | UINT64_C(0x3fc52a163c6223fc), |

62 | UINT64_C(0xc94c4bf0430768b4))) |

63 | return 1; |

64 | if (test__multf3(0x1.234425696abcad34a35eeffefdcbap+456L, |

65 | 0x451.ed98d76e5d46e5f24323dff21ffp+600L, |

66 | UINT64_C(0x44293a91de5e0e94), |

67 | UINT64_C(0xe8ed17cc2cdf64ac))) |

68 | return 1; |

69 | if (test__multf3(0x1.4356473c82a9fabf2d22ace345defp-234L, |

70 | 0x1.eda98765476743ab21da23d45678fp-455L, |

71 | UINT64_C(0x3d4f37c1a3137cae), |

72 | UINT64_C(0xfc6807048bc2836a))) |

73 | return 1; |

74 | // underflow |

75 | if (test__multf3(0x1.23456734245345p-10000L, |

76 | 0x1.edcba524498724p-6497L, |

77 | UINT64_C(0x0), |

78 | UINT64_C(0x0))) |

79 | return 1; |

80 | |

81 | #else |

82 | printf("skipped\n"); |

83 | |

84 | #endif |

85 | return 0; |

86 | } |

87 |