Recompiler: keep scalar state across proven per-lane paths #1912
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!1912
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1912"
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?
@Kalmarv on GitHub · 2026-11-24 23:00 UTC · original
Kalmarv:per-lane-stale-main→main· +272 −21 · 4 files · 4 commits · openPart of #1269. Builds on #1866 (merged). Four commits, rebased onto
maincbfc67bc: a test for SCC from the complemented SAVEEXEC forms (review point 3; it was meant for #1866, which merged first), this change, the dominance-walk fix from review point 1, and a fix for an interaction with #1888.What is in it
A per-lane read can use a dominating write when the reader stays inside every loop containing that write. For a native wave32 loop header, the first iteration sees the entry value and every returning lane has passed its sole latch. The proof excludes enclosing loops that could carry an earlier write back to the entry. On the sole empty-EXEC exit of a WREXEC self-loop, the final SCC and saved mask are both zero for the entire wave.
crates/xcl/src/gpu/recomp/lower.rs,lane_masks.rs: the dominance proof for reads inside loops and the WREXEC exit case.crates/xcl/src/gpu/recomp/lower_dxil.rs: GPU and CPU tests.README.md: one line on the new per-lane loop case.c4093f4, after #1888 merged: its SCC check rejected the shrinking wave32 loop, because the analysis lost the fact that EXEC is empty on the loop's exit. The analysis and the lowering now share one check for aWREXEC_B32self-loop ending inS_CBRANCH_EXECNZ. On its sole fallthrough exit the copied mask is zero and SCC is uniformly false, so a later scalar read is safe.ANDN1arm in the mixed-mask list is removed, with a CPU test ofS_ANDN1_SAVEEXEC_B32andS_ORN1_SAVEEXEC_B32SCC.Tested
33b1b33e,6a760ae4raises native per-lane translation from 316 to 427 of 2,689 compute programs using four switch-selected memory windows. All 111 new admissions were previously refused for a stale value. Stale-first refusals fell from 154 to 43. The 316 previously accepted programs retained their DXIL byte counts. The 19 slowest remain refused by the whole-wave branch check, so none has per-lane DXIL to time.c4093f4, after the rebase ontocbfc67bc:cargo test --workspace -- --test-threads=4(debug): 1187 passed, 1 failed, 46 ignored.xcllibrary tests (four threads, nothing filtered): 1131 passed, 1 failed, 26 ignored.hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa, which fails onmainitself since #1991 (see the note there).lower.rs:wave_brancheskeeps #2203'sir.can_wave_branch()and SCC liveness, andanalyze_brancheskeeps this PR's fifth argument.5d0c1f0:cargo test --release --workspace -- --test-threads=4reported 963 passed, 0 failed and 43 ignored. Twelve tests printed 22 runtime skip messages for unsupported hardware or unimplemented paths. The new GPU fixtures ran with DXC 1.9 and no skip.Regression run
scripts/smoke.ps1, the same retail title for 60 s each, one after the other on the machine under Tested, release builds from clean trees.maincbfc67b(this PR's base):this PR,
c4093f4:PR vs
main: 1298 / 1312 frames (99 %), peak commit 27446 / 26713 MB (103 %); device removals 0 and crashes 0 on both runs.Both runs use default settings, nothing else running.
Not tested
5d0c1f0).AI use
OpenAI Codex (GPT-6.2) wrote the change and the tests and ran the suite and the pack count. Claude Code (Claude Opus 5.5) edited this description and opened the PR.
🤖 Generated with Claude Code
@eizispark on GitHub · 2026-11-24 23:27 UTC · original
Hardware test report — commit
661f7fdVerified
661f7fdad2d39368e875a678535a7cb13c5ecd5d(branched frommain689f2db477c3c062cf162649781640ef8a977c18, clean merge with currentmain20cf130): pass (0new failures vsmain689f2db).Tested
32.0.32015.16001), 32 GB RAM,rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smokecargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads:976 passed, 2 failed, 45 ignored(8 skipped), vsmain689f2db972 passed, 2 failed, 45 ignored(8 skipped) on this adapter:--skip gpu::dxil::msaa_tests::gpu_direct_msaa_image_loadsavoids the pre-#1900#1679amdxc64.dll0xc0000005crash on the689f2dbbase, and the 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722,gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3seed 1599) are pre-existing on689f2db;0new failures8 skipped: 6gpu::recomp::lower_dxil::testsf16/f32 direct-DXIL per-lane cases refused where#1426semantics differ from the console's;shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode required,0x887A002D);heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows50/50gpu::recomp::lower::testsandgpu::recomp::lower_dxil::testspassed on RX 9070 XT — includinga_value_written_in_a_lane_region_is_read_in_it_past_an_inner_if,the_latch_counter_can_still_be_stale_after_the_loop,a_branch_on_a_mixed_mask_matches_the_hlsl_path_on_the_gpu,shrinking_loops_agree_with_the_hlsl_path_on_the_gpu, andREGION_DIAMONDGPU runs — along with native RDNA4 wave64 GPU tests (gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,console_wave64_compute_through_the_pso_hook_dispatch_and_read_back)Regression run (
scripts/smoke.ps1, 60 s, warm shader/driver cache)main(689f2db477c3c062cf162649781640ef8a977c18):PR (
661f7fdad2d39368e875a678535a7cb13c5ecd5d):Not tested
XCL_DIRECT_DXIL=1+XCL_PER_LANE=1past the menusAI use
@Kalmarv on GitHub · 2026-11-24 23:40 UTC · original
@ruipedro-pinheiro thanks for the careful read. On the four points:
dominates: agreed, we'll stop onidom[b] == brather than on block 0.We'll reply here with the new heads.
AI use: Claude Code (Claude Opus 5.5) wrote this.
@Kalmarv on GitHub · 2026-11-24 23:47 UTC · original
@ruipedro-pinheiro the review fixes are pushed. This PR is now
177785a, on #1866's new headc61f53d.dominates: both dominance walks now stop at the root of the dominator tree, the block whose immediate dominator is itself, rather than at block 0, and they handle unreachable blocks. A new CPU test has an entry block that isn't block 0.Lanes::new(lane_masks.rs:418) rejects a backward edge whose target doesn't dominate its source, and lowering (lower.rs:1175) returns that error before it reads any loop body. The existing two-entry-cycle CPU test (lane_masks.rs:1070) checks that exact refusal.S_ORN1_SAVEEXEC_B32already took the EXEC-specific path (lane_masks.rs:519-526), which sets SCC from the new mask. The plainANDN1arm next to it was unreachable, so it's removed. A new CPU test on #1866 covers both complemented SAVEEXEC forms with a numeric input and EXEC restored before the SCC branch.cargo test --release -p xcl --lib -- gpu::recompon an RTX 5070 Ti: 267 passed, 0 failed, 18 ignored on177785a, and 263 / 0 / 18 onc61f53d. The 21 skip notices are 18 native wave64 and 3 unsupported wave32 f16 cases. Regression pairs on the new heads are queued.AI use: OpenAI Codex (GPT-6.2) wrote the fixes and the tests and ran them; Claude Code (Claude Opus 5.5) wrote this.
@Kalmarv on GitHub · 2026-11-24 23:49 UTC · original
Correction to the head above: #1866 was merged at
438d420before the SAVEEXEC test reached it, so that commit (4c524ec, "cover SCC from complemented SAVEEXEC forms") is now part of this PR. Rebased ontomain62265d3(clean): head5d0c1f0, three commits (the SAVEEXEC test, this change, the dominance fix). Pairs on the new head are queued.AI use: Claude Code (Claude Opus 5.5) wrote this.
@Kalmarv on GitHub · 2026-11-25 00:45 UTC · original
On #1912 at
5d0c1f0b, we compared 97 of the 111 new admissions on an RTX 5070 Ti, with one full workgroup per seed (191201,191203,191211). All 44 native-wave32 programs matched. Of 53 programs run as split wave64, 51 matched and two differed on all three seeds. Of the 95 matches, 39 changed at least one output word and 56 left the initialized outputs unchanged. Another 13 programs refused split lowering and one failed split PSO creation.The first differing word in each of the six runs was a texture W component. HLSL stored
0x80000000(−0) and per-lane stored0x00000000(+0). On seed191201,12c2b3c6c3298a43first differed at texture slot 14, word 3, and3617dc5cc417241aat slot 47, word 195. The scalar buffer descriptors had zero stride and byte limits of 42 and 40 respectively, so loading at byte offset 52 supplied0x00000000in both replays.In
3617dc5cc417241a, the W stored at PC0x10ccomes fromV_SUB_F32at0x100. In12c2b3c6c3298a43, the store at0x2ectakes W fromV_MAX_F32at0x2e4, following aV_SUB_F32at0x2c4. In XCL's default round-to-nearest-even mode, +0 minus +0 gives +0, and RDNA2 takes +0 as the maximum of opposite-signed zeros. Neither program writes the FP mode. The original console launch mode remains unverified. AMD RDNA2 ISA, §§6.4 and 12.7The HLSL path gives DXC an ordinary
0.0 - x, which compiles here tofsub fast float -0.0, x. Per-lane DXIL preserves the positive left zero. The same instruction-level difference occurs in17a2587e8c0c4817, already accepted on main62265d3bbefore #1912. This explains the first-word sign difference under XCL's modeled mode and places it in the existing HLSL reference. The other differing words still need classification.@eizispark, could you run the 67 native-wave64 rows on your RX 9070 XT with the default seeds and post the summary from
results.csv, including any mismatches or unavailable rows, your driver and DXC version? Native-wave64 replay kit and instructionsAI use: Claude Code (Claude Opus 5.5) and Codex helpers built the replay harness, ran the readbacks and the DXC check on our machine, and wrote this comment.
@DavidM1911 on GitHub · 2026-11-25 02:15 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.@JJAutoCompare on GitHub · 2026-11-25 03:33 UTC · original
Arc A770 verification for PR #1912
PR #1912 was open at
5d0c1f0b8a802712e9542f0ffa269d9e36b6747fbefore and after testing. The assigned checkout was clean and detached at that same commit on both checks. I found no equivalent Arc A770 report in the PR discussion or GPU-results issue #42.Tested
x86_64-pc-windows-msvc, unoptimized test profile. The GPU test logged DXC 1.9.2609.5 (01b62ad4) and DXIL 1.9.2609.5 from%LOCALAPPDATA%/XclTooling/dxc-1.9.2609/bin/x64.cargo test --locked -p xcl --lib --no-runcompleted outside the Arc lock. UsedCARGO_BUILD_JOBS=2,CARGO_INCREMENTAL=0,CARGO_PROFILE_DEV_DEBUG=0,CARGO_PROFILE_TEST_DEBUG=0,CARGO_TARGET_DIR=L:/XclTooling/pr1778-2e2ee55-20261125-020159/target,XCL_ADAPTER=A770andXCL_DXC_DIRpointing at the DXC path above.TEMPandTMPpointed at the private run directory'stempsubdirectory.crates/xcl. The CPU ran outside the Arc lock. The GPU invocation ran inpowershell.exe -NoProfile -ExecutionPolicy RemoteSignedwith the shared Arc wrapper.v1and the WREXEC loop's empty-EXEC exit produced11inv2(128 value assertions across both cases and both paths). The Arc wrapper logged lock release.SKIPPEDline. Total 2 passed, 0 failed, 0 ignored, 0 skipped.Not tested
AI use
@Kalmarv on GitHub · 2026-11-25 12:00 UTC · original
Thanks for reading it again. All four points were raised on the earlier head, and at
c4093f4they stand as follows (reply with the details: #1912):dominatesstops at the root of the dominator tree (idom[b] == b), not at block 0, and skips unreachable blocks (lane_masks.rs:307).dominance_ends_at_the_entry_even_when_it_is_not_block_zero(lane_masks.rs:1148) has an entry that isn't block 0.Irreducible cycles never reach the check.
Lanes::newreturns"irreducible control flow"(lane_masks.rs:447) for a backward edge whose target doesn't dominate its source. Lowering returns that error before it builds any loop body (lower.rs:1092).unsupported_control_flow_is_refusedasserts it on a two-entry cycle (lane_masks.rs:1166).ORN1:
S_ORN1_SAVEEXEC_B32takes the EXEC path, which sets SCC from the new mask. The plain list has bothANDN1andORN1(lane_masks.rs:535-536). The CPU test atlower.rs:3361runs both complemented SAVEEXEC forms.The 111 programs: the random-input comparison is at #1912. It covered 97 of them on
5d0c1f0, on an RTX 5070 Ti with three seeds.0.0 - x. Main already has the same difference in a program it accepts. Their other differing words are not classified yet.That comparison predates the rebase onto
cbfc67b. The only change in the rebase is one hunk inlower.rsthat keeps #2203'scan_wave_branch()condition alongside this PR's argument, so I haven't rerun it.AI use: Claude Code (Claude Opus 5.5) checked each point against
c4093f4and wrote this reply.@DavidM1911 on GitHub · 2026-11-26 00:42 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
@Kalmarv on GitHub · 2026-11-26 01:00 UTC · original
I'm closing and reopening this right away only to rerun CI on today's
main(b49be18). The failedBuild and test(merge with themainof 11-25 about 10:45Z) failed inhle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa("format 85 kept"). This PR doesn't touch that file, andmain's CI has been green since then. The headc4093f4merges intob49be18without conflicts.AI use: Claude Code (Claude Opus 5.5) read the CI log, checked the merge with
git merge-treeand wrote this.@thehollowedone on GitHub · 2026-11-24 23:30 UTC · original · edited 2026-11-26 01:12 UTC
Updated check on c4093f4 (26 Nov). Windows 11 build 26300, RTX 3080 Ti / driver 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11. Synthetic tests only.
Tested
cargo build --offline --locked --workspacepassed. The checked-inshrinking_loops_agree_with_the_hlsl_path_on_the_gpucomparison passed on the GPU (1 passed, no skip), as did the two focused empty-loop/latch regression tests (1 passed each, no skip).cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4reported 1,187 passed, 1 failed, 46 ignored, with 24SKIPPEDnotices. The failure was the unrelated D3D12 resource-format testpc_resource_desc_strips_uav_on_unsupported_formats_and_msaa(format 85 kept); this PR does not change its file.b49be18locally, without committing. The merge had no conflicts.cargo build --offline --locked --workspacepassed, and the same full suite reported 1,441 passed, 0 failed, 47 ignored, with 25SKIPPEDnotices. The D3D12 format test and the checked-in GPU shrinking-loop comparison both passed on the integration. This checks the current merge result; it does not change the PR branch.Not tested
AI use
Earlier check on 661f7fd: an additional synthetic, production-translator fixture selected per-lane DXIL for the latch and empty-EXEC SCC cases; the stale counter case stayed per-instruction. Selected DXIL and HLSL matched the expected outputs on two native wave32s. That fixture was local and is separate from the checked-in tests above.
@futurepro62 on GitHub · 2026-11-26 05:54 UTC · original
NVIDIA and AMD full-suite run of head
c4093f4c, on its own basecbfc67band merged with currentmainb49be183, to go with the reports above by thehollowedone, since none of them covers AMD. On its base, the 2 failures come from changes made onmainafter that base (#2245 andea088a5); merged withmain, both cards pass. The bare-head runs come first.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: 1120 passed, 1 failed, 24 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.hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa. (stale on this base, fixed onmainby #2245; see the merged run below)dominance_ends_at_the_entry_even_when_it_is_not_block_zero,complemented_saveexec_replaces_the_previous_uniform_scc,a_value_written_in_a_lane_region_is_read_in_it_past_an_inner_if,empty_wrexec_loop_repairs_the_mask_and_scc_only_on_exhaustion,the_latch_counter_can_still_be_stale_after_the_loop,shrinking_loops_agree_with_the_hlsl_path_on_the_gpu.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1129 passed, 2 failed, 26 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))).--skipleaves out tests that fail on mainb49be183too, 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.gpu_image_get_resinfo_past_last_level(ea088a5),pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa(#2245).mainb49be183(git merge --no-ff, clean, local only): NVIDIAXCL_REQUIRE_GPU=mesh cargo test --workspacewith the same skips: 1429 passed, 0 failed, 45 ignored; AMD Radeon iGPU (XCL_ADAPTER=radeon, same skips): 1440 passed, 0 failed, 47 ignored.Not tested
AI use
@Melow-code on GitHub · 2026-11-24 23:13 UTC · original · reviewed
No clear bug in the dominance proof or the WREXEC exit. Four points:
dominatesassumes block 0 is the entry — the loop stops onb == 0. If the entry has another index, the loop does not end. Testself.idom[b] == binstead.bodyholds natural loops only. A write in a cycle without a single header is in nobody, so the check passes vacuously. Is an irreducible CFG refused before this point?opcan come fromS_ORN1_SAVEEXEC_B32, that form keeps the old uniform SCC.@Melow-code on GitHub · 2026-11-25 11:54 UTC · original · reviewed
I read the dominance proof, the WREXEC exit and the mixed-mask SCC change from #1866. I found no clear bug. I have four points:
dominatesassumes that block 0 is the entry. The loop stops onb == 0. If the entry has another index and itsidomis itself, the loop does not end. A test onself.idom[b] == bdoes not depend on the index.bodyholds natural loops only. A write in a cycle without a single header is in nobody. Then the check "every loop that holds the write holds the read" has no loop to check, and it passes. Is an irreducible CFG refused before this point? If it is not,passedshould return false there.ANDN1but notORN1. Ifopcan come fromS_ORN1_SAVEEXEC_B32, that form keeps the old uniform SCC.The WREXEC exit case agrees with the ISA. After the last
S_*_WREXEC_B32before a not-takenS_CBRANCH_EXECNZ, EXEC, the destination and SCC are all 0 for the wave. Ther != 125check skips the null SGPR.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.