diff options
author | Austin Clements <austin@google.com> | 2014-10-31 13:39:36 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2014-10-31 13:39:36 -0400 |
commit | 40a5b3ecb1578a68b0423b8ef4eaebd5fb4c7869 (patch) | |
tree | 41859800101653986208dba799e9aebfd5557383 | |
parent | 6e86003651be7feb6da46360d6c411ff1c29b7f5 (diff) | |
download | go-40a5b3ecb1578a68b0423b8ef4eaebd5fb4c7869.tar.gz go-40a5b3ecb1578a68b0423b8ef4eaebd5fb4c7869.zip |
[dev.power64] runtime: fix fastrand1 on power64x
fastrand1 depends on testing the high bit of its uint32 state.
For efficiency, all of the architectures implement this as a
sign bit test. However, on power64, fastrand1 was using a
64-bit sign test on the zero-extended 32-bit state. This
always failed, causing fastrand1 to have very short periods
and often decay to 0 and get stuck.
Fix this by using a 32-bit signed compare instead of a 64-bit
compare. This fixes various tests for the randomization of
select of map iteration.
LGTM=rsc
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/166990043
-rw-r--r-- | src/runtime/asm_power64x.s | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/runtime/asm_power64x.s b/src/runtime/asm_power64x.s index 2ad3e56e94..713cc5f549 100644 --- a/src/runtime/asm_power64x.s +++ b/src/runtime/asm_power64x.s @@ -965,7 +965,7 @@ TEXT runtime·fastrand1(SB), NOSPLIT, $0-4 MOVD g_m(g), R4 MOVWZ m_fastrand(R4), R3 ADD R3, R3 - CMP R3, $0 + CMPW R3, $0 BGE 2(PC) XOR $0x88888eef, R3 MOVW R3, m_fastrand(R4) |