diff options
author | Michael Munday <mike.munday@ibm.com> | 2018-04-29 15:12:50 +0100 |
---|---|---|
committer | Michael Munday <mike.munday@ibm.com> | 2018-05-09 11:20:40 +0000 |
commit | 6d00e8c478431b32b38ac5849a703a86df8e5298 (patch) | |
tree | 54a68f6a7d6ca643e0b1cf379ccd8cf6458236db /test/codegen/copy.go | |
parent | 66cb80c266a83313abadbd004b5358c1d1761ed3 (diff) | |
download | go-git-6d00e8c478431b32b38ac5849a703a86df8e5298.tar.gz |
cmd/compile: convert memmove call into Move when arguments are disjoint
Move ops can be faster than memmove calls because the number of bytes
to be moved is fixed and they don't incur the overhead of a call.
This change allows memmove to be converted into a Move op when the
arguments are disjoint.
The optimization is only enabled on s390x at the moment, however
other architectures may also benefit from it in the future. The
memmove inlining rule triggers an extra 12 times when compiling the
standard library. It will most likely make more of a difference as the
disjoint function is improved over time (to recognize fresh heap
allocations for example).
Change-Id: I9af570dcfff28257b8e59e0ff584a46d8e248310
Reviewed-on: https://go-review.googlesource.com/110064
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Diffstat (limited to 'test/codegen/copy.go')
-rw-r--r-- | test/codegen/copy.go | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/test/codegen/copy.go b/test/codegen/copy.go index 70a4f86ae8..5c3837bc7c 100644 --- a/test/codegen/copy.go +++ b/test/codegen/copy.go @@ -6,6 +6,8 @@ package codegen +import "runtime" + // Check small copies are replaced with moves. func movesmall4() { @@ -31,10 +33,31 @@ func movesmall16() { copy(x[1:], x[:]) } -// Check that no branches are generated when the pointers are [not] equal. - var x [256]byte +// Check that large disjoint copies are replaced with moves. + +func moveDisjointStack() { + var s [256]byte + // s390x:-".*memmove" + copy(s[:], x[:]) + runtime.KeepAlive(&s) +} + +func moveDisjointArg(b *[256]byte) { + var s [256]byte + // s390x:-".*memmove" + copy(s[:], b[:]) + runtime.KeepAlive(&s) +} + +func moveDisjointNoOverlap(a *[256]byte) { + // s390x:-".*memmove" + copy(a[:], a[128:]) +} + +// Check that no branches are generated when the pointers are [not] equal. + func ptrEqual() { // amd64:-"JEQ",-"JNE" // ppc64le:-"BEQ",-"BNE" |