diff options
author | Heiko Stuebner <heiko.stuebner@vrull.eu> | 2023-02-08 23:53:28 +0100 |
---|---|---|
committer | Palmer Dabbelt <palmer@rivosinc.com> | 2023-02-28 08:00:34 -0800 |
commit | 6934cf8a3e0b4a8318ce8f1342348e967e29192f (patch) | |
tree | 0a0cabf60b22d188fc8897a179667699e41328ee /arch/riscv/lib/strncmp.S | |
parent | 01687e7c935ef70eca69ea2d468020bc93e898dc (diff) |
RISC-V: improve string-function assembly
Adapt the suggestions for the assembly string functions that Andrew
suggested but that I didn't manage to include into the series that
got applied.
This includes improvements to two comments, removal of unneeded labels
and moving one instruction slightly higher to contradict an
explanatory comment.
Suggested-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Heiko Stuebner <heiko.stuebner@vrull.eu>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Tested-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20230208225328.1636017-3-heiko@sntech.de
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'arch/riscv/lib/strncmp.S')
-rw-r--r-- | arch/riscv/lib/strncmp.S | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/arch/riscv/lib/strncmp.S b/arch/riscv/lib/strncmp.S index ee49595075be..e09de79e62b9 100644 --- a/arch/riscv/lib/strncmp.S +++ b/arch/riscv/lib/strncmp.S @@ -70,7 +70,7 @@ strncmp_zbb: li t5, -1 and t2, t2, SZREG-1 add t4, a0, a2 - bnez t2, 4f + bnez t2, 3f /* Adjust limit for fast-path. */ andi t6, t4, -SZREG @@ -114,23 +114,21 @@ strncmp_zbb: ret /* Simple loop for misaligned strings. */ -3: - /* Restore limit for slow-path. */ .p2align 3 -4: - bge a0, t4, 6f +3: + bge a0, t4, 5f lbu t0, 0(a0) lbu t1, 0(a1) addi a0, a0, 1 addi a1, a1, 1 - bne t0, t1, 5f - bnez t0, 4b + bne t0, t1, 4f + bnez t0, 3b -5: +4: sub a0, t0, t1 ret -6: +5: li a0, 0 ret |