[PATCH v2 0/2] riscv: lib: add optimized memcmp() and extend KUnit tests

Milan Tripkovic posted 2 patches 4 weeks, 1 day ago
There is a newer version of this series
arch/riscv/include/asm/string.h |   2 +
arch/riscv/lib/Makefile         |   1 +
arch/riscv/lib/memcmp.S         | 124 ++++++++++++++++++++++++++++++++
arch/riscv/purgatory/Makefile   |   5 +-
lib/tests/string_kunit.c        | 106 +++++++++++++++++++++++++++
5 files changed, 237 insertions(+), 1 deletion(-)
create mode 100644 arch/riscv/lib/memcmp.S
[PATCH v2 0/2] riscv: lib: add optimized memcmp() and extend KUnit tests
Posted by Milan Tripkovic 4 weeks, 1 day ago
Add an assembly implementation of memcmp() for RISC-V. This version
incorporates feedback from v1 regarding alignment safety, loop 
efficiency, and ZBB usage.

The second patch extends the KUnit string tests to include functional
verification and benchmarking for memcmp().
        
Signed-off-by: Milan Tripkovic <Milan.Tripkovic@rt-rk.com>

---
v2 changes:
    - Added alignment checks for buffers to avoid expensive misaligned loads.
    - Optimized the loop using end-pointers to reduce per-iteration overhead.
    - Implemented word-aligned tail handling using ZBB shifts.
    - Removed redundant pointer equality (a0 == a1) check.
    - Retained BE support via #ifndef; ZBB rev8 is used for the LE fast-path.
    - Fixed KUnit build failures for Clang and non-benchmark configs.

Milan Tripkovic (2):
  riscv: lib: add memcmp() implementation
  lib/string_kunit: extend benchmarks and unit test to memcmp()

 arch/riscv/include/asm/string.h |   2 +
 arch/riscv/lib/Makefile         |   1 +
 arch/riscv/lib/memcmp.S         | 124 ++++++++++++++++++++++++++++++++
 arch/riscv/purgatory/Makefile   |   5 +-
 lib/tests/string_kunit.c        | 106 +++++++++++++++++++++++++++
 5 files changed, 237 insertions(+), 1 deletion(-)
 create mode 100644 arch/riscv/lib/memcmp.S

-- 
2.43.0