Recompiler: propagate half-local masks through 64-bit bitwise ops and EXEC #1875
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1875
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1875/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@certified-retart on GitHub · 2026-11-24 22:30 UTC · original
certified-retart:recomp/x64-masks-bitwise-exec→main· +530 −37 · 5 files · 1 commits · closed without mergingPart of #1269, #1598, and #675.
In split-wave64 mode (NVIDIA / 32-lane wave GPUs),
x64_masks::whole_live_outpreviously treated every scalar read of a 64-bit mask register—and every read or write ofEXEC—as requiring the whole 64-bit mask across both 32-lane halves. As a result, anyv_cmp_*/v_cmpx_*feeding a 64-bit bitwise mask chain (s_and_b64,s_or_b64,s_xor_b64,s_andn2_b64,s_not_b64,s_mov_b64,s_cselect_b64,s_*_saveexec_b64,s_*_wrexec_b64, etc.) or feedingEXECfor branchless predication emitted a full cross-halfxcl_x_ballot(LDS write + twoGroupMemoryBarrierWithGroupSyncbarriers + LDS read) even when neither the resulting mask nor itsSCCwas ever observed across halves.Summary of changes
crates/xcl/src/gpu/recomp/x64_masks.rs:SCCwhole-liveness (bit 125, stripped before returning fromwhole_live_out) and propagate half-local liveness backward through bit-parallel 64-bit SALU ops (S_MOV_B64,S_CMOV_B64,S_NOT_B64,S_WQM_B64,S_CSELECT_B64,S_{AND,OR,XOR,ANDN2,ORN2,NAND,NOR,XNOR}_B64,S_*_SAVEEXEC_B64, andS_*_WREXEC_B64) on even-aligned 64-bit pairs.s_{2k}in half 0,s_{2k+1}in half 1), bit-parallel ops preserve half-exactness when neither the destination pair nor a liveSCCis observed whole; whenever either is whole-live (or whensrc_vccz/src_execz/SCCis read), all inputs are forced whole.EXECwhole-liveness with demand-drivenEXECliveness:EXECis marked whole-live at cross-half observations (S_CBRANCH_EXECZ/NZ,src_execz,V_READFIRSTLANE_B32,DS_BPERMUTE_B32,DS_PERMUTE_B32,S_MOVREL*, non-bit-parallel scalar reads ofEXEC, indirect jumps, andend_reads_all), while in-half reads (act(), DPP,V_PERMLANE(X)16,DS_SWIZZLE) remain half-local.pub fn uses(d: &Decoded)unchanged forlane_masksandrecomp::lower.gpu::recomp::x64_masks::teststo 19 unit tests covering bit-parallel propagation,SCCsoundness,SAVEEXEC/WREXECpatterns,EXECcross-half reads (S_CBRANCH_EXECZ,V_READFIRSTLANE_B32,DS_BPERMUTE_B32), and loop/back-edge propagation.crates/xcl/src/gpu/recomp/emit.rs&crates/xcl/src/gpu/dxil/lower.rs:write_maskto use the half-local ballot when writingEXEC(n <= 126 && n % 2 == 0instead ofn < 126) wheneverEXECis not whole-live after the write.crates/xcl/src/gpu/dxil/kernel.rs:TRANSLATOR_VERSIONfrom7to8.crates/xcl/src/gpu/recomp/tests.rs:gpu_split_wave64_bit_parallel_and_exec_masksverifying both HLSL and Direct DXIL execution on GPU: bit-parallel mask chains, branchlesss_and_saveexec_b64/s_andn2_b64if/else, restored outerEXEC, half-localv_cmpx, and cross-half soundness with upper-half-only active lanes (45..63) forSCC,v_readfirstlane_b32,s_cbranch_execz, andds_bpermute_b32.Measured impact (split-wave64 compute shaders)
Across 200 retail compute shaders (
>= 64 KBHLSL) exported with--split 1:xcl_x_ballotcalls: 10,286 → 6,734 (-3,552 exchanges, -34.5%, removing 7,104 group memory barriers).xcl_x_ballot_localcalls: 7,725 → 11,277.Sample large wave64 compute shaders compiled with DXC (
-E main -T cs_6_6 -HV 2021 -O1,dxcompiler 1.9.2602.17):xcl_x_ballot(main → PR)Direct DXIL sweep with
XCL_FORCE_SPLIT_WAVE64=1(--direct --sample 1000 --max-bytes 65536 --validate): 977 / 977 (100.0%) translated and validated bydxil.dll 1.9.2602.17with 0 validator errors, 0 panics, and 0 timeouts.Regression run
Baseline (
origin/main):PR (
recomp/x64-masks-bitwise-exec):Tested
dxil.dll1.9.2602.17 (Windows SDK 10.0.26100.0), Rust MSVC toolchain.cargo test --workspace -- --test-threads=4— full suite passed (0 failed), including all 19gpu::recomp::x64_masks::testsunit tests and the new GPU testgpu_split_wave64_bit_parallel_and_exec_masks.XCL_DIRECT_DXIL=1 cargo test -p xcl --lib "gpu::dxil::"andgpu_split_wave64— 100/100 Direct DXIL tests (including fuzz suites) and 6/6 split-wave64 GPU tests passed.XCL_FORCE_SPLIT_WAVE64=1, 1,000 sampled records,<= 64 KB): 977/977 validated with 0 errors.scripts/smoke.ps1) onorigin/main(689f2db) vs PR head (b478b4e).Not tested
CreateComputePipelineStatetiming via--measure-pso(Windows Developer Mode is disabled on this machine).AI use
@certified-retart on GitHub · 2026-11-24 22:30 UTC · original
Closing in favor of #1596 and #1597, which already cover split-wave64 EXEC and bitwise mask propagation (I missed them in the open PR list before opening this). Note: if #1596 wants Direct DXIL parity as well, \crates/xcl/src/gpu/dxil/lower.rs\ has the same
< 126\ check in \write_mask\ as \emit.rs.
@DavidM1911 on GitHub · 2026-11-25 01:45 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Pull request closed