[libc-commits] [libc] [libc][math][c23] Add f16sqrtf C23 math function (PR #95251)
via libc-commits
libc-commits at lists.llvm.org
Wed Jun 12 07:11:14 PDT 2024
================
@@ -68,6 +68,41 @@ struct UnaryOpChecker : public virtual LIBC_NAMESPACE::testing::Test {
}
};
+template <typename OutType, typename InType>
+using UnaryNarrowerOp = OutType(InType);
+
+template <typename OutType, typename InType, mpfr::Operation Op,
+ UnaryNarrowerOp<OutType, InType> Func>
+struct UnaryNarrowerOpChecker : public virtual LIBC_NAMESPACE::testing::Test {
+ using FloatType = InType;
+ using FPBits = LIBC_NAMESPACE::fputil::FPBits<FloatType>;
+ using StorageType = typename FPBits::StorageType;
+
+ static constexpr UnaryNarrowerOp<OutType, FloatType> *FUNC = Func;
+
+ // Check in a range, return the number of failures.
+ uint64_t check(StorageType start, StorageType stop,
+ mpfr::RoundingMode rounding) {
+ mpfr::ForceRoundingMode r(rounding);
+ if (!r.success)
+ return (stop > start);
+ StorageType bits = start;
+ uint64_t failed = 0;
+ do {
+ FPBits xbits(bits);
+ FloatType x = xbits.get_val();
+ bool correct =
+ TEST_MPFR_MATCH_ROUNDING_SILENTLY(Op, x, FUNC(x), 0.5, rounding);
+ failed += (!correct);
+ // Uncomment to print out failed values.
+ if (!correct) {
+ EXPECT_MPFR_MATCH_ROUNDING(Op, x, FUNC(x), 0.5, rounding);
+ }
----------------
overmighty wrote:
I forgot to re-comment this.
https://github.com/llvm/llvm-project/pull/95251
More information about the libc-commits
mailing list