diff options
author | Lynn Boger <laboger@linux.vnet.ibm.com> | 2017-10-30 12:30:45 -0400 |
---|---|---|
committer | Lynn Boger <laboger@linux.vnet.ibm.com> | 2017-11-03 18:46:59 +0000 |
commit | bb1fd3b5ff10eb9ad1a40b5bf7c7f35bd20e626f (patch) | |
tree | 5fa0552d41688d157161a1d9153a1ccb12342a57 /src/encoding/binary | |
parent | f99d14e0de86bc387aef366eef122bd49086ac8c (diff) | |
download | go-bb1fd3b5ff10eb9ad1a40b5bf7c7f35bd20e626f.tar.gz go-bb1fd3b5ff10eb9ad1a40b5bf7c7f35bd20e626f.zip |
cmd/compile: add rules to improve consecutive byte loads and stores on ppc64le
This adds new rules to recognize consecutive byte loads and
stores and lowers them to loads and stores such as lhz, lwz, ld,
sth, stw, std. This change only covers the little endian cases
on little endian machines, such as is found in encoding/binary
UintXX or PutUintXX for little endian. Big endian will be done
later.
Updates were also made to binary_test.go to allow the benchmark
for Uint and PutUint to actually use those functions because
the way they were written, those functions were being
optimized out.
Testcases were also added to cmd/compile/internal/gc/asm_test.go.
Updates #22496
The following improvement can be found in golang.org/x/crypto
poly1305:
Benchmark64-16 142 114 -19.72%
Benchmark1K-16 1717 1424 -17.06%
Benchmark64Unaligned-16 142 113 -20.42%
Benchmark1KUnaligned-16 1721 1428 -17.02%
chacha20poly1305:
BenchmarkChacha20Poly1305Open_64-16 1012 885 -12.55%
BenchmarkChacha20Poly1305Seal_64-16 971 836 -13.90%
BenchmarkChacha20Poly1305Open_1350-16 11113 9539 -14.16%
BenchmarkChacha20Poly1305Seal_1350-16 11013 9392 -14.72%
BenchmarkChacha20Poly1305Open_8K-16 61074 53431 -12.51%
BenchmarkChacha20Poly1305Seal_8K-16 61214 54806 -10.47%
Other improvements of around 10% found in crypto/tls.
Results after updating encoding/binary/binary_test.go:
BenchmarkLittleEndianPutUint64-16 1.87 0.93 -50.27%
BenchmarkLittleEndianPutUint32-16 1.19 0.93 -21.85%
BenchmarkLittleEndianPutUint16-16 1.16 1.03 -11.21%
Change-Id: I7bbe2fbcbd11362d58662fecd907a0c07e6ca2fb
Reviewed-on: https://go-review.googlesource.com/74410
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Diffstat (limited to 'src/encoding/binary')
-rw-r--r-- | src/encoding/binary/binary_test.go | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/encoding/binary/binary_test.go b/src/encoding/binary/binary_test.go index 0547bee437..af402575e4 100644 --- a/src/encoding/binary/binary_test.go +++ b/src/encoding/binary/binary_test.go @@ -109,6 +109,7 @@ var little = []byte{ var src = []byte{1, 2, 3, 4, 5, 6, 7, 8} var res = []int32{0x01020304, 0x05060708} +var putbuf = []byte{0, 0, 0, 0, 0, 0, 0, 0} func checkResult(t *testing.T, dir string, order ByteOrder, err error, have, want interface{}) { if err != nil { @@ -502,25 +503,42 @@ func BenchmarkWriteSlice1000Int32s(b *testing.B) { } func BenchmarkPutUint16(b *testing.B) { - buf := [2]byte{} b.SetBytes(2) for i := 0; i < b.N; i++ { - BigEndian.PutUint16(buf[:], uint16(i)) + BigEndian.PutUint16(putbuf[:], uint16(i)) } } func BenchmarkPutUint32(b *testing.B) { - buf := [4]byte{} b.SetBytes(4) for i := 0; i < b.N; i++ { - BigEndian.PutUint32(buf[:], uint32(i)) + BigEndian.PutUint32(putbuf[:], uint32(i)) } } func BenchmarkPutUint64(b *testing.B) { - buf := [8]byte{} b.SetBytes(8) for i := 0; i < b.N; i++ { - BigEndian.PutUint64(buf[:], uint64(i)) + BigEndian.PutUint64(putbuf[:], uint64(i)) + } +} +func BenchmarkLittleEndianPutUint16(b *testing.B) { + b.SetBytes(2) + for i := 0; i < b.N; i++ { + LittleEndian.PutUint16(putbuf[:], uint16(i)) + } +} + +func BenchmarkLittleEndianPutUint32(b *testing.B) { + b.SetBytes(4) + for i := 0; i < b.N; i++ { + LittleEndian.PutUint32(putbuf[:], uint32(i)) + } +} + +func BenchmarkLittleEndianPutUint64(b *testing.B) { + b.SetBytes(8) + for i := 0; i < b.N; i++ { + LittleEndian.PutUint64(putbuf[:], uint64(i)) } } |