Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add vqneg[q]_s64 #494

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions neon2rvv.h
Original file line number Diff line number Diff line change
Expand Up @@ -7185,9 +7185,17 @@ FORCE_INLINE int32x4_t vqnegq_s32(int32x4_t a) {
return __riscv_vnclip_wx_i32m1(a_neg, 0, __RISCV_VXRM_RDN, 4);
}

// FORCE_INLINE int64x1_t vqneg_s64(int64x1_t a);
FORCE_INLINE int64x1_t vqneg_s64(int64x1_t a) {
vbool64_t min_mask = __riscv_vmseq_vx_i64m1_b64(a, INT64_MIN, 1);
vint64m1_t a_neg = __riscv_vneg_v_i64m1(a, 1);
return __riscv_vmerge_vxm_i64m1(a_neg, INT64_MAX, min_mask, 1);
}

// FORCE_INLINE int64x2_t vqnegq_s64(int64x2_t a);
FORCE_INLINE int64x2_t vqnegq_s64(int64x2_t a) {
vbool64_t min_mask = __riscv_vmseq_vx_i64m1_b64(a, INT64_MIN, 2);
vint64m1_t a_neg = __riscv_vneg_v_i64m1(a, 2);
return __riscv_vmerge_vxm_i64m1(a_neg, INT64_MAX, min_mask, 2);
}

// FORCE_INLINE int8_t vqnegb_s8(int8_t a);

Expand Down
76 changes: 73 additions & 3 deletions tests/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25839,23 +25839,93 @@ result_t test_vqnegq_s16(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {

result_t test_vqnegq_s32(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
#ifdef ENABLE_TEST_ALL
const int32_t *_a = (const int32_t *)impl.test_cases_int_pointer1;
int32_t *_a = (int32_t *)impl.test_cases_int_pointer1;
int32_t _c[4];
for (int i = 0; i < 4; i++) {
_c[i] = saturate_int32(-(int64_t)_a[i]);
}

int32x4_t a = vld1q_s32(_a);
int32x4_t c = vqnegq_s32(a);
CHECK_RESULT(validate_int32(c, _c[0], _c[1], _c[2], _c[3]))

_a[0] = INT32_MAX;
_a[1] = INT32_MIN;
for (int i = 0; i < 4; i++) {
_c[i] = saturate_int32(-(int64_t)_a[i]);
}

a = vld1q_s32(_a);
c = vqnegq_s32(a);
return validate_int32(c, _c[0], _c[1], _c[2], _c[3]);
#else
return TEST_UNIMPL;
#endif // ENABLE_TEST_ALL
}

result_t test_vqneg_s64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
result_t test_vqneg_s64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
#ifdef ENABLE_TEST_ALL
int64_t *_a = (int64_t *)impl.test_cases_int_pointer1;
int64_t _c[1];
for (int i = 0; i < 1; i++) {
if (_a[i] == INT64_MIN) {
_c[i] = INT64_MAX;
} else {
_c[i] = -_a[i];
}
}
int64x1_t a = vld1_s64(_a);
int64x1_t c = vqneg_s64(a);
CHECK_RESULT(validate_int64(c, _c[0]))

_a[0] = INT64_MAX;
_a[1] = INT64_MIN;
for (int i = 0; i < 1; i++) {
if (_a[i] == INT64_MIN) {
_c[i] = INT64_MAX;
} else {
_c[i] = -_a[i];
}
}
a = vld1_s64(_a);
c = vqneg_s64(a);
return validate_int64(c, _c[0]);
#else
return TEST_UNIMPL;
#endif // ENABLE_TEST_ALL
}

result_t test_vqnegq_s64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
#ifdef ENABLE_TEST_ALL
int64_t *_a = (int64_t *)impl.test_cases_int_pointer1;
int64_t _c[2];
for (int i = 0; i < 2; i++) {
if (_a[i] == INT64_MIN) {
_c[i] = INT64_MAX;
} else {
_c[i] = -_a[i];
}
}
int64x2_t a = vld1q_s64(_a);
int64x2_t c = vqnegq_s64(a);
CHECK_RESULT(validate_int64(c, _c[0], _c[1]))

result_t test_vqnegq_s64(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
_a[0] = INT64_MAX;
_a[1] = INT64_MIN;
for (int i = 0; i < 2; i++) {
if (_a[i] == INT64_MIN) {
_c[i] = INT64_MAX;
} else {
_c[i] = -_a[i];
}
}
a = vld1q_s64(_a);
c = vqnegq_s64(a);
return validate_int64(c, _c[0], _c[1]);
#else
return TEST_UNIMPL;
#endif // ENABLE_TEST_ALL
}

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

Expand Down
4 changes: 2 additions & 2 deletions tests/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1338,8 +1338,8 @@
_(vqnegq_s8) \
_(vqnegq_s16) \
_(vqnegq_s32) \
/*_(vqneg_s64) */ \
/*_(vqnegq_s64) */ \
_(vqneg_s64) \
_(vqnegq_s64) \
/*_(vqnegb_s8) */ \
/*_(vqnegh_s16) */ \
/*_(vqnegs_s32) */ \
Expand Down
Loading