summaryrefslogtreecommitdiff
path: root/libgo/go/hash/crc32/crc32_s390x.go
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2016-09-20 21:49:12 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2016-09-20 21:49:12 +0000
commitc9c81ef3c667aaa14c498a5449ec6d134b4b66ff (patch)
tree0ac440db6513ee01deb5e5dc6142769d1e5b7b2d /libgo/go/hash/crc32/crc32_s390x.go
parent12cdcb9d74f55c165366ca1b1eeec013a0ce72ef (diff)
parent891196d7325e4c55d92d5ac5cfe7161c4f36c0ce (diff)
downloadgcc-c9c81ef3c667aaa14c498a5449ec6d134b4b66ff.tar.gz
Merge from trunk (r239915 to r240230)fortran-dev
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/fortran-dev@240290 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/hash/crc32/crc32_s390x.go')
-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 b8a580870c5..2a7926b4796 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:]