This cannot beat the Zbb implementation, and it is unlikely that a real meaningful CPU design would support V and not Zbb. The best loop rewrite that I could come up with (4 shifts, 2 ands, 3 ors) is still ~40% slower than Zbb. A proper faster vector implementation should be feasible with the cryptographic vector extensions, but that is a story for another time.
Unified · Split
| @@ -26,7 +26,6 @@ · 25 unmodified lines | ||
| 26 | 26 | #include "libavcodec/bswapdsp.h" |
| 27 | 27 | |
| 28 | 28 | void ff_bswap32_buf_rvb(uint32_t *dst, const uint32_t *src, int len); |
| 29 | −void ff_bswap32_buf_rvv(uint32_t *dst, const uint32_t *src, int len); | |
| 30 | 29 | void ff_bswap16_buf_rvv(uint16_t *dst, const uint16_t *src, int len); |
| 31 | 30 | |
| 32 | 31 | av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c) |
| @@ -39,10 +38,8 @@ av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c) · 6 unmodified lines | ||
| 39 | 38 | c->bswap_buf = ff_bswap32_buf_rvb; |
| 40 | 39 | #endif |
| 41 | 40 | #if HAVE_RVV |
| 42 | − if (flags & AV_CPU_FLAG_RVV_I32) { | |
| 43 | − c->bswap_buf = ff_bswap32_buf_rvv; | |
| 41 | + if (flags & AV_CPU_FLAG_RVV_I32) | |
| 44 | 42 | c->bswap16_buf = ff_bswap16_buf_rvv; |
| 45 | − } | |
| 46 | 43 | #endif |
| 47 | 44 | } |
| 48 | 45 | } |
| @@ -21,29 +21,6 @@ · 20 unmodified lines | ||
| 21 | 21 | #include "config.h" |
| 22 | 22 | #include "libavutil/riscv/asm.S" |
| 23 | 23 | |
| 24 | −func ff_bswap32_buf_rvv, zve32x | |
| 25 | − li t4, 4 | |
| 26 | − addi t1, a0, 1 | |
| 27 | − addi t2, a0, 2 | |
| 28 | − addi t3, a0, 3 | |
| 29 | −1: | |
| 30 | − vsetvli t0, a2, e8, m1, ta, ma | |
| 31 | − vlseg4e8.v v8, (a1) | |
| 32 | − sub a2, a2, t0 | |
| 33 | − sh2add a1, t0, a1 | |
| 34 | − vsse8.v v8, (t3), t4 | |
| 35 | − sh2add t3, t0, t3 | |
| 36 | − vsse8.v v9, (t2), t4 | |
| 37 | − sh2add t2, t0, t2 | |
| 38 | − vsse8.v v10, (t1), t4 | |
| 39 | − sh2add t1, t0, t1 | |
| 40 | − vsse8.v v11, (a0), t4 | |
| 41 | − sh2add a0, t0, a0 | |
| 42 | − bnez a2, 1b | |
| 43 | − | |
| 44 | − ret | |
| 45 | −endfunc | |
| 46 | − | |
| 47 | 24 | func ff_bswap16_buf_rvv, zve32x |
| 48 | 25 | 1: |
| 49 | 26 | vsetvli t0, a2, e16, m8, ta, ma |