linux/arch/riscv/lib
Feng Jiang 18be4ca5cb riscv: lib: optimize strlen loop efficiency
Optimize the generic strlen implementation by using a pre-decrement
pointer. This reduces the loop body from 4 instructions to 3 and
eliminates the unconditional jump ('j').

Old loop (4 instructions, 2 branches):
  1: lbu t0, 0(t1); beqz t0, 2f; addi t1, t1, 1; j 1b

New loop (3 instructions, 1 branch):
  1: addi t1, t1, 1; lbu t0, 0(t1); bnez t0, 1b

This change improves execution efficiency and reduces branch pressure
for systems without the Zbb extension.

Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
Link: https://patch.msgid.link/20251218032614.57356-1-jiangfeng@kylinos.cn
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2026-02-09 15:27:33 -07:00
..
clear_page.S use linux/export.h rather than asm-generic/export.h 2024-01-09 20:10:40 -08:00
csum.c riscv: checksum: Use riscv_has_extension_likely 2025-11-19 09:19:27 -07:00
delay.c include/linux/delay.h: replace kernel.h with the necessary inclusions 2021-11-09 10:02:49 -08:00
error-inject.c riscv: Add support for function error injection 2021-01-14 15:09:09 -08:00
Makefile Crypto library updates for 6.17 2025-07-28 17:58:52 -07:00
memcpy.S riscv: Use SYM_*() assembly macros instead of deprecated ones 2023-11-06 09:42:47 -08:00
memmove.S riscv: Use SYM_*() assembly macros instead of deprecated ones 2023-11-06 09:42:47 -08:00
memset.S RISC-V: lib: Add pi aliases for string functions 2024-08-05 12:06:39 -07:00
riscv_v_helpers.c riscv: make unsafe user copy routines use existing assembly routines 2025-06-05 11:39:15 -07:00
strcmp.S RISC-V: separate Zbb optimisations requiring and not requiring toolchain support 2025-03-18 08:53:02 +00:00
strlen.S riscv: lib: optimize strlen loop efficiency 2026-02-09 15:27:33 -07:00
strncmp.S RISC-V: separate Zbb optimisations requiring and not requiring toolchain support 2025-03-18 08:53:02 +00:00
tishift.S use linux/export.h rather than asm-generic/export.h 2024-01-09 20:10:40 -08:00
uaccess.S riscv: make unsafe user copy routines use existing assembly routines 2025-06-05 11:39:15 -07:00
uaccess_vector.S riscv: make unsafe user copy routines use existing assembly routines 2025-06-05 11:39:15 -07:00
xor.S riscv: Add vector extension XOR implementation 2024-01-16 07:13:55 -08:00