diff options
author | Ruslan Andreev <ruslan.andreev@huawei.com> | 2021-01-19 22:30:10 +0800 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2021-05-12 16:23:30 +0000 |
commit | 3b321a9d122f0dbf8b333cc79bbf61218e3d05ba (patch) | |
tree | 8bc8bfeb9f886a84f695ca542623e58df30d544d /test | |
parent | 07ff596404b03a8e01ed53f1553c59eb215dc697 (diff) | |
download | go-3b321a9d122f0dbf8b333cc79bbf61218e3d05ba.tar.gz go-3b321a9d122f0dbf8b333cc79bbf61218e3d05ba.zip |
cmd/compile: add arch-specific inlining for runtime.memmove
This CL add runtime.memmove inlining for AMD64 and ARM64.
According to ssa dump from testcases generic rules can't inline
memmomve properly due to one of the arguments is Phi operation. But this
Phi op will be optimized out by later optimization stages. As a result
memmove can be inlined during arch-specific rules.
The commit add new optimization rules to arch-specific rules that can
inline runtime.memmove if it possible during lowering stage.
Optimization fires 5 times in Go source-code using regabi.
Fixes #41662
Change-Id: Iaffaf4c482d068b5f0683d141863892202cc8824
Reviewed-on: https://go-review.googlesource.com/c/go/+/289151
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: David Chase <drchase@google.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/codegen/copy.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/codegen/copy.go b/test/codegen/copy.go index 0cd86d1161..ea8a01f803 100644 --- a/test/codegen/copy.go +++ b/test/codegen/copy.go @@ -97,6 +97,42 @@ func moveDisjointNoOverlap(a *[256]byte) { copy(a[:], a[128:]) } +// Check arch-specific memmove lowering. See issue 41662 fot details + +func moveArchLowering1(b []byte, x *[1]byte) { + _ = b[1] + // amd64:-".*memmove" + // arm64:-".*memmove" + copy(b, x[:]) +} + +func moveArchLowering2(b []byte, x *[2]byte) { + _ = b[2] + // amd64:-".*memmove" + // arm64:-".*memmove" + copy(b, x[:]) +} + +func moveArchLowering4(b []byte, x *[4]byte) { + _ = b[4] + // amd64:-".*memmove" + // arm64:-".*memmove" + copy(b, x[:]) +} + +func moveArchLowering8(b []byte, x *[8]byte) { + _ = b[8] + // amd64:-".*memmove" + // arm64:-".*memmove" + copy(b, x[:]) +} + +func moveArchLowering16(b []byte, x *[16]byte) { + _ = b[16] + // amd64:-".*memmove" + copy(b, x[:]) +} + // Check that no branches are generated when the pointers are [not] equal. func ptrEqual() { |