Skip to content

Commit b2e809b

Browse files
committed
internal/bytealg: improve compare on Power10/PPC64
Handle comparisons of 15 or less bytes more efficiently with Power10 instructions when building with GOPPC64=power10. name old time/op new time/op delta BytesCompare/1 2.53ns ± 0% 2.17ns ± 0% -14.17% BytesCompare/2 2.70ns ± 0% 2.17ns ± 0% -19.77% BytesCompare/4 2.59ns ± 0% 2.17ns ± 0% -16.20% BytesCompare/8 2.66ns ± 0% 2.17ns ± 0% -18.63% Change-Id: I6d7c6af0a58ea3e03acc3930c54b77f2ac1dfbd5 Reviewed-on: https://go-review.googlesource.com/c/go/+/522315 Reviewed-by: Joedian Reid <[email protected]> Run-TryBot: Paul Murphy <[email protected]> Reviewed-by: Lynn Boger <[email protected]> Reviewed-by: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent c5569f0 commit b2e809b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/internal/bytealg/compare_ppc64x.s

+11-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,16 @@ lower:
274274
RET
275275

276276
PCALIGN $16
277-
cmp8: // 8 - 15B
277+
cmp8: // 8 - 15B (0 - 15B if GOPPC64_power10)
278+
#ifdef GOPPC64_power10
279+
SLD $56,R9,R9
280+
LXVLL R5,R9,V3 // Load bytes starting from MSB to LSB, unused are zero filled.
281+
LXVLL R6,R9,V4
282+
VCMPUQ V3,V4,CR0 // Compare as a 128b integer.
283+
SETB_CR0(R6)
284+
ISEL CR0EQ,R3,R6,R3 // If equal, length determines the return value.
285+
RET
286+
#else
278287
CMP R9,$8
279288
BLT cmp4
280289
ANDCC $7,R9,R9
@@ -330,3 +339,4 @@ cmp0:
330339
SETB_CR0(R6)
331340
ISEL CR0EQ,R3,R6,R3
332341
RET
342+
#endif

0 commit comments

Comments
 (0)