Repository navigation
rdna2spirv: v_dot4_i32_i8's op_sel/op_sel_hi come from the blob when llvm-mc drops them (SHADER-626) - #3372
rdna2spirv: v_dot4_i32_i8's op_sel/op_sel_hi come from the blob when llvm-mc drops them (SHADER-626)#3372mrp1no wants to merge 4 commits into
Conversation
kacper-serewis
left a comment
There was a problem hiding this comment.
AI-assisted independent CPU review at 363a553 found a live-source mismatch accepted by dropped_op_sel (tools/rdna2spirv.py:11083). After replacing select bits, same_encoding permits stored s0 (0x000) to match printed inline zero (0x080) in SRC1 or SRC2. Both are live v_dot4 operands. Combining a dropped select with either mismatch made both clean and re-anchoring paths accept the instruction and use zero; dependency #2229 rejected all four controls. Require exact equality after replacing the six select bits for this opcode, with regression coverage for both source fields and paths.
All 25 targeted tests passed. An independent 64-select sweep on both paths produced correct signed-byte sums for 16 supported combinations and rejected 48 unsupported addend combinations. The defect's emitted module still passes Vulkan 1.2 spirv-val. Synthetic CPU inputs only. Dependency 6d4cc4c is an ancestor. Inline-constant native dot4 semantics remain inferred from packed16 measurements. Trial integration with #2977 confirmed documented conflicts.
…exactly what was printed From the review on ItsNotRexed#3372. dropped_op_sel compared the stored bytes, with the printed selects put back, through same_encoding. same_encoding lets an unused SRC1/SRC2 stored as 0 (s0) match a printed 0x80 (inline 0). v_dot4_i32_i8 reads all three sources, so a dropped select together with a stored s0 in SRC1 or SRC2 was accepted and translated as the constant 0. The rest of the bytes must now be equal. A new test covers SRC1 and SRC2 on both paths; it fails with the old check. The two FSPX programs still translate (26 of 29). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @kacper-serewis, you're right. Fixed in 2dfe273.
On the inline-constant semantics: agreed, they're inferred from #2224's packed-16 measurement. The design row and the PR body say so. |
|
Tested
AI-assisted (Claude Code). Synthetic test shaders only, no game files. |
|
Tested 2dfe273 merged onto main f847748 on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:
AI-assisted (Claude Code). |
|
Tested Native gfx1036 (Ryzen 9 9950X3D iGPU, AMD driver 32.0.21030.2001, raw
So on Translated, the PR's restored-select path. A compute listing has a
Also run here: |
…tsNotRexed#3372) @TheMrBeez ran v_dot4_i32_i8 on gfx1036 (raw hw_oracle kernels, wave32 and wave64) with 13 operand/select combinations. S1 was a VGPR or an inline constant (-16, -6, 7, 64). Every result equals the translator's: a constant reads as its sign-extended 32-bit value, and op_sel/op_sel_hi pick its halves like a VGPR's. The design row and the test comment now say measured instead of inferred from ItsNotRexed#2224. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @TheMrBeez, that closes the one thing this PR could only infer. In f51ed5f the |
|
Rebased onto
Re-run on the rebased head:
|
f51ed5f to
b6e26b3
Compare
…exactly what was printed From the review on ItsNotRexed#3372. dropped_op_sel compared the stored bytes, with the printed selects put back, through same_encoding. same_encoding lets an unused SRC1/SRC2 stored as 0 (s0) match a printed 0x80 (inline 0). v_dot4_i32_i8 reads all three sources, so a dropped select together with a stored s0 in SRC1 or SRC2 was accepted and translated as the constant 0. The rest of the bytes must now be equal. A new test covers SRC1 and SRC2 on both paths; it fails with the old check. The two FSPX programs still translate (26 of 29). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tsNotRexed#3372) @TheMrBeez ran v_dot4_i32_i8 on gfx1036 (raw hw_oracle kernels, wave32 and wave64) with 13 operand/select combinations. S1 was a VGPR or an inline constant (-16, -6, 7, 64). Every result equals the translator's: a constant reads as its sign-extended 32-bit value, and op_sel/op_sel_hi pick its halves like a VGPR's. The design row and the test comment now say measured instead of inferred from ItsNotRexed#2224. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Additional RTX 4070 Laptop GPU coverage for the pre-rebase head
All eight dispatched modules passed SPIR-V validation, and the focused CPU suite passed 20/20. I compared the restoration functions with rebased head |
|
Tested b6e26b3 (merged onto main aa2988c) on RTX 3060 (Ampere), driver 617.14, Windows 11, MSVC 14.44, RelWithDebInfo: pass
AI-assisted: this check was run and written with Claude Code (Anthropic) on my machine; the numbers above are its unedited output. |
|
Tested Setup
Overlap with
FSPX programs (1.0.2.1,
Hardware, that exact form
Game shaders
Tests
Not from this PR: an undecodable dot4 cuts the program short
AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2). |
|
Combined data point for #3369 and #3372, from a scratch merge of both onto
Caveat: as @aslan2142 found on #3372, some programs fall through into dot4 words llvm-mc can't decode at all. Those translate but may lose stores until SHADER-813 lands, so 29/29 means 'translated and valid', not yet 'computes everything'. AI-assisted (Claude Code). |
|
@kacper-serewis, your requested change is in the current head
Could you take another look and update your review if it holds? Your "changes requested" is still the PR's review state. AI-assisted. |
kacper-serewis
left a comment
There was a problem hiding this comment.
AI-assisted CPU comparison on 29 distinct cached FSPX programs. #3372 base 4c52ce2 accepted 22/29 and head b6e26b3 accepted 24/29 with blob half-selector recovery. At the identical #2323 revision 18ffaf0, the listing path accepted 22/29 and direct binary decoding accepted 29/29. Every translated module passed spirv-val and both paths retained all 22 baseline successes. These counts establish structural validity. Runtime equivalence remains open.
|
Rebased onto
Both suites against a
AI-assisted (Claude Code). |
…exactly what was printed From the review on ItsNotRexed#3372. dropped_op_sel compared the stored bytes, with the printed selects put back, through same_encoding. same_encoding lets an unused SRC1/SRC2 stored as 0 (s0) match a printed 0x80 (inline 0). v_dot4_i32_i8 reads all three sources, so a dropped select together with a stored s0 in SRC1 or SRC2 was accepted and translated as the constant 0. The rest of the bytes must now be equal. A new test covers SRC1 and SRC2 on both paths; it fails with the old check. The two FSPX programs still translate (26 of 29). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tsNotRexed#3372) @TheMrBeez ran v_dot4_i32_i8 on gfx1036 (raw hw_oracle kernels, wave32 and wave64) with 13 operand/select combinations. S1 was a VGPR or an inline constant (-16, -6, 7, 64). Every result equals the translator's: a constant reads as its sign-extended 32-bit value, and op_sel/op_sel_hi pick its halves like a VGPR's. The design row and the test comment now say measured instead of inferred from ItsNotRexed#2224. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b6e26b3 to
3c30096
Compare
|
Tested 3c30096 on two Vulkan devices, Windows 11, Vulkan SDK 1.4.363, MSVC 14.50, llvm-mc 23.1.6 (AMDGPU, LLVM-MinGW build). vk_* test programs rebuilt from current main:
AI-assisted. No game files. |
|
Tested 3c30096 on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: pass.
No runtime C++ changes in this PR; tested from the PR worktree against the existing main runtime build. AI-assisted (OpenCode). |
…llvm-mc drops them llvm-mc 23.1.6 refuses op_sel and op_sel_hi on gfx1030's v_dot4_i32_i8. It disassembles an instruction that has them as the plain one and re-encodes the defaults, so op_sel_hi:[1,0,1] reads back as [1,1,1]. The hardware reads them, and ItsNotRexed#2229 gives them their meaning. So translating the listing as printed would sum the wrong bytes. Where the stored and printed bytes differ only in the select bits, dropped_op_sel() reads op_sel/op_sel_hi from the blob, and restore_op_sel() gives the instruction those modifiers. This applies in a clean listing (check_printed_encodings) and in one with undecodable words (the re-anchoring loop). Any other difference is still refused, and a restored addend select is still refused by the dot4 rule. On a 1.0.2.1 package the DXBC corpus has no v_dot4_i32_i8. The FSPX programs hold 1,458 of them in 13 listings, and 2 (in 2 programs) store non-default selects. Those programs were refused with "reachable instruction with normalized encoding"; they now translate and pass spirv-val (24 -> 26 of 29 on top of ItsNotRexed#2229). tests/semantic/test_dot4_dropped_op_sel.py runs the restored forms through the interpreter on both paths. Without the rule, 5 of its 6 tests fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ograms store Both FSPX instructions take S1 from an inline constant with op_sel_hi[1] = 0, the broadcast of its low half. The test now runs that form too (-6: 70 restored, 85 with the defaults). The design row says the constant reads as its 32-bit value, as ItsNotRexed#2224 measured for packed 16-bit ops, and that this isn't measured on v_dot4_i32_i8 itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…exactly what was printed From the review on ItsNotRexed#3372. dropped_op_sel compared the stored bytes, with the printed selects put back, through same_encoding. same_encoding lets an unused SRC1/SRC2 stored as 0 (s0) match a printed 0x80 (inline 0). v_dot4_i32_i8 reads all three sources, so a dropped select together with a stored s0 in SRC1 or SRC2 was accepted and translated as the constant 0. The rest of the bytes must now be equal. A new test covers SRC1 and SRC2 on both paths; it fails with the old check. The two FSPX programs still translate (26 of 29). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tsNotRexed#3372) @TheMrBeez ran v_dot4_i32_i8 on gfx1036 (raw hw_oracle kernels, wave32 and wave64) with 13 operand/select combinations. S1 was a VGPR or an inline constant (-16, -6, 7, 64). Every result equals the translator's: a constant reads as its sign-extended 32-bit value, and op_sel/op_sel_hi pick its halves like a VGPR's. The design row and the test comment now say measured instead of inferred from ItsNotRexed#2224. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3c30096 to
5650930
Compare
New SHADER item, claimed in #3232 (claim).
Depends on: #2229 (merged). That PR gives
v_dot4_i32_i8'sop_sel/op_sel_hitheir meaning. It has landed, so the diff is now only this item's four commits. It conflicts with #2977 in the two places both hook into (thesame_encodingfailure incheck_printed_encodingsand in the re-anchoring loop). Whichever lands second needs a short rebase. The two rules don't overlap.What was wrong
llvm-mc drops
v_dot4_i32_i8's half selects on gfx1030. I checked llvm-mc 23.1.6 on synthetic words:op_selandop_sel_hion that instruction.00 40 16 cc 01 05 0e 0c, which isop_sel_hi:[1,0,1], prints as plainv_dot4_i32_i8 v0, v1, v2, v3, and the printed encoding ends in1c(the default[1,1,1]).The hardware does read these fields ("Signed-byte dot products" in
docs/design.md, from #2229's gfx1036 measurements). So the listing as printed sums the wrong bytes. The translator caught the mismatch and refused: "reachable instruction with normalized encoding" in the re-anchoring path, "a field the disassembler dropped" in a clean listing.The change
dropped_op_sel(raw, printed, op): forv_dot4_i32_i8only. It returns the storedop_sel/op_sel_hiwhen the printed instruction has the default selects and the stored one doesn't. With the printed selects put back, the bytes must be the printed instruction (same_encoding). Any other difference still refuses.restore_op_sel(ins, ...): gives the instruction those modifiers in llvm-mc's spelling. rdna2spirv: v_dot4_i32_i8 op_sel/op_sel_hi and clamp (FSPX) #2229's rule then reads them. A restored addend select (op_sel_hi[2] = 0) is still refused by that rule.check_printed_encodings(clean listings) and the re-anchoring loop (listings with undecodable words).docs/design.md: the "Printed encodings" row gets the rule, how it was confirmed and the counts.Tested
Measured on my own 1.0.2.1 package, with counts only:
v_dot4_i32_i8in it, so it can't change.v_dot4_i32_i8in 13 listings. 2 of them, in 2 programs, store non-default selects. Both areop_sel_hi:[1,0,1]on an inline-constant S1, the compiler's broadcast of the constant's low half into both byte pairs. The constant reads as its sign-extended 32-bit value. @TheMrBeez confirmed that on RDNA2 hardware forv_dot4_i32_i8itself: gfx1036, 13 combinations, all equal to the translator.The 29 FSPX programs translated with
--no-asm --wave64-emulate:spirv-valmain+ #2229 + this + #3095v_fma_mixleft, which is #2977)In both new modules, S1's byte pairs 2..3 are now extracted at offsets 0/8 for that one instruction, as
op_sel_hi[1] = 0says.Tests:
tests/semantic/test_dot4_dropped_op_sel.py(new, 8 tests): runs the program through the interpreter. The default selects give 90.op_sel_hi:[1,0,1]restored gives 126, on both paths.op_sel:[0,1,0] op_sel_hi:[1,0,1]gives 110. An inline-constant S1 (-6) withop_sel_hi:[1,0,1]gives 70, against 85 with the defaults. A restored addend select, aneg_lodifference and a live SRC1/SRC2 stored ass0(printed as inline 0) are still refused, and other ops are left alone. Negative control: with the rule reverted, 5 of the first 6 fail.python -m unittest discover -s tests/semantic: 2,575 tests OK (3 skipped).tests/test_rdna2spirv_decode.pyOK. With currentmainmerged in,test_docs_design_rows.py,test_docs_repo_paths.py,test_docs_links.py,test_docs_list_items.py,test_printed_encoding.pyandtest_alu_dot4_i8.pyall pass.test_docs_design_rows.pyfails on rdna2spirv: v_dot4_i32_i8 op_sel/op_sel_hi and clamp (FSPX) #2229's older base alone, and that isn't from this change.CPU only, Windows 11, Python 3.15.2, llvm-mc 23.1.6,
spirv-valfrom SPIRV-Tools v2026.4. No GPU run of the two programs. No shader names, bytes or disassembly from the package. The encodings above are hand-assembled. AI-assisted (Claude Code).🤖 Generated with Claude Code