Skip to content

Commit

Permalink
Merge pull request #18 from howjmay/vbsl_s8
Browse files Browse the repository at this point in the history
feat: Add vbsl_s8
  • Loading branch information
howjmay authored Oct 27, 2023
2 parents 6bf5d2e + 797c386 commit c5dd322
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 4 additions & 1 deletion neon2rvv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2365,7 +2365,10 @@ FORCE_INLINE int8x8_t vrev64_s8(int8x8_t __a) {

// FORCE_INLINE uint8x16_t vrev16q_u8(uint8x16_t __a);

// FORCE_INLINE int8x8_t vbsl_s8(uint8x8_t __a, int8x8_t __b, int8x8_t __c);
FORCE_INLINE int8x8_t vbsl_s8(uint8x8_t __a, int8x8_t __b, int8x8_t __c) {
return __riscv_vxor_vv_i8mf2(
__riscv_vand_vv_i8mf2(__riscv_vxor_vv_i8mf2(__c, __b, 8), __riscv_vreinterpret_v_u8mf2_i8mf2(__a), 8), __c, 8);
}

// FORCE_INLINE int16x4_t vbsl_s16(uint16x4_t __a, int16x4_t __b, int16x4_t __c);

Expand Down
21 changes: 20 additions & 1 deletion tests/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2916,7 +2916,26 @@ result_t test_vrev16q_s8(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return

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

result_t test_vbsl_s8(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) { return TEST_UNIMPL; }
result_t test_vbsl_s8(const NEON2RVV_TEST_IMPL &impl, uint32_t iter) {
const int8_t *_a = (int8_t *)impl.test_cases_int_pointer1;
const int8_t *_b = (int8_t *)impl.test_cases_int_pointer1 + 8;
const int8_t *_c = (int8_t *)impl.test_cases_int_pointer2;

int8_t d0 = _c[0] ^ ((_c[0] ^ _b[0]) & _a[0]);
int8_t d1 = _c[1] ^ ((_c[1] ^ _b[1]) & _a[1]);
int8_t d2 = _c[2] ^ ((_c[2] ^ _b[2]) & _a[2]);
int8_t d3 = _c[3] ^ ((_c[3] ^ _b[3]) & _a[3]);
int8_t d4 = _c[4] ^ ((_c[4] ^ _b[4]) & _a[4]);
int8_t d5 = _c[5] ^ ((_c[5] ^ _b[5]) & _a[5]);
int8_t d6 = _c[6] ^ ((_c[6] ^ _b[6]) & _a[6]);
int8_t d7 = _c[7] ^ ((_c[7] ^ _b[7]) & _a[7]);

uint8x8_t a = vld1_u8((uint8_t *)_a);
int8x8_t b = vld1_s8(_b);
int8x8_t c = vld1_s8(_c);
int8x8_t d = vbsl_s8(a, b, c);
return validate_int8(d, d0, d1, d2, d3, d4, d5, d6, d7);
}

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

Expand Down

0 comments on commit c5dd322

Please sign in to comment.