Recompiler: guard NULL (125) dests and bridged lane_mask inputs in per-lane lowering #2107
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-25T04:59:58Z.
What 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.Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T05:24:21Z.
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.
Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-25T05:18:36Z.
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
Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-25T06:12:04Z.
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
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T06:17:41Z.
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!
upstream-sync referenced this pull request2026-11-25 18:04:27 +00:00
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T14:56:59Z.
merge-check claim
head:
d758ce8b2cImported from ivall/xcl. Originally posted by throny on 2026-11-28T15:17:06Z.
merge-check
base:
309c3ec5head:
d758ce8b2cmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2145 passed, 1 failed, 48 ignored (26 SKIPPED lines). Base alone at
309c3ec5: 2142 passed, 0 failed, 48 ignored. The failure is one of this PR's own new tests, gpu::recomp::lower::tests::bridged_wave32_carry_preserves_scalar_operands_in_dxil ("adjacent scalar operand s1=42 must not be clobbered by lane_mask"). Rerun alone: it fails twice on the merge result and passes on this PR's headd758ce8bwithout main (merge base6987e496). It is a CPU-only test of the generated DXIL text, so this is not about the GPU here.review: the code reads as correct and the merge itself is clean (main renamed a helper next to one of the PR's lines; the three-way merge keeps main's name). The real fix, writers of a 64-bit value with the null register as destination no longer touching the register after it, is not on main yet; parts of the rest are (main already reads register 125 as false and skips it in two paths). The blocking point is only the test above: on current main either the test's expectation or the code path it checks no longer fits what main generates, and that needs the author's look after a rebase. Minor: a few guards are now redundant with the new early return.
performance: no runtime cost. It changes per-lane translator sources only: testers who use the per-lane path re-translate those entries once.
verdict: not yet: rebase onto main and make the PR's own test bridged_wave32_carry_preserves_scalar_operands_in_dxil pass there; I will re-check the new head.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T01:57:41Z.
merge-check claim
head:
d758ce8b2cImported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T02:12:47Z.
merge-check
base:
9335bc0d86head:
d758ce8b2cmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2804 passed, 2 failed, 50 ignored; SKIPPED: 28 (22 no wave64 on this GPU; 3 per-lane form refused (#1426 semantics); 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: (1) this PR's own new test gpu::recomp::lower::tests::bridged_wave32_carry_preserves_scalar_operands_in_dxil (lower.rs:4791, "adjacent scalar operand s1=42 must not be clobbered by lane_mask"), not on main; (2) hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, fails on base too. Main alone at
9335bc0: 2800 passed, 2 failed, 50 ignored (the same standin test, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs in its warm child run, which passed on the merge result). The PR's other three new tests pass, including gpu_null_dest_and_bridged_carry_agree_with_hlsl on the GPU (wave32 and split wave64).review: the failing test is stale, not the fix. It looks for "zext i32 42 to i64" in the DXIL, but since
aa63928("keep VALU carry arithmetic in i32", adapted from #2565, on main through #2959) the carry is lowered as two i32 operations and an unsigned compare: the DXIL in the failure message has "add i32 42, %30" and "add i32 5, %30", so both operands reach the add unclobbered. The GPU test of the same program agrees: every lane gives 42 + lane + carry-in and 5 + lane + carry-in, matching HLSL. That explains the first check's finding (passes on the PR's own base, fails merged). The fix itself reads right: write_num / write_bit drop writes to register 125, and the 64-bit pair writers (S_GETPC_B64, S_MOV_B64, S_CSELECT_B64, SMEM loads) skip both halves, which is what keeps EXEC_LO (126) intact, so those guards are not redundant with the early return; lane_masks reads null as FALSE and never records it as a destination; the lane-mask inputs no longer overwrite an SGPR the instruction also reads whole. Overlaps without duplicating: #1864 (on main) handles null as a source in the same lowering; #2136 handles the null destination in upper_lanes.rs; #2833 touches the same files for SRC_SCC.performance: none at run time; per-lane translations of programs with these instructions change once.
verdict: not yet: update bridged_wave32_carry_preserves_scalar_operands_in_dxil to main's i32 carry lowering (e.g. look for "add i32 42," and "add i32 5,"); the fix itself has no finding.
hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; diff review by Claude Opus 5.5.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:24:47Z.
Triage (#1607) – head
d758ce8Part of this is on main now:
15fff3b4(#1864) reads NULL as a FALSE mask inlower.rs, skips NULL in the lane-mask inputs and the saveexec destination, and574bda48passes the real SGPRs for a wave32 bridged carry. Still missing on main:lane_masks.rs:mask_srctreats 125 as a register, andS_MOV_B64/S_CSELECT_B64/S_GETPC_B64with SDST = NULL still writesd + 1= s126 (EXEC_LO).The PR conflicts and needs a rebase down to those parts. #2136 fixes the same class of NULL-destination bug in
upper_lanes.rs, a different module.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.