Shaders: fix missing and phantom operands in SP3 text #661
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!661
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/661/head"
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?
@coderanonymus on GitHub · 2026-11-24 06:24 UTC · original
coderanonymus:sp3-text-operands→main· +72 −4 · 1 files · 1 commits · merged 2026-11-25 00:20 UTCWhat
The SP3 disassembly text (
Instruction::text, used byvictory shader) printed operands that some instructions do not have. It also dropped VOP3P negation that applies to one half of a source only. The decodedFieldswere right in every case; only the text was wrong. Translation readsFields, so it is unaffected.Before and after, for words that llvm-mc
-mcpu=gfx1030assembles (-mcpu=gfx1010fors_get_waveid_in_workgroup, which gfx1030 lacks):0xF4900500 0x00000000s_memtime s[20:21], s[0:1], s0s_memtime s[20:21]0xF4A80140 0x00000000s_get_waveid_in_workgroup s5, s[0:1], s0s_get_waveid_in_workgroup s50xDC308000 0x007D0002global_load_dword v0, v[2:3], nullglobal_load_dword v0, v[2:3], off0xE0311000 0x00010001buffer_load_dword v0, v1, s[4:7], s0 offen ldsbuffer_load_dword v1, s[4:7], s0 offen lds0x7E0202F9 0x00050602v_mov_b32 v1, v2 src0_sel:WORD_1 src1_sel:BYTE_0v_mov_b32 v1, v2 src0_sel:WORD_10xCC0F4001 0x3A020702v_pk_add_f16 v1, v2, v3v_pk_add_f16 v1, v2, v3 neg_lo:[1,0]0xCC0F4201 0x1A020702v_pk_add_f16 v1, v2, v3v_pk_add_f16 v1, v2, v3 neg_hi:[0,1]0xCC0F4101 0x7A020702v_pk_add_f16 v1, -v2, v3v_pk_add_f16 v1, -v2, v3 neg_lo:[0,1]Changes, all in
crates/victory-shader/src/gfx10/sp3.rs:s_memtime,s_memrealtimeands_get_waveid_in_workgroupprint only their data. They have no address. This matchesir.rs, which treats all three as data only.saddrof NULL prints asoff, as the same arm already does for a missing VGPR address.ldsleaves out vdata. This matchesir.rs, which records no VGPR write for it. Stores keep their data.srcN_selis printed only for sources the instruction has.v_fma_mix; also coversv_dot2_*): a source negated in both halves keeps the-srcprefix. Bits set in only one half now print as LLVM'sneg_lo:[..]/neg_hi:[..], one entry per source, beforeclamp.Nothing else in the printer's style changes.
Verification
gfx10::sp3::tests::one_sided_packed_negation_is_printedandgfx10::sp3::tests::fields_the_instruction_lacks_are_not_printed. They assert llvm-mc's operands in this printer's style: no_sdwasuffix or default selects, and-srcfor a source negated in both halves. So llvm-mc'sv_mov_b32_sdwa v1, v2 dst_sel:DWORD dst_unused:UNUSED_PAD src0_sel:WORD_1is asserted asv_mov_b32 v1, v2 src0_sel:WORD_1, and itsv_pk_add_f16 v1, v2, v3 neg_lo:[1,1] neg_hi:[1,0]asv_pk_add_f16 v1, -v2, v3 neg_lo:[0,1].CARGO_TARGET_DIR=/home/eric/src/VIctory/target cargo test -p victory-shader --lib -- one_sided_packed fields_the_instruction_lacks: both failed, with the "Before" strings above.cargo test -p victory-shader: 58 passed, 0 failed.cargo clippy -p victory-shader --tests --target x86_64-pc-windows-msvc: no warnings. On the Linux target, the only warning is the existing dead-codeconstant_colorinemit/mod.rs, which this change does not touch.rustfmt --edition 2024 --check crates/victory-shader/src/gfx10/sp3.rs: clean.victory shaderon real shaders. This needs Windows and game files, and neither is available here.Known gap, same on main and left for a follow-up: MUBUF with neither
offennoridxenprints a vaddr register where llvm-mc printsoff(0xE0310000 0x00010000:buffer_load_dword v0, s[4:7], s0 ldsvs llvm-mc'sbuffer_load_dword off, s[4:7], s0 lds).No game data used.
🤖 Generated with Claude Code
@CaravelaLabs on GitHub · 2026-11-24 11:07 UTC · original
Thanks — the phantom-operand cleanup is real.
Checked against AMD LLVM 23.0.0git
llvm-mc -arch=amdgcn -mcpu=gfx1030(and-mcpu=gfx1010fors_get_waveid_in_workgroup). Merged this branch onto currentmain(ffe310e).cargo test -p victory-shader: 98 passed, 0 failed, including both new tests.The five encodings in
fields_the_instruction_lacks_are_not_printedmatch llvm-mc. The old printer text does not assemble: extras[0:1], s0ons_memtime,nullinstead ofoffonglobal_load_dword, avdataon an LDSbuffer_load_dword, andsrc1_selon a one-source SDWAv_mov_b32.One packed-negation case does not. Words
0xCC0F4101 0x7A020702(last row ofone_sided_packed_negation_is_printed):v_pk_add_f16 v1, -v2, v3 neg_lo:[0,1]v_pk_add_f16 v1, v2, v3 neg_lo:[1,1] neg_hi:[1,0]-srcprefix onv_pk_add_f16(not a valid operand)The first three packed encodings match. The
-prefix for both-halves negation is the printer's own convention, not LLVM's VOP3P syntax, so that row's expected string is not llvm-mc's. Translation is unaffected (Fieldswere already right), as the PR says.AI-assisted review. llvm-mc and the tests were run on this machine.
@molodayamama on GitHub · 2026-11-24 14:03 UTC · original
Independent Windows check of
6325df752c5638365c3e5a2b2f827ba0f3f145cb(Windows 10 22H2 19045, Rust 1.98.1, MSVC x64).cargo test -p victory-shader --locked --lib one_sided_packed_negation_is_printed -- --test-threads=1 --nocapture: 1 passed.The focused SP3 formatting fixture passed for a one-sided packed negation. A separate filter for absent fields did not select a test in my run, so this report covers only the packed-negation case.
Only source-built synthetic fixtures were used. AI-assisted verification.