Shader tests: the GFX10 decoder against llvm-mc on every opcode (checked-in fixture, no LLVM needed) #87
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/uiliannn--VItoriaBr--gone-20261201!87
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-87"
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?
@lcg007xd-c on GitHub · 2026-11-25 22:18 UTC · original
lcg007xd-c:test/llvm-decoder-oracle→main· +7649 −0 · 3 files · 1 commits · openWhat
This checks the GFX10 decoder against LLVM's, on every opcode, without needing LLVM to run the tests.
gfx10/llvm-mc-gfx1030.txt(264 KB, plain text) records whatllvm-mc -triple=amdgcn -mcpu=gfx1030 --disassemblemakes of one encoding of every opcode of every family. The families are SOP1/2/C/K/P, VOP1/2/3/3P/C, SMEM, DS, MUBUF, MTBUF, MIMG, FLAT/GLOBAL/SCRATCH, VINTRP and EXP. The ALU forms also come with a literal, and VOP3 with a literal in either the first or the third source. That is 7,093 cases, 2,393 of which LLVM decodes.decoder_agrees_with_llvmdecodes each case and compares the name (ignoring LLVM's_e32/_e64) and the length in dwords. A wrong length is the bad one, because every later instruction is then read out of step. It takes 0.02 s.KNOWN, each with a reason, and anything else fails. One pattern is skipped without listing:0xFFin a source field the instruction doesn't have (e.g. a third source on a two-source op). LLVM reads no literal there and real code never writes one.cargo test -p victory-shader regenerate_llvm_fixture -- --ignoredrewrites the fixture. It needsllvm-mc, which can be set withLLVM_MC.What it found
The 48 listed cases:
image_sample_cd_g16(all 8) andimage_gather4hhave no name; #69 adds them.0xFFin the attribute field are decoded as having a literal; #70 fixes that.v_mac_legacy_f32/v_mad_legacy_f32here, the GFX10.1 names. LLVM's gfx1030 hasv_fmac_legacy_f32/v_fma_legacy_f32there, the fused forms. Which one the console's GPU implements decides whether these round like an FMA. That is left for whoever owns the lowering. The test only records it.v_movrels*,v_readlane,v_swap*and the permlanes, or the lane mask ofv_cndmaskand the carry ops. LLVM doesn't read a literal there, and the compiler can't encode one.s_call_b64's branch target lies past the end of the test program.So nothing in today's decoder misreads real code that I can see. The test is there to keep it that way.
Tests
--target x86_64-pc-windows-msvc) pass locally. The fixture is within the asset policy's size limit.Not covered: operand text (styles differ from LLVM's), and DS/SMEM/MUBUF encodings beyond the one template each, which LLVM refuses for many opcodes.
🤖 Generated with Claude Code
@lmouz823-lang on GitHub · 2026-11-28 05:31 UTC · original
I can take native Windows validation and skip-accounting review at exact head
b7104dbd13a005ff4a3942aef795d0fb7c85e15f. I will run the checked-in fixture test, independently count its accepted, known and unused-literal cases, and inspect whether the exception rules can hide meaningful name/length regressions. Any justified small regression or fix will include a negative control, restored-source runs and explicit coverage limits. Local LLVM fixture regeneration will be reported separately according to tool availability. AI-assisted with Codex.@lmouz823-lang on GitHub · 2026-11-28 05:42 UTC · original
Native Windows validation completed for exact head
b7104dbd13a005ff4a3942aef795d0fb7c85e15f. The originalgfx10::llvm_tests::decoder_agrees_with_llvmexecutes exactly one test and passes.I audited the checked-in fixture and temporarily counted the comparison paths. The 7,093 data rows contain 2,393 stored LLVM acceptances and 4,700 stored rejections. The accepted rows divide into 2,095 exact name/length agreements, 250 unused-source literal exclusions, and 48 observed KNOWN disagreements. Family/encoding keys and KNOWN keys are unique.
The 250 exclusions require a literal-family case, the same decoded name, a decoder length exactly one dword longer, and a literal field beyond the decoder's reported source count. The 48 KNOWN keys consist of two branch-target artifacts, 23 register-only literal forms, nine missing image names, eight legacy fused-name differences and six attribute/literal cases. The KNOWN gate matches family and first word, so each matching key admits any mismatch for that key. The unused-source rule depends on the decoder's source count. These allowances bound the semantic regression's coverage.
The original comparison silently continues past rows with fewer than four columns and only checks a fixture-size lower bound. I added a 21-line test-only integrity regression that pairs every fixture row with
cases()in order, checks equal row counts, exactly four columns, the family and canonical encoding, a nonempty name, the-/zero-length relation, and a length within the supplied input. The generator appends oneS_ENDPGMword. Five existing encodings consume that extra word, so the length bound includes it.Two temporary fixture mutations demonstrate the new coverage.
I restored the fixture byte-for-byte to SHA256
cef83c381ac1edd37c7850143dff989563fe69d11196b7df19a9d3d5e83f2f96, removed the temporary counting diagnostic, cleaned only the isolated shader package target, and confirmed a fresh 12.38-second compilation. On the final formatted source, both exact tests each execute one test and pass. The complete LLVM test group reports 2 passed, 0 failed, 1 ignored.The ignored test is
regenerate_llvm_fixture. It requiresllvm-mc, and this environment has neitherLLVM_MCconfigured norllvm-mcon PATH. All LLVM judgments above come from the committed fixture. Local regeneration, a live LLVM comparison, GPU/DXIL execution, game behavior, other platforms and the remaining shader/workspace suites remain unverified.Environment was Windows 11 build 26200, Rust 1.98.1 MSVC, default test profile and an isolated target. Package Clippy with
--all-targets -- -D warnings, whole-file rustfmt on the original and final source,git diff --check, and asset policy (198 files) pass. The final patch adds only the integrity test. The fixture and the original comparison source match their initial contents after removing that added test and normalizing source newlines.Reproduce after applying the attached patch.
AI assistance from Codex covered the audit, regression, execution and this report.
Fixture integrity regression against this PR head
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.