summaryrefslogtreecommitdiff
path: root/arch/riscv/lib/strlen.S
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-03-03 09:32:51 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2023-03-03 09:32:51 -0800
commitbf1a1bad82407ad81130c065f6495ec0f939ae60 (patch)
tree1067a74a84186de39a94dd1e1ff6faae6c8ebe36 /arch/riscv/lib/strlen.S
parent271d89394e33aae5391fd886c046ce54c8240e5b (diff)
parent61fc1ee8be26bc192d691932b0a67eabee45d12f (diff)
downloadlwn-bf1a1bad82407ad81130c065f6495ec0f939ae60.tar.gz
lwn-bf1a1bad82407ad81130c065f6495ec0f939ae60.zip
Merge tag 'riscv-for-linus-6.3-mw2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull more RISC-V updates from Palmer Dabbelt: - Some cleanups and fixes for the Zbb-optimized string routines - Support for custom (vendor or implementation defined) perf events - COMMAND_LINE_SIZE has been increased to 1024 * tag 'riscv-for-linus-6.3-mw2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: Bump COMMAND_LINE_SIZE value to 1024 drivers/perf: RISC-V: Allow programming custom firmware events riscv, lib: Fix Zbb strncmp RISC-V: improve string-function assembly
Diffstat (limited to 'arch/riscv/lib/strlen.S')
-rw-r--r--arch/riscv/lib/strlen.S10
1 files changed, 5 insertions, 5 deletions
diff --git a/arch/riscv/lib/strlen.S b/arch/riscv/lib/strlen.S
index 8345ceeee3f6..15bb8f3aa959 100644
--- a/arch/riscv/lib/strlen.S
+++ b/arch/riscv/lib/strlen.S
@@ -96,7 +96,7 @@ strlen_zbb:
* of valid bytes in this chunk.
*/
srli a0, t1, 3
- bgtu t3, a0, 3f
+ bgtu t3, a0, 2f
/* Prepare for the word comparison loop. */
addi t2, t0, SZREG
@@ -112,20 +112,20 @@ strlen_zbb:
addi t0, t0, SZREG
orc.b t1, t1
beq t1, t3, 1b
-2:
+
not t1, t1
CZ t1, t1
+ srli t1, t1, 3
- /* Get number of processed words. */
+ /* Get number of processed bytes. */
sub t2, t0, t2
/* Add number of characters in the first word. */
add a0, a0, t2
- srli t1, t1, 3
/* Add number of characters in the last word. */
add a0, a0, t1
-3:
+2:
ret
.option pop