aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/hash
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2016-09-10 13:14:00 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2016-09-10 13:14:00 +0000
commitaf4b8a523322d6100b52d41ad12d7b602d01331b (patch)
tree948949901cdcd5af947a3db9a68f59e5c4b415bd /libgo/go/hash
parent337fa50b7b0d2964b6ebe2373224b5c1bbb61efb (diff)
downloadgcc-af4b8a523322d6100b52d41ad12d7b602d01331b.zip
gcc-af4b8a523322d6100b52d41ad12d7b602d01331b.tar.gz
gcc-af4b8a523322d6100b52d41ad12d7b602d01331b.tar.bz2
libgo: update to Go 1.7.1 release
Reviewed-on: https://go-review.googlesource.com/29012 From-SVN: r240071
Diffstat (limited to 'libgo/go/hash')
-rw-r--r--libgo/go/hash/crc32/crc32_s390x.go35
1 files changed, 8 insertions, 27 deletions
diff --git a/libgo/go/hash/crc32/crc32_s390x.go b/libgo/go/hash/crc32/crc32_s390x.go
index b8a5808..2a7926b 100644
--- a/libgo/go/hash/crc32/crc32_s390x.go
+++ b/libgo/go/hash/crc32/crc32_s390x.go
@@ -6,14 +6,9 @@
package crc32
-import (
- "unsafe"
-)
-
const (
vxMinLen = 64
- vxAlignment = 16
- vxAlignMask = vxAlignment - 1
+ vxAlignMask = 15 // align to 16 bytes
)
// hasVectorFacility reports whether the machine has the z/Architecture
@@ -51,20 +46,13 @@ func genericIEEE(crc uint32, p []byte) uint32 {
return update(crc, IEEETable, p)
}
-// updateCastagnoli calculates the checksum of p using genericCastagnoli to
-// align the data appropriately for vectorCastagnoli. It avoids using
-// vectorCastagnoli entirely if the length of p is less than or equal to
-// vxMinLen.
+// updateCastagnoli calculates the checksum of p using
+// vectorizedCastagnoli if possible and falling back onto
+// genericCastagnoli as needed.
func updateCastagnoli(crc uint32, p []byte) uint32 {
// Use vectorized function if vector facility is available and
// data length is above threshold.
- if hasVX && len(p) > vxMinLen {
- pAddr := uintptr(unsafe.Pointer(&p[0]))
- if pAddr&vxAlignMask != 0 {
- prealign := vxAlignment - int(pAddr&vxAlignMask)
- crc = genericCastagnoli(crc, p[:prealign])
- p = p[prealign:]
- }
+ if hasVX && len(p) >= vxMinLen {
aligned := len(p) & ^vxAlignMask
crc = vectorizedCastagnoli(crc, p[:aligned])
p = p[aligned:]
@@ -77,19 +65,12 @@ func updateCastagnoli(crc uint32, p []byte) uint32 {
return genericCastagnoli(crc, p)
}
-// updateIEEE calculates the checksum of p using genericIEEE to align the data
-// appropriately for vectorIEEE. It avoids using vectorIEEE entirely if the length
-// of p is less than or equal to vxMinLen.
+// updateIEEE calculates the checksum of p using vectorizedIEEE if
+// possible and falling back onto genericIEEE as needed.
func updateIEEE(crc uint32, p []byte) uint32 {
// Use vectorized function if vector facility is available and
// data length is above threshold.
- if hasVX && len(p) > vxMinLen {
- pAddr := uintptr(unsafe.Pointer(&p[0]))
- if pAddr&vxAlignMask != 0 {
- prealign := vxAlignment - int(pAddr&vxAlignMask)
- crc = genericIEEE(crc, p[:prealign])
- p = p[prealign:]
- }
+ if hasVX && len(p) >= vxMinLen {
aligned := len(p) & ^vxAlignMask
crc = vectorizedIEEE(crc, p[:aligned])
p = p[aligned:]