Repository navigation
Recompiler: encode direct DXIL with bitcode abbreviations - #3250
Conversation
The direct DXIL writer emitted every record unabbreviated, so each operand took a full 6-bit VBR chunk plus the record header. Define LLVM DEFINE_ABBREV records for the hot function-block opcodes (binop without flags, cast, cmp2, vselect, extractval, 4-byte-aligned load / store, br, call, phi, gep) and for integer / f32 constants, and write the compact form's lookup tables as one CST_CODE_DATA record instead of an aggregate of interned integer constants. The records decode to the same operands, so the module means the same; only its encoding is smaller. Measured on the retail title with an RTX 5070 Ti (numbers in the PR). Ported from the bitcode-encoding part of amd-dev's f089a9d (cherry picked there from 46aecbf, raylitebull, Assisted-by: Antigravity (Gemini 4 Neon High)). Left out here: its dead-constant pruning (main already prunes, 09a65d6) and its IR / compact-form changes, which follow separately. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
merge-check |
KOLESNiii
left a comment
There was a problem hiding this comment.
Static review of e13ccd7f for the stack in the #3041 comparison.
I found no actionable issue in the tested bitcode abbreviation and constant-table encoding changes.
Review assisted by Codex (GPT-6, exact variant unavailable). No new build or GPU run for this review.
|
Test run data for the static review
Local system used for these runs was an RTX 2070 SUPER 8 GB (621.40, wave32), Ryzen 5 3600XT, 32 GB RAM, Windows 11 build 26300, and rustc 1.100.1. Claude Code (Claude Opus 5.5) ran the earlier tests. Codex (GPT-6, exact variant unavailable) checked the artifacts and ran the new build. |
First part of moving amd-dev's direct DXIL size work (
f089a9df, "shrink emitted shaders 4.5x-5.4x") to main, split up as CONTRIBUTING asks. This part changes only how the direct DXIL writer encodes the module. It defines LLVMDEFINE_ABBREVrecords for the most-used function-block records (binop without flags, cast, cmp2, vselect, extractval, 4-byte load / store, br, call, phi, gep) and for integer / f32 constants. The compact form's lookup tables become oneCST_CODE_DATArecord instead of an aggregate of interned integers. The records decode to the same operands as before, so the module means the same thing; it is only smaller.The rest of
f089a9dfcomes in separate PRs: the compact-form micro-blocks and liveness, and the IR optimizations, which build on #1818. On amd-dev's own history, the whole commit took the RTX 5070 Ti's cold pipeline build for the 6 largest compute programs from 31.9 s to 21.4 s. This part alone does not change that much (below): its gain is file size.What is in it
crates/xcl/src/gpu/dxil/bitstream.rs:AbbrevOp,define_abbrev,emit_abbrev,enter_block_with_widthcrates/xcl/src/gpu/dxil/module.rs: the function-block abbreviations (block abbrev width 4) and the constant ones,ConstDef::DataI32/const_data_i32; main's dead-constant pruning (09a65d6) is kept, and the shrink commit's own pruning is left outcrates/xcl/src/gpu/dxil/compact.rs: compact tables throughconst_data_i32crates/xcl/src/gpu/dxil/bitreader_tests.rs: the test reader decodes abbreviated records; newabbreviated_records_decode_to_the_plain_layout;module.rs'ssymtab_namestest helper uses this reader instead of its own, which only read unabbreviated recordsTested
cargo test --workspace --no-fail-fast -- --test-threads=4on e13ccd7: 2605 passed, 4 failed, 49 ignoredgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3:CreateComputePipelineStatereturnsE_OUTOFMEMORY(0x8007000E) on this card, and they fail the same way on main. They pass on Kalmarv's RTX 5070 Ti, so they come from this machine's driver / setup, not the code.no wave64; alsotwo_pass_binds_set_the_shared_view_heap(no heap windows) andpso_measurement_compiles_an_exact_synthetic_record(cannot disable the driver cache)shaders.rpf,xcl shaders --direct --sample 300 --seed 1 --validate, main (b10cc4c) against this PR:95cc13288a27a96e1215 KB to 804 KB,958400d2caf07244612 KB to 415 KBxcl shaders --precompile --only cs --pipelines --records <12 hashes> --threads 1, freshXCL_DXIL_CACHE): 51.3 s on main, 49.3 s here. The driver re-encodes the module, so the smaller bitcode barely changes its compile time.Regression run
main:
this PR:
Not tested
400 + 61 changed lines, about 150 of them tests.
AI use
f089a9df, merged it with main's pruning, wrote the decode test and thesymtab_nameschange, ran the tests, measurements and smoke runs above, and wrote this descriptionf089a9df(raylitebull, cherry-picked from46aecbf7, written with Antigravity (Gemini 4 Neon High))🤖 Generated with Claude Code