1
0
mirror of https://github.com/fumiama/blake2b-simd.git synced 2026-06-09 12:30:25 +08:00

Detect SSE automatically and enable corresponding optimized code path.

With this change, following happens.

```
if sse {
   compressSSE()
   return
}
compressGeneric()
```

compressGeneric is used as a fallback when SSE is not detected.
This commit is contained in:
Harshavardhana
2016-06-25 00:25:28 -07:00
committed by Harshavardhana
parent 83ff4cf5f4
commit 3a46db1cb4
10 changed files with 1553 additions and 1456 deletions

View File

@@ -20,9 +20,9 @@
package blake2b
//go:noescape
func compressSSE(p []uint8, in, iv , t, f, shffle, out []uint64)
func blockSSE(p []uint8, in, iv, t, f, shffle, out []uint64)
func compress(d *digest, p []uint8) {
func compressSSE(d *digest, p []uint8) {
h0, h1, h2, h3, h4, h5, h6, h7 := d.h[0], d.h[1], d.h[2], d.h[3], d.h[4], d.h[5], d.h[6], d.h[7]
in := make([]uint64, 8, 8)
@@ -42,7 +42,7 @@ func compress(d *digest, p []uint8) {
in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7] = h0, h1, h2, h3, h4, h5, h6, h7
compressSSE(p, in, iv[:], d.t[:], d.f[:], shffle, out)
blockSSE(p, in, iv[:], d.t[:], d.f[:], shffle, out)
h0, h1, h2, h3, h4, h5, h6, h7 = out[0], out[1], out[2], out[3], out[4], out[5], out[6], out[7]
@@ -51,3 +51,11 @@ func compress(d *digest, p []uint8) {
d.h[0], d.h[1], d.h[2], d.h[3], d.h[4], d.h[5], d.h[6], d.h[7] = h0, h1, h2, h3, h4, h5, h6, h7
}
func compress(d *digest, p []uint8) {
if sse {
compressSSE(d, p)
return
}
compressGeneric(d, p)
}