diff options
| author | Alejandro García Montoro <alejandro.garciamontoro@gmail.com> | 2021-05-14 18:42:16 +0200 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2021-10-09 01:04:29 +0000 |
| commit | e1c294a56d5d03cdba1f059cdb6b1225477dc546 (patch) | |
| tree | ef0d6bae89b2c4f81449091a0688b5299a6395f6 /test/codegen | |
| parent | 74abcabf3045d2c893a517c872ace719f0e9d88f (diff) | |
| download | go-e1c294a56d5d03cdba1f059cdb6b1225477dc546.tar.xz | |
cmd/compile: eliminate successive swaps
The code generated when storing eight bytes loaded from memory in big
endian introduced two successive byte swaps that did not actually
modified the data.
The new rules match this specific pattern both for amd64 and for arm64,
eliminating the double swap.
Fixes #41684
Change-Id: Icb6dc20b68e4393cef4fe6a07b33aba0d18c3ff3
Reviewed-on: https://go-review.googlesource.com/c/go/+/320073
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Diffstat (limited to 'test/codegen')
| -rw-r--r-- | test/codegen/memcombine.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/codegen/memcombine.go b/test/codegen/memcombine.go index d74dae07f5..2a0c534df0 100644 --- a/test/codegen/memcombine.go +++ b/test/codegen/memcombine.go @@ -432,6 +432,18 @@ func store_be32(b []byte) { binary.BigEndian.PutUint32(b, sink32) } +func store_be64_load(b, x *[8]byte) { + // arm64:-`REV` + // amd64:-`BSWAPQ` + binary.BigEndian.PutUint64(b[:], binary.BigEndian.Uint64(x[:])) +} + +func store_be32_load(b, x *[8]byte) { + // arm64:-`REVW` + // amd64:-`BSWAPL` + binary.BigEndian.PutUint32(b[:], binary.BigEndian.Uint32(x[:])) +} + func store_be32_idx(b []byte, idx int) { // amd64:`BSWAPL`,-`SHR.` // arm64:`REVW`,`MOVW\sR[0-9]+,\s\(R[0-9]+\)\(R[0-9]+\)`,-`MOV[BH]`,-`REV16W` |
