Skip to content

Commit

Permalink
add vrev8.v byteswap
Browse files Browse the repository at this point in the history
  • Loading branch information
camel-cdr committed Aug 17, 2024
1 parent d4ffade commit 7d4f7c7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bench/byteswap.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#if HAS_RVV_1_0

#if defined(MX) && __riscv_zvbb
.global MX(byteswap32_rvv_vrev8_)
MX(byteswap32_rvv_vrev8_):
1:
vsetvli t0, a1, e32, MX(), ta, ma
vle32.v v0, (a0)
vrev8.v v8, v0
vse32.v v8, (a0)
sub a1, a1, t0
slli t1, t0, 2
add a0, a0, t1
bnez a1, 1b
ret
#endif

#if MX_N == 4 || MX_N == 2 || MX_N == 1

# a0 = ptr, a1 = len
Expand Down
8 changes: 8 additions & 0 deletions bench/byteswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,18 @@ byteswap32_SWAR_rev8(uint32_t *ptr, size_t n)
f(rvv_m1_gatherei16s_m8)
#endif

#if __riscv_zvbb
#define IMPLS_ZVBB(f) MX(f,rvv_vrev8)
#else
#define IMPLS_ZVBB(f)
#endif


#define IMPLS(f) \
f(scalar) \
f(scalar_autovec) \
REV8(f) \
IMPLS_ZVBB(f) \
IMPLS_RVV(f)

typedef void Func(uint32_t *ptr, size_t n);
Expand Down

0 comments on commit 7d4f7c7

Please sign in to comment.