Skip to content

Commit

Permalink
Merge pull request #498 from howjmay/cvt_f64
Browse files Browse the repository at this point in the history
feat: Add vcvt[q|d]_[s64|u64]_f64
  • Loading branch information
howjmay authored Jul 31, 2024
2 parents d243c26 + eb5cbd6 commit 4e39149
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 @@ -8138,13 +8138,13 @@ FORCE_INLINE uint32x4_t vcvtq_u32_f32(float32x4_t a) { return __riscv_vfcvt_rtz_

// FORCE_INLINE uint32_t vcvtas_u32_f32(float32_t a);

// FORCE_INLINE int64x1_t vcvt_s64_f64(float64x1_t a);
FORCE_INLINE int64x1_t vcvt_s64_f64(float64x1_t a) { return __riscv_vfcvt_rtz_x_f_v_i64m1(a, 1); }

// FORCE_INLINE int64x2_t vcvtq_s64_f64(float64x2_t a);
FORCE_INLINE int64x2_t vcvtq_s64_f64(float64x2_t a) { return __riscv_vfcvt_rtz_x_f_v_i64m1(a, 2); }

// FORCE_INLINE uint64x1_t vcvt_u64_f64(float64x1_t a);
FORCE_INLINE uint64x1_t vcvt_u64_f64(float64x1_t a) { return __riscv_vfcvt_rtz_xu_f_v_u64m1(a, 1); }

// FORCE_INLINE uint64x2_t vcvtq_u64_f64(float64x2_t a);
FORCE_INLINE uint64x2_t vcvtq_u64_f64(float64x2_t a) { return __riscv_vfcvt_rtz_xu_f_v_u64m1(a, 2); }

// FORCE_INLINE int64x1_t vcvtn_s64_f64(float64x1_t a);

Expand Down Expand Up @@ -8178,9 +8178,9 @@ FORCE_INLINE uint32x4_t vcvtq_u32_f32(float32x4_t a) { return __riscv_vfcvt_rtz_

// FORCE_INLINE uint64x2_t vcvtaq_u64_f64(float64x2_t a);

// FORCE_INLINE int64_t vcvtd_s64_f64(float64_t a);
FORCE_INLINE int64_t vcvtd_s64_f64(float64_t a) { return (int64_t)a; }

// FORCE_INLINE uint64_t vcvtd_u64_f64(float64_t a);
FORCE_INLINE uint64_t vcvtd_u64_f64(float64_t a) { return (uint64_t)a; }

// FORCE_INLINE int64_t vcvtnd_s64_f64(float64_t a);

Expand Down
90 changes: 84 additions & 6 deletions tests/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30196,13 +30196,69 @@ result_t test_vcvtas_s32_f32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { re

result_t test_vcvtas_u32_f32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }

result_t test_vcvt_s64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
result_t test_vcvt_s64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
#ifdef ENABLE_TEST_ALL
const double *_a = (const double *)impl.test_cases_float_pointer1;
int64_t _c[1];
for (int i = 0; i < 1; i++) {
_c[i] = _a[i];
}

float64x1_t a = vld1_f64(_a);
int64x1_t c = vcvt_s64_f64(a);
return validate_int64(c, _c[0]);
#else
return TEST_UNIMPL;
#endif // ENABLE_TEST_ALL
}

result_t test_vcvtq_s64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
#ifdef ENABLE_TEST_ALL
const double *_a = (const double *)impl.test_cases_float_pointer1;
int64_t _c[2];
for (int i = 0; i < 2; i++) {
_c[i] = _a[i];
}

float64x2_t a = vld1q_f64(_a);
int64x2_t c = vcvtq_s64_f64(a);
return validate_int64(c, _c[0], _c[1]);
#else
return TEST_UNIMPL;
#endif // ENABLE_TEST_ALL
}

result_t test_vcvtq_s64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
result_t test_vcvt_u64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
#ifdef ENABLE_TEST_ALL
const double *_a = (const double *)impl.test_cases_float_pointer1;
uint64_t _c[1];
for (int i = 0; i < 1; i++) {
_c[i] = _a[i];
}

float64x1_t a = vld1_f64(_a);
uint64x1_t c = vcvt_u64_f64(a);
return validate_uint64(c, _c[0]);
#else
return TEST_UNIMPL;
#endif // ENABLE_TEST_ALL
}

result_t test_vcvt_u64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
result_t test_vcvtq_u64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
#ifdef ENABLE_TEST_ALL
const double *_a = (const double *)impl.test_cases_float_pointer1;
uint64_t _c[2];
for (int i = 0; i < 2; i++) {
_c[i] = _a[i];
}

result_t test_vcvtq_u64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
float64x2_t a = vld1q_f64(_a);
uint64x2_t c = vcvtq_u64_f64(a);
return validate_uint64(c, _c[0], _c[1]);
#else
return TEST_UNIMPL;
#endif // ENABLE_TEST_ALL
}

result_t test_vcvtn_s64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }

Expand Down Expand Up @@ -30236,9 +30292,31 @@ result_t test_vcvta_u64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { ret

result_t test_vcvtaq_u64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }

result_t test_vcvtd_s64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
result_t test_vcvtd_s64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
#ifdef ENABLE_TEST_ALL
const double *_a = (const double *)impl.test_cases_float_pointer1;
int64_t _c, c;
_c = _a[0];

c = vcvtd_s64_f64(_a[0]);
return c == _c ? TEST_SUCCESS : TEST_FAIL;
#else
return TEST_UNIMPL;
#endif // ENABLE_TEST_ALL
}

result_t test_vcvtd_u64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
#ifdef ENABLE_TEST_ALL
const double *_a = (const double *)impl.test_cases_float_pointer1;
uint64_t _c, c;
_c = _a[0];

result_t test_vcvtd_u64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
c = vcvtd_u64_f64(_a[0]);
return c == _c ? TEST_SUCCESS : TEST_FAIL;
#else
return TEST_UNIMPL;
#endif // ENABLE_TEST_ALL
}

result_t test_vcvtnd_s64_f64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }

Expand Down
12 changes: 6 additions & 6 deletions tests/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1694,10 +1694,10 @@
/*_(vcvtps_u32_f32) */ \
/*_(vcvtas_s32_f32) */ \
/*_(vcvtas_u32_f32) */ \
/*_(vcvt_s64_f64) */ \
/*_(vcvtq_s64_f64) */ \
/*_(vcvt_u64_f64) */ \
/*_(vcvtq_u64_f64) */ \
_(vcvt_s64_f64) \
_(vcvtq_s64_f64) \
_(vcvt_u64_f64) \
_(vcvtq_u64_f64) \
/*_(vcvtn_s64_f64) */ \
/*_(vcvtnq_s64_f64) */ \
/*_(vcvtn_u64_f64) */ \
Expand All @@ -1714,8 +1714,8 @@
/*_(vcvtaq_s64_f64) */ \
/*_(vcvta_u64_f64) */ \
/*_(vcvtaq_u64_f64) */ \
/*_(vcvtd_s64_f64) */ \
/*_(vcvtd_u64_f64) */ \
_(vcvtd_s64_f64) \
_(vcvtd_u64_f64) \
/*_(vcvtnd_s64_f64) */ \
/*_(vcvtnd_u64_f64) */ \
/*_(vcvtmd_s64_f64) */ \
Expand Down

0 comments on commit 4e39149

Please sign in to comment.