Recompiler: guard NULL (125) dests and bridged lane_mask inputs in per-lane lowering #2117
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!2117
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2117"
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?
@Decodere on GitHub · 2026-11-25 04:59 UTC · original
Decodere:fix-1269-perlane-null-and-bridge→main· +190 −23 · 2 files · 1 commits · openWhat is in it
Fixes two correctness bugs in the per-lane lowering (
crates/xcl/src/gpu/recomp/lower.rs) and lane-mask analysis (crates/xcl/src/gpu/recomp/lane_masks.rs):NULL(125) destination & source handling (recomp/lower.rs,recomp/lane_masks.rs):Lower::write_numandLower::write_bitlacked an early return onr == 125. In wave64, mask writes tonull(such asS_AND_B64 null, exec, vcc,S_WQM_B64 null, exec,S_CSELECT_B64 null, ..., and VOP3V_CMP_* null, ...) wrotenum_marker/bit_markertor + 1 = 126(destroyingEXEC), and 64-bit scalar / multi-dword SMEM writes (S_GETPC_B64,S_MOV_B64,S_CSELECT_B64,S_LOAD_DWORD*) wrotesd + 1 = 126. Addedif r == 125 { return; }towrite_numandwrite_bit, guarded the 64-bit scalar and SMEM write sites with!= 125, and excluded125inreads_maskandcmp64.lane_masks.rs, mapped125(null) toSome(FALSE)inmask_src, avoided pushing125intoset(st.regs[125]) onV_CMP_*,saveexec/wrexec, and SALU mask ops while preservingSCCtracking (scc = Some((v, SccKind::Any))) for non-MOV/CSELECTmask ops tonull, and excluded125when detecting tracked mask sources.lane_maskinput clobbering (recomp/lower.rs::bridge):bridge()pushed(Var::S(m), ...)and(Var::S(m + 1), ...)unconditionally after thewholeSGPR loop, overwriting live scalar operands already placed ininputs(for example, wave32V_ADD_CO_CI_U32 v2, vcc_lo, s1, v1, s0clobbereds1with0;SRC0 == SRC2clobbered the scalar addend with1 << lane; andm == 127pushed out-of-rangeVar::S(128)).lane_maskpushes so(Var::S(r), val)is only pushed whenr < 128andVar::S(r)is not already ininputs(in wave32dxil::Lw::lane_ofignoreshi, and a scalar register already present as a number ininputsalready holds its true mask bit for every lane).lane_masks.rs,lower.rs):lane_masks::tests::null_dest_and_source_in_lane_masks: verifiesS_AND_SAVEEXEC_B64 null, vcc+S_OR_B64 s[0:1], null, vccreadsFALSEfornull(keepingMOV2guarded) andS_AND_B64 null, exec, vcc/nullstill tracks maskSCC.lower::tests::null_dest_preserves_exec_and_scc: CPUInterptest covering wave64S_AND_B64, VOP3V_CMP_EQ_U32,S_MOV_B64,S_CSELECT_B64, andS_GETPC_B64tonull(125), verifyingEXECandSCC.lower::tests::bridged_wave32_carry_preserves_scalar_operands_in_dxil: CPU +dxil.dllvalidation test checkinglower_dxil::kernelpreservess1=42(SRC0adjacent toSRC2=s0) ands4=5(SRC0 == SRC2) in the generated DXIL.lower::tests::gpu_null_dest_and_bridged_carry_agree_with_hlsl: CI-WARP-safe (gpu_waves()+dxc::location()) GPU parity test verifying wave32 bridgedV_ADD_CO_CI_U32(lower_dxil::kernel) and wave64 splitNULLdests (lower_dxil::kernel_split) match HLSL on the GPU.Part of #1269
Tested
rustc 1.100.0, DXC1.9.2609.5, release build.6987e496):null_dest_and_source_in_lane_masksfailed (left: [], right: [16]—nullread stalest.regs[125]).null_dest_preserves_exec_and_sccfailed (s126: a mask read as a number—write_bit(125)clobberedEXEC).bridged_wave32_carry_preserves_scalar_operands_in_dxilfailed (adjacent scalar operand s1=42 must not be clobbered by lane_mask).gpu_null_dest_and_bridged_carry_agree_with_hlslfailed (lane 0: v2 (s1 + v0 + cin): left: 0, right: 43).null_dest_and_source_in_lane_masks,null_dest_preserves_exec_and_scc,bridged_wave32_carry_preserves_scalar_operands_in_dxil,gpu_null_dest_and_bridged_carry_agree_with_hlsl): 4 passed, 0 failed, 0 ignored, 0 skipped.XCL_ADAPTER="Microsoft Basic Render Driver"andXCL_ADAPTER=warp): 4 passed, 0 failed (all 3 CPU tests pass; GPU test skips cleanly withno GPU with 32-lane waves).cargo build --release --workspace: exit0.cargo test --release --workspace -- --test-threads=4: 1158 passed, 0 failed, 46 ignored across 21 test binaries, with 25SKIPPEDstderr lines:no wave64(32-lane RTX 4060 hardware)per-lane form: refused(#1426unsupported f16/f32 semantics in per-lane wave32 tests)cannot disable the driver cache (Windows Developer Mode is required)(pso_measurement_compiles_an_exact_synthetic_record)no heap windows(heap_window_out_of_memory_falls_back_to_the_switch_form)Regression run
Paired 60s
scripts/smoke.ps1runs on the same retail title (title: 29640639) and GPU (NVIDIA GeForce RTX 4060):Base (
origin/main,6987e496):This PR (
d758ce8b):No regressions (
1602vs1590frames,14471 MBvs14516 MBpeak commit,60 61 60presents per 2 s,0device removals,0crashes).Not tested
lower_dxil::kernel_split, and wave64 per-lane semantics were verified on the CPU viaInterp.AI use
NULL(125) destination/source and bridgedlane_maskinput-clobbering bugs inrecomp/lower.rsandrecomp/lane_masks.rs, authored the fixes and CPU/GPU regression tests, and ran all build, unit, GPU, WARP, workspace, and paired smoke checks.Fix two correctness bugs in the per-lane lowering and lane-mask analysis: 1. `NULL` (`125`) destination/source handling (`recomp/lower.rs`, `recomp/lane_masks.rs`): - `Lower::write_num` and `Lower::write_bit` lacked an `r == 125` early return, so wave64 mask writes to `null` (such as `S_AND_B64 null, exec, vcc`, `S_WQM_B64 null, exec`, `S_CSELECT_B64 null, ...`, and VOP3 `V_CMP_* null, ...`) wrote markers to `r + 1 = 126`, clobbering `EXEC`, and 64-bit scalar writes (`S_GETPC_B64`, `S_MOV_B64`, `S_CSELECT_B64`, multi-dword `S_LOAD_DWORD*`) wrote `sd + 1 = 126`. Guard `write_num`, `write_bit`, the 64-bit/SMEM write sites, and exclude `125` in `reads_mask` and `cmp64`. - In `lane_masks.rs`, map `125` (`null`) to `Some(FALSE)` in `mask_src`, avoid writing `st.regs[125]` on `V_CMP_*`, `saveexec`/`wrexec`, and SALU mask ops while still updating `SCC` on non-`MOV`/`CSELECT` mask ops to `null`, and exclude `125` when detecting tracked mask sources. 2. Bridged `lane_mask` input clobbering (`recomp/lower.rs::bridge`): - Pushing `(Var::S(m), ...)` and `(Var::S(m + 1), ...)` unconditionally after the `whole` SGPR loop overwrote live scalar operands in `inputs` (e.g. wave32 `V_ADD_CO_CI_U32 v2, vcc_lo, s1, v1, s0` clobbered `s1` with `0`, `SRC0 == SRC2` clobbered the scalar addend with `1 << lane`, and `m == 127` pushed out-of-range `Var::S(128)`). - Only push `(Var::S(r), val)` when `r < 128` and `Var::S(r)` is not already present in `inputs`. Add CPU, DXIL-validation, and CI-WARP-safe GPU parity tests covering both bugs (wave32 bridged `V_ADD_CO_CI_U32` and wave64 `NULL` dests). Part of #1269 Assisted-by: Google Antigravity (Gemini 4 Neon)@DarkPanda69 on GitHub · 2026-11-25 05:24 UTC · original
Tested:
gpu_null_dest_and_bridged_carry_agree_with_hlslpasses on an AMD D3D12 driver and on an RTX 3060.gpu::filter: 588 passed, 2 failed, 22 ignored. The 2 failures are the AMD fuzz seeds 722 and 1599 tracked in #2115, which fail the same way onmain.Head
d758ce8applied onmain6020a33,cargo test -p xcl --lib -- gpu:: --test-threads=4withXCL_ADAPTERset to each card.The new test runs its wave32 case and the split form of its wave64 case (
kernel_split,split_wave64: true), so even on the 9070 XT it does not run the NULL-dest case in native 64-lane waves. This is an AMD driver result, not the native wave64 check the PR lists as untested.Not tested: native wave64 per-lane, retail runs.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@futurepro62 on GitHub · 2026-11-25 05:18 UTC · original · edited 2026-11-25 05:27 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
d758ce8(on its base6987e49).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1146 passed, 0 failed, 44 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.null_dest_and_source_in_lane_masks,bridged_wave32_carry_preserves_scalar_operands_in_dxil,null_dest_preserves_exec_and_scc,gpu_null_dest_and_bridged_carry_agree_with_hlsl.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1157 passed, 0 failed, 46 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main6020a33too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@JoaoPauluu on GitHub · 2026-11-25 06:12 UTC · original
A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, not the native-Windows path: this PR's 4 new tests pass, none skipped.
Tested
x86_64-pc-windows-gnu.d758ce8as it is (merge base withmain6987e49), no uncommitted changes. The lib test binary runs under Wine, one test per process.null_dest_and_source_in_lane_masks: okbridged_wave32_carry_preserves_scalar_operands_in_dxil: okgpu_null_dest_and_bridged_carry_agree_with_hlsl: oknull_dest_preserves_exec_and_scc: okNot tested
AI use
@DavidM1911 on GitHub · 2026-11-25 06:17 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.