Commit c292b32f authored by Ilya Tocar's avatar Ilya Tocar

cmd/compile: enable disjoint memmove inlining on amd64

Memmove can use AVX/prefetches/other optional instructions, so
only do it for small sizes, when call overhead dominates.

Change-Id: Ice5e93deb11462217f7fb5fc350b703109bb4090
Reviewed-on: https://go-review.googlesource.com/112517
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarMichael Munday <mike.munday@ibm.com>
parent 3000795c
...@@ -905,7 +905,7 @@ func isInlinableMemmove(dst, src *Value, sz int64, c *Config) bool { ...@@ -905,7 +905,7 @@ func isInlinableMemmove(dst, src *Value, sz int64, c *Config) bool {
// have fast Move ops. // have fast Move ops.
switch c.arch { switch c.arch {
case "amd64", "amd64p32": case "amd64", "amd64p32":
return sz <= 16 return sz <= 16 || (sz < 1024 && disjoint(dst, sz, src, sz))
case "386", "ppc64", "ppc64le", "arm64": case "386", "ppc64", "ppc64le", "arm64":
return sz <= 8 return sz <= 8
case "s390x": case "s390x":
......
...@@ -40,6 +40,7 @@ var x [256]byte ...@@ -40,6 +40,7 @@ var x [256]byte
func moveDisjointStack() { func moveDisjointStack() {
var s [256]byte var s [256]byte
// s390x:-".*memmove" // s390x:-".*memmove"
// amd64:-".*memmove"
copy(s[:], x[:]) copy(s[:], x[:])
runtime.KeepAlive(&s) runtime.KeepAlive(&s)
} }
...@@ -47,12 +48,14 @@ func moveDisjointStack() { ...@@ -47,12 +48,14 @@ func moveDisjointStack() {
func moveDisjointArg(b *[256]byte) { func moveDisjointArg(b *[256]byte) {
var s [256]byte var s [256]byte
// s390x:-".*memmove" // s390x:-".*memmove"
// amd64:-".*memmove"
copy(s[:], b[:]) copy(s[:], b[:])
runtime.KeepAlive(&s) runtime.KeepAlive(&s)
} }
func moveDisjointNoOverlap(a *[256]byte) { func moveDisjointNoOverlap(a *[256]byte) {
// s390x:-".*memmove" // s390x:-".*memmove"
// amd64:-".*memmove"
copy(a[:], a[128:]) copy(a[:], a[128:])
} }
......
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