Browse Source

glibc/newlib: unroll strcmp further for RV32

This reduces the performance cliff between RV32 and RV64 slightly,
without an egregious increase in code size.
pull/151/head
Andrew Waterman 10 years ago
parent
commit
7b87222f9b
  1. 24
      glibc/sysdeps/riscv/strcmp.S
  2. 24
      newlib/newlib/libc/machine/riscv/strcmp.S

24
glibc/sysdeps/riscv/strcmp.S

@ -54,10 +54,18 @@ ENTRY(strcmp)
.endm
.Lloop:
# examine full words
# examine full words at a time, favoring strings of a couple dozen chars
#ifdef __riscv32
check_one_word 0 5
check_one_word 1 5
check_one_word 2 5
check_one_word 3 5
check_one_word 4 5
#else
check_one_word 0 3
check_one_word 1 3
check_one_word 2 3
#endif
# backwards branch to .Lloop contained above
.Lmismatch:
@ -108,9 +116,17 @@ ENTRY(strcmp)
ret
# cases in which a null byte was detected
foundnull 0, 3
foundnull 1, 3
foundnull 2, 3
#ifdef __riscv32
foundnull 0 5
foundnull 1 5
foundnull 2 5
foundnull 3 5
foundnull 4 5
#else
foundnull 0 3
foundnull 1 3
foundnull 2 3
#endif
END(strcmp)

24
newlib/newlib/libc/machine/riscv/strcmp.S

@ -55,10 +55,18 @@ strcmp:
.endm
.Lloop:
# examine full words
# examine full words at a time, favoring strings of a couple dozen chars
#ifdef __riscv32
check_one_word 0 5
check_one_word 1 5
check_one_word 2 5
check_one_word 3 5
check_one_word 4 5
#else
check_one_word 0 3
check_one_word 1 3
check_one_word 2 3
#endif
# backwards branch to .Lloop contained above
.Lmismatch:
@ -109,9 +117,17 @@ strcmp:
ret
# cases in which a null byte was detected
foundnull 0, 3
foundnull 1, 3
foundnull 2, 3
#ifdef __riscv32
foundnull 0 5
foundnull 1 5
foundnull 2 5
foundnull 3 5
foundnull 4 5
#else
foundnull 0 3
foundnull 1 3
foundnull 2 3
#endif
#if SZREG == 8
.section .srodata.cst8,"aM",@progbits,8

Loading…
Cancel
Save