Skip to content

Commit c0bbc84

Browse files
lizthegreyclaude
andauthored
zstd: bump avo pin, regenerate arm64 asm (#1167)
* zstd: bump avo pin, regenerate arm64 with BMI2 lowering Bumps the pinned avo commit (honeycombio/avo) past today's fixes: a flag-liveness bug and a 32-bit CMPL/TESTL fold bug (neither actually reachable from this codebase - seqdec's generated output is byte-identical without them, and CMPL/TESTL aren't used here at all), plus a new EQ/NE-only sub-32-bit CMPW/TESTB lowering that fse_decoder's buildDtable needs. Checked whether the sub-word compare/test fold (the general form of which the new avo now refuses to lower) actually produced wrong output in the already-shipped fse_decoder_arm64.s: it didn't. All three call sites happened to operate on registers already clean above the compared width (via an upstream sign/zero-extending load, or a preceding bounds check), verified by tracing register provenance by hand. Real risk, but mitigated by accident rather than by design - which is exactly why the stricter check is worth having going forward. The new avo also prefers the BMI2 twin over the generic one when lowering to arm64 (arm64 has native flag-free equivalents for the BMI2 idioms), so seqdec_arm64.s now lowers sequenceDecs_decode_bmi2/decodeSync_bmi2 instead of the generic variants. Symbol names are unaffected (arm64Name strips the _bmi2/_amd64 suffix either way). Validated: go vet and go test ./zstd/... pass natively on arm64; FuzzDecodeAll (26.4M execs), FuzzDecoder (9.6M execs), and FuzzDecAllNoBMI2 pass with zero crashers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * zstd: bump avo pin, prefer generic (non-BMI2) twin on arm64 Benchmarking the BMI2-preferred seqdec on real hardware (Apple M4, Cortex-A72) showed it's 13-50% slower than the generic twin, not faster as assumed -- see the follow-up avo commit for why. Bump past that fix; avo's arm64 lowering now defaults to the generic twin (ARM64PreferBMI2 defaults false), which this repo doesn't override. seqdec_arm64.s is now byte-identical to what #1160 shipped, aside from the skip-reason comment text; fse_decoder_arm64.s is unchanged (the CMPW/TESTB fix has no BMI2 twin to choose between). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent efdb6ed commit c0bbc84

4 files changed

Lines changed: 18 additions & 11 deletions

File tree

zstd/_generate/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.24.2
66

77
require (
88
github.com/klauspost/compress v1.15.15
9-
github.com/mmcloughlin/avo v0.6.0
9+
github.com/mmcloughlin/avo v0.6.1-0.20260709170202-520357590ac6
1010
)
1111

1212
require (
@@ -17,4 +17,4 @@ require (
1717

1818
replace github.com/klauspost/compress => ../..
1919

20-
replace github.com/mmcloughlin/avo => github.com/honeycombio/avo v0.6.1-0.20260629192935-ff52dcb5f88d
20+
replace github.com/mmcloughlin/avo => github.com/honeycombio/avo v0.6.1-0.20260709170202-520357590ac6

zstd/_generate/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
22
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
3-
github.com/honeycombio/avo v0.6.1-0.20260629192935-ff52dcb5f88d h1:946aSI2nbyDYa8iTjFmwoM4S4TKmE8heVLGlchLj7vU=
4-
github.com/honeycombio/avo v0.6.1-0.20260629192935-ff52dcb5f88d/go.mod h1:+Pk+j3KceMwAIGb32HZSCvkMCzJvxy6xCRk+urz7iPw=
3+
github.com/honeycombio/avo v0.6.1-0.20260709170202-520357590ac6 h1:NG37EIVIXn6fWkKN8xIUqLZ7huCzt+17QTbW2bEc9vA=
4+
github.com/honeycombio/avo v0.6.1-0.20260709170202-520357590ac6/go.mod h1:+Pk+j3KceMwAIGb32HZSCvkMCzJvxy6xCRk+urz7iPw=
55
golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ=
66
golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc=
77
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=

zstd/fse_decoder_arm64.s

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ TEXT ·buildDtable_asm(SB), $0-24
2828
init_main_loop:
2929
ADD R8<<1, R1, R15
3030
MOVH (R15), R9
31-
CMN $1, R9
31+
AND $0xffff, R9, R15
32+
MOVD $-1, R16
33+
AND $0xffff, R16, R16
34+
CMP R16, R15
3235
BNE do_not_update_high_threshold
3336
ADD R7<<3, R5, R15
3437
MOVB R8, 1(R15)
@@ -126,9 +129,13 @@ build_table_main_table:
126129
RET
127130

128131
build_table_check1_ok:
129-
TST R1, R1
132+
AND $0xff, R1, R15
133+
AND $0xff, R1, R16
134+
TST R16, R15
130135
BNE build_table_check2_ok
131-
CMP R6, R7
136+
AND $0xffff, R7, R15
137+
AND $0xffff, R6, R16
138+
CMP R16, R15
132139
BNE build_table_check2_ok
133140
MOVD ctx+8(FP), R0
134141
MOVD R7, 24(R0)

zstd/seqdec_arm64.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,9 @@ error_overread:
670670
MOVD R16, ret+24(FP)
671671
RET
672672

673-
// skipped sequenceDecs_decode_bmi2 (BMI2 not available on arm64)
673+
// skipped sequenceDecs_decode_bmi2 (generic twin preferred on arm64)
674674

675-
// skipped sequenceDecs_decode_56_bmi2 (BMI2 not available on arm64)
675+
// skipped sequenceDecs_decode_56_bmi2 (generic twin preferred on arm64)
676676

677677
// func sequenceDecs_executeSimple_amd64(ctx *executeAsmContext) bool
678678
// Requires: SSE
@@ -1966,7 +1966,7 @@ error_not_enough_space:
19661966
MOVD R16, ret+24(FP)
19671967
RET
19681968

1969-
// skipped sequenceDecs_decodeSync_bmi2 (BMI2 not available on arm64)
1969+
// skipped sequenceDecs_decodeSync_bmi2 (generic twin preferred on arm64)
19701970

19711971
// func sequenceDecs_decodeSync_safe_amd64(s *sequenceDecs, br *bitReader, ctx *decodeSyncAsmContext) int
19721972
// Requires: CMOV, SSE
@@ -2702,4 +2702,4 @@ error_not_enough_space:
27022702
MOVD R16, ret+24(FP)
27032703
RET
27042704

2705-
// skipped sequenceDecs_decodeSync_safe_bmi2 (BMI2 not available on arm64)
2705+
// skipped sequenceDecs_decodeSync_safe_bmi2 (generic twin preferred on arm64)

0 commit comments

Comments
 (0)