aboutsummaryrefslogtreecommitdiff
path: root/src/internal/bytealg
diff options
context:
space:
mode:
authorMeng Zhuo <mzh@golangcn.org>2022-04-28 23:20:53 +0800
committermzh <mzh@golangcn.org>2022-05-03 14:36:37 +0000
commitd0cda4d95f4c889fdb4988750f704604553c35a4 (patch)
tree7112385eb0ec07f29cf8f43ef84d9bf60d0e8247 /src/internal/bytealg
parentb75e492b35746ca3b327f7b353f4912e705a3125 (diff)
downloadgo-d0cda4d95f4c889fdb4988750f704604553c35a4.tar.xz
internal/bytealg: mask high bit for riscv64 regabi
This CL masks byte params which high bits(~0xff) is unused for riscv64 regabi. Currently the compiler only guarantees the low bits contains value. Change-Id: I6dd6c867e60d2143fefde92c866f78c4b007a2f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/402894 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: mzh <mzh@golangcn.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Diffstat (limited to 'src/internal/bytealg')
-rw-r--r--src/internal/bytealg/count_riscv64.s3
-rw-r--r--src/internal/bytealg/indexbyte_riscv64.s2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/internal/bytealg/count_riscv64.s b/src/internal/bytealg/count_riscv64.s
index 1e081e2c8c..a15d07d768 100644
--- a/src/internal/bytealg/count_riscv64.s
+++ b/src/internal/bytealg/count_riscv64.s
@@ -15,7 +15,7 @@ TEXT ·Count<ABIInternal>(SB),NOSPLIT,$0-40
// X11 = b_len
// X12 = b_cap (unused)
// X13 = byte to count (want in X12)
- MOV X13, X12
+ AND $0xff, X13, X12
#endif
MOV ZERO, X14 // count
ADD X10, X11 // end
@@ -45,6 +45,7 @@ TEXT ·CountString<ABIInternal>(SB),NOSPLIT,$0-32
// X10 = s_base
// X11 = s_len
// X12 = byte to count
+ AND $0xff, X12
MOV ZERO, X14 // count
ADD X10, X11 // end
diff --git a/src/internal/bytealg/indexbyte_riscv64.s b/src/internal/bytealg/indexbyte_riscv64.s
index e9d3e6be39..a20396592b 100644
--- a/src/internal/bytealg/indexbyte_riscv64.s
+++ b/src/internal/bytealg/indexbyte_riscv64.s
@@ -15,6 +15,7 @@ TEXT ·IndexByte<ABIInternal>(SB),NOSPLIT,$0-40
// X11 = b_len
// X12 = b_cap (unused)
// X13 = byte to find
+ AND $0xff, X13
MOV X10, X12 // store base for later
ADD X10, X11 // end
ADD $-1, X10
@@ -47,6 +48,7 @@ TEXT ·IndexByteString<ABIInternal>(SB),NOSPLIT,$0-32
// X10 = b_base
// X11 = b_len
// X12 = byte to find
+ AND $0xff, X12
MOV X10, X13 // store base for later
ADD X10, X11 // end
ADD $-1, X10