Commit 686d44d9 authored by Dave Cheney's avatar Dave Cheney

runtime: check pointer equality in arm64 cmpbody

Updates #11336

Follow the lead of amd64 by doing a pointer equality check
before comparing string/byte contents on arm64.

BenchmarkCompareBytesEqual-8               25.8           26.3           +1.94%
BenchmarkCompareBytesToNil-8               9.59           9.59           +0.00%
BenchmarkCompareBytesEmpty-8               9.59           9.17           -4.38%
BenchmarkCompareBytesIdentical-8           26.3           9.17           -65.13%
BenchmarkCompareBytesSameLength-8          16.3           16.3           +0.00%
BenchmarkCompareBytesDifferentLength-8     16.3           16.3           +0.00%
BenchmarkCompareBytesBigUnaligned-8        1132038        1131409        -0.06%
BenchmarkCompareBytesBig-8                 1126758        1128470        +0.15%
BenchmarkCompareBytesBigIdentical-8        1084366        9.17           -100.00%

Change-Id: Id7125c31957eff1ddb78897d4511bd50e79af3f7
Reviewed-on: https://go-review.googlesource.com/13885Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 3efe36d4
...@@ -870,6 +870,8 @@ TEXT bytes·Compare(SB),NOSPLIT,$-4-56 ...@@ -870,6 +870,8 @@ TEXT bytes·Compare(SB),NOSPLIT,$-4-56
// On exit: // On exit:
// R4, R5, and R6 are clobbered // R4, R5, and R6 are clobbered
TEXT runtime·cmpbody<>(SB),NOSPLIT,$-4-0 TEXT runtime·cmpbody<>(SB),NOSPLIT,$-4-0
CMP R2, R3
BEQ samebytes // same starting pointers; compare lengths
CMP R0, R1 CMP R0, R1
CSEL LT, R1, R0, R6 // R6 is min(R0, R1) CSEL LT, R1, R0, R6 // R6 is min(R0, R1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment