Repository navigation
rdna2spirv: v_dot4_i32_i8 op_sel/op_sel_hi and clamp (FSPX) - #2229
Conversation
264e40b to
6d4cc4c
Compare
|
Tested 6d4cc4c (contains A scratch compute kernel (not in this PR), one thread, operands from
Also:
Not covered here: AI-assisted (Claude Code); no game files. |
|
Tested 6d4cc4c on AMD Radeon RX 9070 XT (RADV GFX1201) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.
No game files. AI-assisted. |
…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>
…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>
…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>
…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>
Implements the remaining FSPX translator rules from
docs/fspx.md(claim: #1902 (comment)):v_dot4_i32_i8op_sel/op_sel_hi: selects the 16-bit half of S0 and S1 for byte pairs 0..1 (op_sel) and 2..3 (op_sel_hi), matching all 5gfx1036hardware-measured rows inMEASURED_OP_SEL(tests/semantic/test_alu_dot4_i8.py), including theop_sel:[0,1,0] op_sel_hi:[1,0,1]form decoded by rdna2_decode: pure-Python RDNA2 binary ISA decoder (#1901) #2038. Non-default S2 half selection stays refused.v_dot4_i32_i8clamp: signed 32-bit saturation[-2^31, 2^31-1]using pure 32-bit signed-overflow detection (valid because the 4-byte dot sum is bounded by[-65024, 65536]), matching both overflowinggfx1036hardware-measured cases.v_pk_fmac_f16: VOP2 packed f16x2 FMA accumulating intodstusing the same single-roundedGen.fma_f16_oddpath asv_pk_fma_f16, plus read-before-write VGPR tracking inread_before_write_vgprsandvgpr_io.Verification
python3 -m unittest discover -s tests/semantic -p test_alu_dot4_i8.py -v: 12/12 OK (all 10MEASUREDrows, all 5MEASURED_OP_SELrows, bothclampoverflow rows,v_pk_fmac_f16accumulation / read-before-write / single-rounding tie /clamp).python3 -m unittest discover -s tests/semantic -p test_f16_fma_rounding.py: 5/5 OK.spirv-as+spirv-val --target-env vulkan1.2on translatedop_sel,clamp, andv_pk_fmac_f16modules: 3/3 OK.tests/test_docs_links.py,tests/test_text_write_line_endings.py: 7/7 OK.AI-assisted.