From fbb40020b0ded87648f9dd4642236e22b95299ce Mon Sep 17 00:00:00 2001 From: Yang Hau Date: Thu, 25 Jul 2024 16:39:20 +0800 Subject: [PATCH] feat: Add vrecpe[s|d]_[f32|f64] --- neon2rvv.h | 4 ++-- tests/impl.cpp | 26 ++++++++++++++++++++++++-- tests/impl.h | 4 ++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/neon2rvv.h b/neon2rvv.h index b98be3d1..245fbde3 100644 --- a/neon2rvv.h +++ b/neon2rvv.h @@ -7243,9 +7243,9 @@ FORCE_INLINE float64x1_t vrecpe_f64(float64x1_t a) { return __riscv_vfrec7_v_f64 FORCE_INLINE float64x2_t vrecpeq_f64(float64x2_t a) { return __riscv_vfrec7_v_f64m1(a, 2); } -// FORCE_INLINE float32_t vrecpes_f32(float32_t a); +FORCE_INLINE float32_t vrecpes_f32(float32_t a) { return 1.0f / a; } -// FORCE_INLINE float64_t vrecped_f64(float64_t a); +FORCE_INLINE float64_t vrecped_f64(float64_t a) { return 1.0f / a; } // FORCE_INLINE uint32x4_t vrecpeq_u32(uint32x4_t a); diff --git a/tests/impl.cpp b/tests/impl.cpp index 4834461e..b3a58a8b 100644 --- a/tests/impl.cpp +++ b/tests/impl.cpp @@ -25755,9 +25755,31 @@ result_t test_vrecpeq_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { #endif // ENABLE_TEST_ALL } -result_t test_vrecpes_f32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; } +result_t test_vrecpes_f32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { +#ifdef ENABLE_TEST_ALL + const float *_a = impl.test_cases_float_pointer1; + float _c, c; + _c = 1.0f / _a[0]; + + c = vrecpes_f32(_a[0]); + return validate_float_error(c, _c, 0.01f); +#else + return TEST_UNIMPL; +#endif // ENABLE_TEST_ALL +} -result_t test_vrecped_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; } +result_t test_vrecped_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { +#ifdef ENABLE_TEST_ALL + const double *_a = (const double *)impl.test_cases_float_pointer1; + double _c, c; + _c = 1.0f / _a[0]; + + c = vrecped_f64(_a[0]); + return validate_double_error(c, _c, 0.01f); +#else + return TEST_UNIMPL; +#endif // ENABLE_TEST_ALL +} result_t test_vrecpeq_u32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; } diff --git a/tests/impl.h b/tests/impl.h index 5a85e530..47d95dc5 100644 --- a/tests/impl.h +++ b/tests/impl.h @@ -1393,8 +1393,8 @@ _(vrecpeq_f32) \ _(vrecpe_f64) \ _(vrecpeq_f64) \ - /*_(vrecpes_f32) */ \ - /*_(vrecped_f64) */ \ + _(vrecpes_f32) \ + _(vrecped_f64) \ _(vrecpeq_u32) \ _(vrsqrte_f32) \ _(vrsqrte_u32) \