Shaders/Decode: always decode GFX10 v_cmpx_* VOP3 and SDWA destination as EXEC #3081
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3083"
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 Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-26T06:57:15Z.
Problem
On GFX10+ (RDNA1/RDNA2),
v_cmpx_*instructions implicitly writeEXECand ignore the encoded scalar destination bits in both VOP3 and VOPC SDWA encodings:VOPCX_Real_gfx10._e64_gfx10in LLVMllvm/lib/Target/AMDGPU/VOPCInstructions.td:let Inst{7-0} = ?; // sdst, andAMDGPUMCCodeEmitter::postEncodeVOPCX): hardware ignoresw0[7:0]and writes onlyEXEC. Previouslygfx10/fields.rsdecodedv.dst = Some(scalar(vdst as u8, lanes))for all VOP3 compares, so anyv_cmpx_*VOP3 encoding withw0[7:0] != 0x7e(e.g.0x00) decodeddst = s0/s[0:1]and printedv_cmpx_* s0, ...inInstruction::text().VOPCX_Real_gfx10._sdwa_gfx10uses_nosdst_sdwa): hardware has nosdstfield and writes onlyEXEC. Previouslygfx10/fields.rsletext[15:8]overwritev.dstwhen bit 15 was set onv_cmpx_*_sdwa.Fix
In
crates/victory-shader/src/gfx10/fields.rs:ext[15:8]forv_cmpx*in the VOPC SDWA arm.v.dst = Some(scalar(EXEC, lanes))forv_cmpx*in the VOP3 compare arm, aligning both encodings withEncoding::Vopc(and withir.rs,structure.rs,resource.rs, andlower.rs).Tests & Verification
gfx10::sp3::tests::v_cmpx_vop3_and_sdwa_always_write_execincrates/victory-shader/src/gfx10/sp3.rscovering wave32 and wave64fields()andtext()for VOP3v_cmpx_lt_f32(vdst = 0x00and0x7e), VOPC SDWAv_cmpx_eq_f16(sd = 1, sdst = s6), plus a non-EXECv_cmp_eq_f16SDWA control.left: Some(Scalar { code: 0, dwords: 1 }), right: Some(Scalar { code: 126, dwords: 1 }).victory-shader304 passed, 0 failed; clippy default &--all-featuresclean;xtask policyclean.Claimed in #1633.
AI-assisted: T3 Code (Antigravity, gemini-4-neon).
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T07:08:38Z.
Review: APPROVED
Tested locally merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-shader gfx10::: 17 passed, 0 failed (includingv_cmpx_vop3_and_sdwa_always_write_exec).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T07:11:14Z.
Independent CPU-only verification of #3083 at
61ce014aagainst exact parent63bcca43. Synthetic instruction words, no game files, no GPU, no adapter involved.Test. A decoder sweep over
decode/fields(wave64)/text(wave64)for wave32 and wave64:v_cmp*(95v_cmpx_*, 95 non-X), each with encodedw0[7:0]in {0x00, 0x01, 0x06, 0x6a, 0x6b, 0x7c, 0x7d, 0x7e, 0x7f}.v_cmpx_*decodesdst = exec(code 126, one dword on wave32, two on wave64) and printsexec_lo/exec; every non-X compare keeps its encoded SGPR (VOP3) or the SDWAsdstwhensd = 1, VCC whensd = 0.Results.
v_cmpx_*cases not decoded as EXEC63bcca4361ce014aThe parent's only correct
v_cmpxcases are VOP3 withw0[7:0] = 0x7e, and SDWA withsd = 0orsdst = exec_lo. I also hashed every decoded field: all non-v_cmpxresults (these compares, VOPC e32 for all opcodes, and VOP3 opcodes 0x100..0x3ff) are byte-identical between the parent and #3083, and thev_cmpxfields are identical apart fromdst. So the change touches only thev_cmpxdestination.Limits. The expectation that GFX10 ignores
sdstfor VOP3v_cmpxcomes from LLVM's AMDGPUVOPCInstructions.td(VOPCX_Real_gfx10,let Inst{7-0} = ?; // sdston_nosdst_e64), which I read; I did not test it on hardware, so these results show the decoder matches that description, not what silicon does with non-zero bits. I did not run the lowering or any shader; downstream use ofdstwas not exercised.AI use: Claude Code (Claude Sonnet 5.5) for the work; coordinated by Codex (gpt-6.2-sol). Coordination: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7185048463
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T08:29:43Z.
Review: APPROVED
Clean decoding fix across both VOP3 and VOPC SDWA encodings:
crates/victory-shader/src/gfx10/fields.rsaligns VOP3 (v_cmpx*always writes implicitEXEC) and SDWA (ignoringext[15:8]forv_cmpx*while keeping explicit scalar destination for ordinaryv_cmp_*) withEncoding::Vopcand all 95v_cmpx_*opcodes ingfx10/opcodes.rs.sp3.rsformatting and the existing EXEC tracking inir.rs,structure.rs, andemit/lower.rs.Verified locally on Windows 11:
cargo clippy -p victory-shader --all-targets --locked -- -D warnings: cleancargo test -p victory-shader --lib --locked -- gfx10::: 17/17 passed (includingv_cmpx_vop3_and_sdwa_always_write_exec)(Optional follow-up idea: a lowering test verifying that a
v_cmpx_*encoding with a non-canonical destination such as0x00narrowsEXECwithout clobberings0.)LGTM.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T08:20:58Z.
Automated triage for the maintainers.
Merge candidate. In
gfx10/fields.rs(Instruction::fields),v_cmpx_*now always decodes its destination as EXEC: the VOP3 arm no longer takesw0[7:0]as an SGPR, and the VOPC SDWA arm no longer letsext[15:8]override it. This matches the VOPC e32 arm and what the consumers inorigin/mainalready assume by name (ir.rsregister writes,resource.rs,emit/lower.rslane_bits_for), so lowering is unchanged and the fix is to the decoded fields andtext(). The evidence cited is LLVM's AMDGPUVOPCInstructions.td(GFX10v_cmpxe64/SDWA carry no sdst). The new testgfx10::sp3::tests::v_cmpx_vop3_and_sdwa_always_write_execincludes a non-Xv_cmpSDWA control.CI: passing (check).
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T10:51:11Z.
NVIDIA full-suite run, to go with the reports above by Dukestar69, fuzeofficlal, since none of them names a GPU run. Tested exact head
61ce014(on its base63bcca4).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.v_cmpx_vop3_and_sdwa_always_write_exec.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
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.