Files
clang-p2996/libc/test/src/math/in_float_range_test_helper.h
Kirill Okhotnikov 89ed5b7c50 [libc][math] Added auxiliary function log2_eval for asinhf/acoshf/atanhf.
1) `double log2_eval(double)` function added with better than float precision is added.
2) Some refactoring done to put all auxiliary functions and corresponding data
to one place to reuse the code.
3) Added tests for new functions.
4) Performance and precision tests of the function shows, that it more precise than exiting log2,
(no exceptional cases), but timing is ~5% higer that on current one.

Differential Revision: https://reviews.llvm.org/D132809
2022-08-30 22:39:54 +02:00

27 lines
1.3 KiB
C

//
// Created by kirill on 8/30/22.
//
#ifndef LLVM_IN_FLOAT_RANGE_TEST_HELPER_H
#define LLVM_IN_FLOAT_RANGE_TEST_HELPER_H
#include <stdint.h>
#define CHECK_DATA(start, stop, mfp_op, f, f_check, count, prec) \
{ \
uint64_t ustart = FPBits(start).uintval(); \
uint64_t ustop = FPBits(stop).uintval(); \
for (uint64_t i = 0;; ++i) { \
uint64_t v = ustart + (ustop - ustart) * i / count; \
if (v > ustop) \
break; \
float x = FPBits(uint32_t(v)).get_val(); \
if ((f_check)(x)) { \
EXPECT_MPFR_MATCH_ALL_ROUNDING(mfp_op, x, static_cast<float>((f)(x)), \
(prec)); \
} \
} \
}
#endif // LLVM_IN_FLOAT_RANGE_TEST_HELPER_H