Skip to content

Commit

Permalink
Merge pull request #497 from howjmay/cvt_f64
Browse files Browse the repository at this point in the history
feat: Add vcvt[q|d]_f64_[s64|u64]
  • Loading branch information
howjmay authored Jul 31, 2024
2 parents bad5bfe + 708f4fe commit d243c26
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 18 deletions.
12 changes: 6 additions & 6 deletions neon2rvv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); }

Expand Down
90 changes: 84 additions & 6 deletions tests/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) */ \
Expand Down

0 comments on commit d243c26

Please sign in to comment.