Shaders/Decode: always decode GFX10 v_cmpx_* VOP3 and SDWA destination as EXEC #3083
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3083
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@RVZO6 on GitHub · 2026-11-26 06:57 UTC · original
RVZO6:rvzo/v-cmpx-dst-exec→main· +90 −2 · 2 files · 1 commits · openProblem
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).
On GFX10+, v_cmpx_* instructions implicitly write EXEC and ignore the encoded scalar destination bits in both VOP3 (w0[7:0]; LLVM VOPCX_Real_gfx10._e64_gfx10: Inst{7-0} = ?, AMDGPUMCCodeEmitter::postEncodeVOPCX) and VOPC SDWA (ext[15:8]; VOPCX_Real_gfx10._sdwa_gfx10 uses _nosdst_sdwa). Previously fields.rs decoded v_cmpx_* VOP3 dst from w0[7:0] (yielding s0 instead of EXEC whenever w0[7:0] != 0x7e) and let SDWA ext[15:8] override v.dst on v_cmpx_* when bit 15 was set. Align both encodings with Encoding::Vopc (and with ir.rs, structure.rs, resource.rs, and lower.rs) by always decoding v_cmpx_* destinations as EXEC.@oni-swr on GitHub · 2026-11-26 07:11 UTC · original
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: #1633
@Dukestar69 on GitHub · 2026-11-26 07:08 UTC · original · approved these changes
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).
@Marvisak on GitHub · 2026-11-26 08:20 UTC · original
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
@fuzeofficlal on GitHub · 2026-11-26 08:29 UTC · original · approved these changes
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.
@futurepro62 on GitHub · 2026-11-26 10:51 UTC · original
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.