Repository navigation
Conversation
On win64, the FUNC_SAVE and FUNC_RESTORE macros of encode_deflate_icf_04 and encode_deflate_icf_06 store and load xmm6-xmm15 with MOVDQU at xmm_save_mem_offset + i*8. Each 16-byte store overwrites the upper half of the one before it, so encode_deflate_icf() returns with the upper 64 bits of xmm6-xmm14 replaced by the low 64 bits of the next register. The low halves and xmm15 come back intact, so scalar float and double values survive, but a 128-bit vector value the caller keeps in xmm6-xmm14 across level 1-3 compression on an AVX2 or AVX-512 machine loses its upper half. Which registers the caller sees damaged depends on what the compiler saves in isal_deflate() and isal_deflate_stateless() themselves: with mingw-w64 gcc 13, xmm9-xmm14 after isal_deflate() and xmm8-xmm14 after isal_deflate_stateless(); a mingw build on GitHub's Windows runners shows xmm7-xmm14 after isal_deflate_stateless(). Save each register in its own 16-byte slot. The save area is already 10 * 16 bytes. Signed-off-by: Parker Loflin <parker@cronstable.dev>
ptweezy
force-pushed
the
igzip-encode-win64-xmm-save
branch
from
October 21, 2026 21:27
bc4e5ed to
3a6ee3a
Compare
Contributor
|
Thanks! It's merged a33f405 |
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.
On win64,
FUNC_SAVEandFUNC_RESTOREinencode_df_04.asmandencode_df_06.asmsave and restore xmm6-xmm15 with 16-byteMOVDQUatxmm_save_mem_offset + i*8, so each save overwrites the upper half of the previous one, andencode_deflate_icf()returns with the upper 64 bits of xmm6-xmm14 replaced by the low 64 bits of the next register. This PR usesi*16; the save area is already 10 × 16 bytes.Who is affected
Windows builds compressing at levels 1-3 on AVX2 (
encode_deflate_icf_04) and AVX-512 (encode_deflate_icf_06) CPUs. A caller holding a 128-bit vector in xmm6-xmm14 acrossisal_deflate()orisal_deflate_stateless()gets its upper half back corrupted; scalar floats and doubles survive. Which registers are hit depends on the compiler's own saves in those functions: xmm7-xmm14 (stateless) in the CI build below; xmm8-xmm14 (stateless) and xmm9-xmm14 (stateful) with mingw-w64 gcc 13.Output and the Linux (elf64) code do not change.
Testing
isal_deflate_stateless(), xmm7-xmm14 change on master and none with this PR, which also passesmake check.make checkpasses, and xmm6-xmm15 and the callee-saved GPRs stay intact across every_04/_06encoder call and everyisal_deflate()/isal_deflate_stateless()call. On master, every encoder call damages xmm6-xmm14.make checkandtools/check_format.shpass.