Skip to content

Commit

Permalink
Merge pull request #180 from honeycombio/lizf.cherry-pick
Browse files Browse the repository at this point in the history
cherrypick (#172): internal/lz4block: arm64 decoder improvements
  • Loading branch information
pierrec authored May 17, 2022
2 parents 6b02a43 + 72f1f00 commit 1a84cb2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
8 changes: 5 additions & 3 deletions decode_arm.s
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ copyLiteralFinish:
MOVB.NE tmp2, -1(dst)

copyLiteralDone:
CMP src, srcend
BEQ end

// Initial part of match length.
// This frees up the token register for reuse as offset.
AND $15, token, len

CMP src, srcend
BEQ end

// Read offset.
ADD.S $2, src
BCS shortSrc
Expand Down Expand Up @@ -188,6 +188,8 @@ copyMatchDone:
BNE loop

end:
CMP $0, len
BNE corrupt
SUB dstorig, dst, tmp1
MOVW tmp1, ret+24(FP)
RET
Expand Down
19 changes: 11 additions & 8 deletions decode_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ copyLiteralShortEnd:
MOVB.P tmp4, 1(dst)

copyLiteralDone:
// Initial part of match length.
AND $15, token, len

CMP src, srcend
BEQ end

Expand All @@ -123,8 +126,7 @@ copyLiteralDone:
MOVHU -2(src), offset
CBZ offset, corrupt

// Read match length.
AND $15, token, len
// Read rest of match length.
CMP $15, len
BNE readMatchlenDone

Expand Down Expand Up @@ -163,29 +165,30 @@ copyMatchTry8:
AND $7, len, lenRem
SUB $8, len
copyMatchLoop8:
SUBS $8, len
MOVD.P 8(match), tmp1
MOVD.P tmp1, 8(dst)
SUBS $8, len
BPL copyMatchLoop8

ADD lenRem, match
MOVD (match)(len), tmp2 // match+len == match+lenRem-8.
ADD lenRem, dst
MOVD -8(match), tmp2
MOVD $0, len
MOVD tmp2, -8(dst)
B copyMatchDone

copyMatchLoop1:
// Finish with a byte-at-a-time copy.
SUB $1, len
// Byte-at-a-time copy for small offsets.
MOVBU.P 1(match), tmp2
MOVB.P tmp2, 1(dst)
CBNZ len, copyMatchLoop1
SUBS $1, len
BNE copyMatchLoop1

copyMatchDone:
CMP src, srcend
BNE loop

end:
CBNZ len, corrupt
SUB dstorig, dst, tmp1
MOVD tmp1, ret+48(FP)
RET
Expand Down
1 change: 1 addition & 0 deletions decode_asm.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build (amd64 || arm || arm64) && !appengine && gc && !noasm
// +build amd64 arm arm64
// +build !appengine
// +build gc
Expand Down

0 comments on commit 1a84cb2

Please sign in to comment.