Recompiler: fix NULL dest, B32 SAVEEXEC, and MIMG TFE/LWE in upper_lanes #2126
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2136"
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-25T05:48:21Z.
What is in it
Fixes three soundness bugs in wave64-on-wave32 upper-lane analysis (
crates/xcl/src/gpu/recomp/upper_lanes.rs):SDST == 125(NULL) on 64-bit / multi-dword SGPR writes clobberedEXEC_LO(s126) andEXEC_HI(s127):step(), 64-bitSAVEEXEC/WREXECwrites and 64-bitENC_SOP1/ENC_SOP2writes calledst.set(dst + 1, ...)even whendst == 125(NULL), overwritingst.s[126](EXEC_LO) — for example,S_OR_SAVEEXEC_B64 null, -1overwroteEXEC_LOwith savedEXEC_HI(Word::Zero). Guarded both paths withdst != 125and avoided readingdst + 1inCMOVwhendst == 125.sgpr_outputs(), generic SGPR outputs (v < 128) and SDWAV_CMP_*outputs (SD == 1) pushedNULL(125) with multi-dword sizes, causing VOP3/SDWAV_CMP_* null, ...to clobbers126(EXEC_LO) andS_LOAD_DWORDX4 null, ...to clobber boths126ands127(EXEC_HI). Skipped125in both output paths.SAVEEXEC/WREXECreadSSRC0viast.src64()instead ofst.src32():st.src64()maps124(M0) and127(EXEC_HI) toWord::Any, losing trackedWordstate on instructions such asS_AND_SAVEEXEC_B32 s0, exec_hiandS_OR_SAVEEXEC_B32 s0, m0. Now usesst.src32(d, fv("SSRC0"))when!b64, matching theENC_SOP1/ENC_SOP2path below it.vgpr_writes()missed the 5th VGPR (vdata + 4) onMIMGloads/samples/gathers withTFE = 1orLWE = 1:VDATA, so whenDMASK = 0xF(orIMAGE_GATHER4) withD16 = 0andTFE = 1orLWE = 1gaven = 5,w.truncate(5)still returned only 4 registers and leftvdata + 4untracked (allowing stale constants invdata + 4to survive an image load underWWM). Rebuildswas(base..(base + n).min(256)).collect().Adds three deterministic CPU unit tests in
gpu::recomp::upper_lanes::testscovering all three bugs.Part of #336
Tested
Hardware/toolchain: Windows 11 (26200), NVIDIA GeForce RTX 4060 (32-lane waves, driver 621.14), DXC
1.9.2609.5 (01b62ad4), Rust1.100.0.null_dst_multi_dword_writes_preserve_exec:Const(0)instead ofConst(u32::MAX);saveexec_b32_reads_32bit_special_sources:Unknowninstead ofConst(0);mimg_tfe_and_lwe_write_fifth_vgpr:[4, 5, 6, 7]instead of[4, 5, 6, 7, 8]).cargo test --release -p xcl --lib gpu::recomp::upper_lanes::tests::: 12 passed, 0 failed, 0 ignored (pure CPU, CI WARP-safe).cargo test --release -p xcl --lib gpu::recomp::partition::tests::: 44 passed, 0 failed, 0 ignored (pure CPU).cargo build --release --workspace: exit 0.cargo test --release --workspace -- --test-threads=4: 1157 passed, 0 failed, 46 ignored across 21 test suites, with 25 pre-existing runtimeSKIPPEDlines (23 native wave64 / unsupported per-lane lowering skips on 32-lane RTX 4060, 1 Windows driver-cache skip, 1 heap-window skip; 0 new skips).Regression run
Paired 60-second
scripts/smoke.ps1runs on the same retail title build (29640639) from cleanorigin/main(6e1e2be) and this branch (f1e281b):Base (
origin/main):PR (
fix-336-upper-lanes-soundness):Not tested
upper_lanesis specifically the wave64-on-wave32 forward analysis and all new tests are deterministic CPU unit tests).AI use
Drafted with Google Antigravity (Gemini 4 Neon) and verified locally by reproducing all three failures before the fix, verifying
upper_lanes::testsandpartition::tests, running the full release workspace test suite, and completing the paired 60-second smoke run above.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T06:49:16Z.
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!
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T08:02:28Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-28T08:24:34Z.
Tested
Exact
f1e281b2e13cd9fc4efe5ba87410049b38e25f7aon native Windows 11 build 26200.9974, Ryzen 7 3800X, Rust 1.100.1 MSVC x64 debug. The pinned libtest used a verified archive with one private test inserted inupper_lanes.rs. All 332 original files matched their Git blobs after excluding the fixture.I ran
<libtest.exe> <filter> --exact --nocapture --test-threads=1separately for two CPU tests undergpu::recomp::upper_lanes::tests.packed_d16_image_sample_tfe_invalidates_only_statusverified the packed D16 analyzer boundary. With TFE set, the seeded v6 fact was invalidated and adjacent v7 was preserved. With TFE clear, both seeds were preserved.mimg_tfe_and_lwe_write_fifth_vgprexercised the fifth-register fix and passed.2 passed, 0 failed, 0 ignored, 0 runtime skips. Both native processes exited 0, with 1,127 filtered out per invocation.
Not tested
GPU execution, the pre-fix revision, retail smoke, and the full workspace suite.
AI use
T3 Code through the Codex harness (
gpt-6.2-sol) verified the provenance and executable, ran the tests, and wrote this report.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-30T00:45:09Z.
NVIDIA and AMD full-suite run, to go with the reports above by JJAutoCompare, since none of them names a GPU. Tested exact head
f1e281b2(on its base6e1e2be).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace --no-fail-fast -- --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::recomp::lower_dxil::tests::bridged_dpp_agrees_with_hlsl_on_the_gpu --skip hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap --skip gpu::dxil::fuzz_tests: 1145 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_dst_multi_dword_writes_preserve_exec,saveexec_b32_reads_32bit_special_sources,mimg_tfe_and_lwe_write_fifth_vgpr.XCL_ADAPTER=radeon),cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 --skip two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs: 1156 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 main53e85fb1too, 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,bridged_dpp_agrees_with_hlsl_on_the_gpu(no wave64 on this card) andtwo_pass_binds_set_the_shared_view_heap(heap windows are opt-in,XCL_HEAP_WINDOWS=1) fail the same way;gpu::dxil::fuzz_testsstays skipped as in earlier runs (seeds 70, 545, 1019 and 1507 failedCreateComputePipelineStatewithE_OUTOFMEMORYon this card; they passed on this main's baseline). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6).two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsfails on main too, since #2959 (#3441). (Edited: this line first named the wrong merge.) The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:27:27Z.
Triage (#1607) – head
f1e281bNo open PR makes these fixes, and main's
upper_lanes.rsstill has the NULL-destination writes,src64for B32 SAVEEXEC, andw.truncatefor MIMG TFE/LWE. #1616 and #3380 also editupper_lanes.rs, but for S_MOVRELSD and writelane slots, which do not overlap.No problems found in the diff. The new
w[0]is guarded by!w.is_empty().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.