From c44da14440e5a2e412f9b1d3f5f2f562591d8e49 Mon Sep 17 00:00:00 2001 From: Kirill Smelkov Date: Thu, 1 Dec 2016 21:40:57 +0300 Subject: [PATCH] cmd/compile/internal/ssa: add tests for BSWAP on stores on AMD64 Commit 10f75748 (CL 32222) taught AMD64 backend to rewrite series of byte loads or stores with corresponding shifts into a single long or quad load or store + appropriate BSWAP. However it did not added test for stores - only loads were tested. Fix it. NOTE Tests for indexed stores are not added because 10f75748 did not add support for indexed stores - only indexed loads were handled then. Change-Id: I48c867ebe7622ac8e691d43741feed1d40cca0d7 Reviewed-on: https://go-review.googlesource.com/34634 Reviewed-by: Keith Randall Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/asm_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/cmd/compile/internal/gc/asm_test.go b/src/cmd/compile/internal/gc/asm_test.go index 945b74ca8c..db800aba20 100644 --- a/src/cmd/compile/internal/gc/asm_test.go +++ b/src/cmd/compile/internal/gc/asm_test.go @@ -175,6 +175,14 @@ func f(b []byte, i int) uint64 { }, {"amd64", "linux", ` import "encoding/binary" +func f(b []byte, v uint64) { + binary.BigEndian.PutUint64(b, v) +} +`, + []string{"\tBSWAPQ\t"}, + }, + {"amd64", "linux", ` +import "encoding/binary" func f(b []byte) uint32 { return binary.BigEndian.Uint32(b) } @@ -186,6 +194,14 @@ import "encoding/binary" func f(b []byte, i int) uint32 { return binary.BigEndian.Uint32(b[i:]) } +`, + []string{"\tBSWAPL\t"}, + }, + {"amd64", "linux", ` +import "encoding/binary" +func f(b []byte, v uint32) { + binary.BigEndian.PutUint32(b, v) +} `, []string{"\tBSWAPL\t"}, }, -- 2.48.1