nix: apply patched wasm-opt (LSB-test → ctz) to RTS wasm files#5967
Draft
nix: apply patched wasm-opt (LSB-test → ctz) to RTS wasm files#5967
Conversation
Add ggreif/binaryen (branch gabor/lsb-if-ctz-flake) as a flake input, exposing a patched wasm-opt that folds LSB-test `i32.and X 1` patterns into `i32.ctz` (WebAssembly/binaryen#8562). Apply it to the non-debug RTS variants in installPhase, yielding ~0.2% instruction count reductions in GC-heavy benchmarks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… check) The overrideAttrs build was failing because pkgs.binaryen's preConfigure expected test/spec/testsuite to exist. Updated flake disables tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fference) macOS nix computes a different NAR hash than Linux for the same GitHub commit. Update to the hash Linux CI computes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
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.
Summary
wasm-optimplementing the optimization from WebAssembly/binaryen#8562nix/rts.nix, runswasm-opt --optimize-instructionson the three non-debug RTS variants duringinstallPhaseThe optimization
The patched
wasm-optfolds LSB-test patterns common in the RTS intoi32.ctz:These patterns appear 26–105 times per RTS variant, primarily in the
is_skewed/is_scalarpointer-tagging checks in the GC hot path.Benchmark results (EOP RTS, gross effect of
--optimize-instructions)heap-32(run 1)heap-32(run 2)heap-64(run 1)heap-64(run 2)bignumcandid-subtype-costNumbers are gross effects (other rules in
--optimize-instructionsalso contribute).Notes
🤖 Generated with Claude Code