Repository navigation
Conversation
encode_deflate_icf_06 gathers the lit/len and dist codes of 16 entries with two vpgatherdd, which are slow on AMD Zen 4 and Zen 5. Add encode_deflate_icf_10, built from encode_df_06.asm with USE_BYTE_PLANES. When a call has at least 288 entries, it splits the two code tables into byte planes on the stack and looks up the codes of 64 entries at a time with VBMI byte permutes: per plane, four 128-entry lookups in the lit/len table, whose entry 512 is broadcast, and two 128-entry lookups and one 64-entry lookup in the dist table. Unpacks interleave the planes back into dwords, the main loop loads the codes of each 16 entries from there, and the last entries are still gathered. The output does not change. Emerald Rapids and Granite Rapids gather fast enough that the lookups cost more than they save: a build that selected encode_deflate_icf_10 on every processor with AVX-512 VBMI made level 1 3% to 4% slower on them. So give mbin_dispatch_init6 an optional 7th function for AMD processors and an optional 8th argument with the CPUID.7.0:ECX features it needs, and select encode_deflate_icf_10 that way with VBMI and FLAGS_CPUID7_ECX_AVX512_G2. Other processors with AVX-512 keep encode_deflate_icf_06. Signed-off-by: Parker Loflin <parker@cronstable.dev>
ptweezy
force-pushed
the
igzip-icf-encode-vbmi
branch
from
October 21, 2026 21:27
c5dbca6 to
3d748ac
Compare
This was referenced Oct 21, 2026
ptweezy
marked this pull request as draft
October 21, 2026 22:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
encode_deflate_icf_06, the AVX-512 encoder for levels 1 to 3, gathers the lit/len and dist codes of each 16 ICF entries with twovpgatherdd, which are slow on AMD. This PR addsencode_deflate_icf_10,encode_df_06.asmbuilt withUSE_BYTE_PLANES, which looks up the codes of 64 entries at a time with VBMI byte permutes when a call has at least 288 entries, and gathers only the last entries.Which CPUs run it
AMD processors with AVX-512 VBMI (Zen 4, Zen 5), at levels 1 to 3: an optional 7th function and 8th argument of
mbin_dispatch_init6select it only on AuthenticAMD processors with VBMI and the G2 features. Selected on every processor with VBMI, it made level 1 3-4% slower on Emerald Rapids and Granite Rapids; on Ice Lake, it made whole files 0.5% slower and 16 and 64 KB slices 1.4% and 2.2% faster (run, both builds on top of my other open changes).Output does not change, and
encode_deflate_icf_06assembles to the same code as on master.Related PRs
FUNC_SAVEofencode_df_06.asm, whichencode_df_10.asmincludes and which corrupts the upper halves of xmm6-xmm14.Makefile.nmake,cmake/igzip.cmakeandigzip/Makefile.am.Results
MB/s, master → this PR, in-process A/B on GitHub runners (Zen 4, Zen 5, harness): median over all runs (two per runner) of the best of 11 rounds; in parentheses, the median over runs of the change in median-round throughput; Silesia files and 256 slices of the Silesia tar.
Testing
make checkpasses on Linux and natively on Windows 11 (mingw, Ryzen 7 9800X3D), alone and with igzip: save xmm6-xmm15 at 16-byte steps in the win64 ICF encoders #450. On Windows with igzip: save xmm6-xmm15 at 16-byte steps in the win64 ICF encoders #450, every call to the new encoder and its dispatcher keeps xmm6-xmm15, the callee-saved GPRs, rsp and DF.encode_deflate_icf_10and_06return the same output and bit state for 45,000 random token streams ending atPROT_NONEpages; level 1-3 output is the same with either in the dispatch slot.