Recompiler: v_swaprel_b32 indexes the destination with M0[25:16] #803
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!803
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-803"
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?
@upipibi on GitHub · 2026-11-24 05:37 UTC · original
upipibi:fix/swaprel-dst→main· +50 −26 · 2 files · 1 commits · openv_swaprel_b32exchanged the fixedVDSTwithVGPR[SRC0 + M0]and switched on all of M0. The RDNA 2 ISA gives each side its own index (VOP1 opcode 104):addr_src = SRC0 + M0.u[9:0],addr_dst = DST + M0.u[25:16], thentmp = VGPR[addr_dst]; VGPR[addr_dst] = VGPR[addr_src]; VGPR[addr_src] = tmp, with the examplem0 = (20 << 16) | 10,v_swaprel_b32 v5, v7swapping v25 and v17. Section 6.6 (table 25) also uses separate fields for source and destination; it prints the low field as M0[7:0], and this PR follows the opcode table's M0[9:0], asv_movrelsd_2_b32already does. LLVM defines the instruction (VOP1Instructions.td,Uses = [M0]) but no compiler I know of emits it.On
main, withm0 = (2 << 16) | 3, no case ofswitch (m0)matched. XCL wrote 0 to v5 and left v7 and v13 alone, where the ISA swaps v7 and v13 and leaves v5 untouched. The existing test only used m0 = 3 and m0 = 1, where both readings agree.What is in it
crates/xcl/src/gpu/recomp/emit.rs:swaprelreads and writes both sides through the bounded switches thatmovreluses forv_movrelsd_2_b32(m0 & 0x3FF,(m0 >> 16) & 0x3FF). Both old values are still read before either write, so an overlapping pair is a no-op, and the writes stay EXEC-gated as for any VOP1 write.crates/xcl/src/gpu/recomp/tests.rs:gpu_v_swaprel_b32getsm0 = (2 << 16) | 3,v_swaprel_b32 v5, v10(swaps v7 and v13, v5 untouched), andm0 = 0xFC01FC02,v_swaprel_b32 v16, v20(bits outside the two fields ignored: swaps v17 and v22).v_swaprel_b32_uses_the_m0_relative_switchchecks the two index expressions in the HLSL.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4on4db1a2a: 704 passed, 0 failed, 41 ignoredgpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64)main(d5442d2) without theemit.rschange.gpu_v_swaprel_b32fails at lane 0 withv5 = 0, expected 2000 (untouched), andv_swaprel_b32_uses_the_m0_relative_switchfails on the oldswitch (m0). Both pass with the change.upper_lanes::tests::swaprel_writes_any_registerpasses before and after.Regression run
From eizispark's run (https://github.com/ivall/xcl/pull/803#issuecomment-7123874976), thanks:
main:
PR:
Not tested
v_swaprel_b32with a non-zero M0[25:16]. Low impact: neither LLVM nor ACO emits the instruction.AI use
🤖 Generated with Claude Code
@MesshM on GitHub · 2026-11-24 05:46 UTC · original
Test run of
4db1a2a4a3d03b3f5eb559670c1f584fbbdd055con AMD RDNA4. I merged it onto currentmaine50836blocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 704 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 663 passed, 0 failed, 21 ignoredSKIPPED;gpu_v_swaprel_b32,v_swaprel_b32_uses_the_m0_relative_switchandswaprel_writes_any_registerpass.Review: Separate indices for the two sides (
SRC0 + M0[9:0],DST + M0[25:16]) are what the RDNA2 ISA's pseudo-code for VOP1 opcode 104 gives, including itsm0 = (20 << 16) | 10example. I found nothing to change.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@mastrr9 on GitHub · 2026-11-24 05:57 UTC · original
Independent native Windows NVIDIA RTX 5080 (wave32) + D3D12 debug layer build/test run and code review at head
4db1a2a4a3d03b3f5eb559670c1f584fbbdd055c.Code Review
v_swaprel_b32(VDST + M0[25:16]<->SRC0 + M0[9:0]), capturing both old values before either EXEC-gated write and masking both indices to 10 bits (0x3FFu). Both CPU HLSL and GPU tests cover the destination index and ignored upper M0 bits. No issues found.Tested
617.42/32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), D3D12 debug layer installed (d3d12SDKLayers.dll),rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC from Windows SDK10.0.26100.0, debug build.cargo build --workspace && cargo test --workspace -- --test-threads=4hle::d3d12x::cpu_writes::tests::writes_land_after_the_queueatcpu_writes.rs:184, while both PR tests passed in both Run 1 and Run 2.)ok, executed on RTX 5080, not skipped):gpu::recomp::tests::v_swaprel_b32_uses_the_m0_relative_switchgpu::recomp::tests::gpu_v_swaprel_b32gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask(no wave64)gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)Not tested
AI use: Antigravity (Gemini 4 Neon reviewed the diff; Gemini 4 Hydrogen ran the RTX 5080 workspace tests) drafted this report.
@eizispark on GitHub · 2026-11-24 06:22 UTC · original
Hardware check of
4db1a2a4a3d03b3f5eb559670c1f584fbbdd055c(verified clean merge withmainbeaa245): pass.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profilecargo test --workspace -- --test-threads=4:704 passed, 0 failed, 41 ignored(GPU tests skipped on this adapter:none)gpu_v_swaprel_b32,v_swaprel_b32_uses_the_m0_relative_switch,swaprel_writes_any_register:3 passed, 0 failedRegression run
main(beaa245):PR (
4db1a2a):Not tested
AI use
scripts/smoke.ps1harness on this machine and formatted this report.@SlopTart on GitHub · 2026-11-24 06:41 UTC · original
2|
3|AMD/wave64 + release-build datapoint - the axes your row lists as not tested. Plus one flake sighting to log.
4|
5|Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Wine = Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust 1.100.0 cross
x86_64-pc-windows-gnu, release profile,XCL_NETWORK=0, native wave64. Same rig as my Linux rows in #42 / #718.6|
7|Merged state: head
4db1a2aonto mainbeaa245, clean merge.8|
9|Full suite,
cargo test --workspace --release --no-fail-fast -- --test-threads=4: 702 passed, 11 failed, 41 ignored (17 suites). The 11 = this rig's 7 stable Wine-lane failures (my #42 row) + the #718 flaky trio + one hit ofgpu_geometry_wave32_prefix_count_over_a_mask- that one is AMD-only (skipped on your wave32 boxes); 2 hits in 12 full-suite runs and 5 of 20 isolated runs atbeaa245(load-sensitive - see #847). Nothing failed because of your change. Your tests pass on RDNA3 native wave64:gpu_v_swaprel_b32ok,v_swaprel_b32_uses_the_m0_relative_switchok,upper_lanes::tests::swaprel_writes_any_registerok - and your two skipped GPU tests actually execute here, including the geometry one above.10|
11|Not tested: retail titles (none here), Windows, RDNA4.
12|Counts only, no game data.
13|AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
@DavidM1911 on GitHub · 2026-11-25 10:58 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.