From 708f4fe884f782ce5cf94ecf611abf451ca51e7e Mon Sep 17 00:00:00 2001 From: Yang Hau Date: Thu, 1 Aug 2024 02:29:39 +0800 Subject: [PATCH] feat: Add vcvt[q|d]_f64_[s64|u64] --- neon2rvv.h | 12 +++---- tests/impl.cpp | 90 ++++++++++++++++++++++++++++++++++++++++++++++---- tests/impl.h | 12 +++---- 3 files changed, 96 insertions(+), 18 deletions(-) diff --git a/neon2rvv.h b/neon2rvv.h index 6fb31f64..0c95e117 100644 --- a/neon2rvv.h +++ b/neon2rvv.h @@ -8072,17 +8072,17 @@ FORCE_INLINE float32_t vcvts_f32_s32(int32_t a) { return (float32_t)a; } FORCE_INLINE float32_t vcvts_f32_u32(uint32_t a) { return (float32_t)a; } -// FORCE_INLINE float64x1_t vcvt_f64_s64(int64x1_t a); +FORCE_INLINE float64x1_t vcvt_f64_s64(int64x1_t a) { return __riscv_vfcvt_f_x_v_f64m1(a, 1); } -// FORCE_INLINE float64x2_t vcvtq_f64_s64(int64x2_t a); +FORCE_INLINE float64x2_t vcvtq_f64_s64(int64x2_t a) { return __riscv_vfcvt_f_x_v_f64m1(a, 2); } -// FORCE_INLINE float64x1_t vcvt_f64_u64(uint64x1_t a); +FORCE_INLINE float64x1_t vcvt_f64_u64(uint64x1_t a) { return __riscv_vfcvt_f_xu_v_f64m1(a, 1); } -// FORCE_INLINE float64x2_t vcvtq_f64_u64(uint64x2_t a); +FORCE_INLINE float64x2_t vcvtq_f64_u64(uint64x2_t a) { return __riscv_vfcvt_f_xu_v_f64m1(a, 2); } -// FORCE_INLINE float64_t vcvtd_f64_s64(int64_t a); +FORCE_INLINE float64_t vcvtd_f64_s64(int64_t a) { return (float64_t)a; } -// FORCE_INLINE float64_t vcvtd_f64_u64(uint64_t a); +FORCE_INLINE float64_t vcvtd_f64_u64(uint64_t a) { return (float64_t)a; } FORCE_INLINE uint32x4_t vcvtq_u32_f32(float32x4_t a) { return __riscv_vfcvt_rtz_xu_f_v_u32m1(a, 4); } diff --git a/tests/impl.cpp b/tests/impl.cpp index 2f37b567..e64d026f 100644 --- a/tests/impl.cpp +++ b/tests/impl.cpp @@ -30038,17 +30038,95 @@ result_t test_vcvts_f32_u32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { #endif // ENABLE_TEST_ALL } -result_t test_vcvt_f64_s64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; } +result_t test_vcvt_f64_s64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { +#ifdef ENABLE_TEST_ALL + const int64_t *_a = (const int64_t *)impl.test_cases_int_pointer1; + double _c[1]; + for (int i = 0; i < 1; i++) { + _c[i] = _a[i]; + } + + int64x1_t a = vld1_s64(_a); + float64x1_t c = vcvt_f64_s64(a); + return validate_double(c, _c[0]); +#else + return TEST_UNIMPL; +#endif // ENABLE_TEST_ALL +} + +result_t test_vcvtq_f64_s64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { +#ifdef ENABLE_TEST_ALL + const int64_t *_a = (const int64_t *)impl.test_cases_int_pointer1; + double _c[2]; + for (int i = 0; i < 2; i++) { + _c[i] = _a[i]; + } + + int64x2_t a = vld1q_s64(_a); + float64x2_t c = vcvtq_f64_s64(a); + return validate_double(c, _c[0], _c[1]); +#else + return TEST_UNIMPL; +#endif // ENABLE_TEST_ALL +} + +result_t test_vcvt_f64_u64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { +#ifdef ENABLE_TEST_ALL + const uint64_t *_a = (const uint64_t *)impl.test_cases_int_pointer1; + double _c[1]; + for (int i = 0; i < 1; i++) { + _c[i] = _a[i]; + } + + uint64x1_t a = vld1_u64(_a); + float64x1_t c = vcvt_f64_u64(a); + return validate_double(c, _c[0]); +#else + return TEST_UNIMPL; +#endif // ENABLE_TEST_ALL +} -result_t test_vcvtq_f64_s64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; } +result_t test_vcvtq_f64_u64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { +#ifdef ENABLE_TEST_ALL + const uint64_t *_a = (const uint64_t *)impl.test_cases_int_pointer1; + double _c[2]; + for (int i = 0; i < 2; i++) { + _c[i] = _a[i]; + } -result_t test_vcvt_f64_u64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; } + uint64x2_t a = vld1q_u64(_a); + float64x2_t c = vcvtq_f64_u64(a); + return validate_double(c, _c[0], _c[1]); +#else + return TEST_UNIMPL; +#endif // ENABLE_TEST_ALL +} -result_t test_vcvtq_f64_u64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; } +result_t test_vcvtd_f64_s64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { +#ifdef ENABLE_TEST_ALL + const int64_t *_a = (const int64_t *)impl.test_cases_int_pointer1; + double _c, c; + _c = _a[0]; -result_t test_vcvtd_f64_s64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; } + c = vcvtd_f64_s64(_a[0]); + return c == _c ? TEST_SUCCESS : TEST_FAIL; +#else + return TEST_UNIMPL; +#endif // ENABLE_TEST_ALL +} -result_t test_vcvtd_f64_u64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; } +result_t test_vcvtd_f64_u64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { +#ifdef ENABLE_TEST_ALL + const uint64_t *_a = (const uint64_t *)impl.test_cases_int_pointer1; + double _c, c; + _c = _a[0]; + + c = vcvtd_f64_u64(_a[0]); + return c == _c ? TEST_SUCCESS : TEST_FAIL; +#else + return TEST_UNIMPL; +#endif // ENABLE_TEST_ALL +} result_t test_vcvtq_u32_f32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { #ifdef ENABLE_TEST_ALL diff --git a/tests/impl.h b/tests/impl.h index 4678e2ad..f01b492b 100644 --- a/tests/impl.h +++ b/tests/impl.h @@ -1661,12 +1661,12 @@ _(vcvtq_f32_u32) \ _(vcvts_f32_s32) \ _(vcvts_f32_u32) \ - /*_(vcvt_f64_s64) */ \ - /*_(vcvtq_f64_s64) */ \ - /*_(vcvt_f64_u64) */ \ - /*_(vcvtq_f64_u64) */ \ - /*_(vcvtd_f64_s64) */ \ - /*_(vcvtd_f64_u64) */ \ + _(vcvt_f64_s64) \ + _(vcvtq_f64_s64) \ + _(vcvt_f64_u64) \ + _(vcvtq_f64_u64) \ + _(vcvtd_f64_s64) \ + _(vcvtd_f64_u64) \ _(vcvtq_u32_f32) \ /*_(vcvtn_s32_f32) */ \ /*_(vcvtnq_s32_f32) */ \