Skip to content

Commit

Permalink
Unroll for ~20% better speed.
Browse files Browse the repository at this point in the history
  • Loading branch information
klauspost committed Nov 15, 2023
1 parent 52f808a commit 0d0fba1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions galois_nopshufb_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ func galMulSlice(c byte, in, out []byte, o *options) {
return
}
mt := mulTable[c][:256]
for len(in) >= 4 {
ii := (*[4]byte)(in)
oo := (*[4]byte)(out)
oo[0] = mt[ii[0]]
oo[1] = mt[ii[1]]
oo[2] = mt[ii[2]]
oo[3] = mt[ii[3]]
in = in[4:]
out = out[4:]
}
for n, input := range in {
out[n] = mt[input]
}
Expand All @@ -60,6 +70,16 @@ func galMulSliceXor(c byte, in, out []byte, o *options) {
return
}
mt := mulTable[c][:256]
for len(in) >= 4 {
ii := (*[4]byte)(in)
oo := (*[4]byte)(out)
oo[0] ^= mt[ii[0]]
oo[1] ^= mt[ii[1]]
oo[2] ^= mt[ii[2]]
oo[3] ^= mt[ii[3]]
in = in[4:]
out = out[4:]
}
for n, input := range in {
out[n] ^= mt[input]
}
Expand Down

0 comments on commit 0d0fba1

Please sign in to comment.