diff options
| author | Keith Randall <khr@golang.org> | 2023-06-10 08:26:34 -0700 |
|---|---|---|
| committer | David Chase <drchase@google.com> | 2023-07-21 19:06:53 +0000 |
| commit | e713d6f939c90eb599c1469d08bb5edd7de8a281 (patch) | |
| tree | 9276e7eb337a4fe2d5a66311eaf0658527b819d2 /test/codegen | |
| parent | ffd9bd7e605cdd2eb66e38bad6e0d93b0d37963c (diff) | |
| download | go-e713d6f939c90eb599c1469d08bb5edd7de8a281.tar.xz | |
cmd/compile: memcombine if values being stored are from consecutive loads
If we load 2 values and then store those 2 loaded values, we can likely
perform that operation with a single wider load and store.
Fixes #60709
Change-Id: Ifc5f92c2f1b174c6ed82a69070f16cec6853c770
Reviewed-on: https://go-review.googlesource.com/c/go/+/502295
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen')
| -rw-r--r-- | test/codegen/memcombine.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/codegen/memcombine.go b/test/codegen/memcombine.go index 0d1c390dfc..adad9c613d 100644 --- a/test/codegen/memcombine.go +++ b/test/codegen/memcombine.go @@ -836,3 +836,25 @@ func zero_uint64_2(d1, d2 []uint64) { d1[0], d1[1] = 0, 0 // arm64:"STP",-"MOVB",-"MOVH" d2[1], d2[0] = 0, 0 // arm64:"STP",-"MOVB",-"MOVH" } + +func loadstore(p, q *[4]uint8) { + // amd64:"MOVL",-"MOVB" + // arm64:"MOVWU",-"MOVBU" + x0, x1, x2, x3 := q[0], q[1], q[2], q[3] + // amd64:"MOVL",-"MOVB" + // arm64:"MOVW",-"MOVB" + p[0], p[1], p[2], p[3] = x0, x1, x2, x3 +} + +type S1 struct { + a, b int16 +} + +func loadstore2(p, q *S1) { + // amd64:"MOVL",-"MOVWLZX" + // arm64:"MOVWU",-"MOVH" + a, b := p.a, p.b + // amd64:"MOVL",-"MOVW" + // arm64:"MOVW",-"MOVH" + q.a, q.b = a, b +} |
