]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: enable disjoint memmove inlining on amd64
authorIlya Tocar <ilya.tocar@intel.com>
Wed, 9 May 2018 20:49:22 +0000 (15:49 -0500)
committerIlya Tocar <ilya.tocar@intel.com>
Mon, 20 Aug 2018 21:10:12 +0000 (21:10 +0000)
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: Michael Munday <mike.munday@ibm.com>
src/cmd/compile/internal/ssa/rewrite.go
test/codegen/copy.go

index 5e151b5213d29b656c1dffd719b9dd3e9cfec2ad..e7d1b5c767ece14977eab9f8e9167210f01bb80e 100644 (file)
@@ -905,7 +905,7 @@ func isInlinableMemmove(dst, src *Value, sz int64, c *Config) bool {
        // have fast Move ops.
        switch c.arch {
        case "amd64", "amd64p32":
-               return sz <= 16
+               return sz <= 16 || (sz < 1024 && disjoint(dst, sz, src, sz))
        case "386", "ppc64", "ppc64le", "arm64":
                return sz <= 8
        case "s390x":
index 5c3837bc7c337d37666f407f265b035c0b05b97e..dc8ee43f4c7e02ea615b88918600e98d843840b5 100644 (file)
@@ -40,19 +40,22 @@ var x [256]byte
 func moveDisjointStack() {
        var s [256]byte
        // s390x:-".*memmove"
+       // amd64:-".*memmove"
        copy(s[:], x[:])
        runtime.KeepAlive(&s)
 }
 
-func moveDisjointArg(b *[256]byte)  {
+func moveDisjointArg(b *[256]byte) {
        var s [256]byte
        // s390x:-".*memmove"
+       // amd64:-".*memmove"
        copy(s[:], b[:])
        runtime.KeepAlive(&s)
 }
 
 func moveDisjointNoOverlap(a *[256]byte) {
        // s390x:-".*memmove"
+       // amd64:-".*memmove"
        copy(a[:], a[128:])
 }