Skip to content

Commit 7d4f7c7

Browse files
committed
add vrev8.v byteswap
1 parent d4ffade commit 7d4f7c7

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

bench/byteswap.S

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
#if HAS_RVV_1_0
2+
3+
#if defined(MX) && __riscv_zvbb
4+
.global MX(byteswap32_rvv_vrev8_)
5+
MX(byteswap32_rvv_vrev8_):
6+
1:
7+
vsetvli t0, a1, e32, MX(), ta, ma
8+
vle32.v v0, (a0)
9+
vrev8.v v8, v0
10+
vse32.v v8, (a0)
11+
sub a1, a1, t0
12+
slli t1, t0, 2
13+
add a0, a0, t1
14+
bnez a1, 1b
15+
ret
16+
#endif
17+
218
#if MX_N == 4 || MX_N == 2 || MX_N == 1
319

420
# a0 = ptr, a1 = len

bench/byteswap.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,18 @@ byteswap32_SWAR_rev8(uint32_t *ptr, size_t n)
5353
f(rvv_m1_gatherei16s_m8)
5454
#endif
5555

56+
#if __riscv_zvbb
57+
#define IMPLS_ZVBB(f) MX(f,rvv_vrev8)
58+
#else
59+
#define IMPLS_ZVBB(f)
60+
#endif
61+
62+
5663
#define IMPLS(f) \
5764
f(scalar) \
5865
f(scalar_autovec) \
5966
REV8(f) \
67+
IMPLS_ZVBB(f) \
6068
IMPLS_RVV(f)
6169

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

0 commit comments

Comments
 (0)