aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/memmove_386.s
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2016-03-29 21:25:33 -0700
committerKeith Randall <khr@golang.org>2016-03-31 02:54:10 +0000
commit4b209dbf0bf3e5fd4cffda1e11f11bf45ddf212d (patch)
treea7af96647c02144a3e82b576eb72d1704bf2f6ff /src/runtime/memmove_386.s
parent1a9373bc570cf408cecdfab5d531e8041f354a54 (diff)
downloadgo-4b209dbf0bf3e5fd4cffda1e11f11bf45ddf212d.tar.gz
go-4b209dbf0bf3e5fd4cffda1e11f11bf45ddf212d.zip
runtime: don't use REP;MOVSB if CPUID doesn't say it is fast
Only use REP;MOVSB if: 1) The CPUID flag says it is fast, and 2) The pointers are unaligned Otherwise, use REP;MOVSQ. Update #14630 Change-Id: I946b28b87880c08e5eed1ce2945016466c89db66 Reviewed-on: https://go-review.googlesource.com/21300 Reviewed-by: Nigel Tao <nigeltao@golang.org>
Diffstat (limited to 'src/runtime/memmove_386.s')
-rw-r--r--src/runtime/memmove_386.s19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/runtime/memmove_386.s b/src/runtime/memmove_386.s
index d4baf2280a..52b35a6ac7 100644
--- a/src/runtime/memmove_386.s
+++ b/src/runtime/memmove_386.s
@@ -70,24 +70,29 @@ nosse2:
* forward copy loop
*/
forward:
+ // If REP MOVSB isn't fast, don't use it
+ TESTL $(1<<9), runtime·cpuid_ebx7(SB) // erms, aka enhanced REP MOVSB/STOSB
+ JEQ fwdBy4
+
// Check alignment
MOVL SI, AX
ORL DI, AX
TESTL $3, AX
- JNE unaligned_fwd
+ JEQ fwdBy4
+
+ // Do 1 byte at a time
+ MOVL BX, CX
+ REP; MOVSB
+ RET
+fwdBy4:
+ // Do 4 bytes at a time
MOVL BX, CX
SHRL $2, CX
ANDL $3, BX
-
REP; MOVSL
JMP tail
-unaligned_fwd:
- MOVL BX, CX
- REP; MOVSB
- RET
-
/*
* check overlap
*/