Repository navigation
Recompiler: ignore VOP3 op_sel on 16-bit VOPC compares (#1293) - #1572
hajduzsolt wants to merge 1 commit into
Conversation
RDNA2 hardware ignores VOP3 op_sel bits on 16-bit VOPC compares (v_cmp_*/v_cmpx_* over f16/u16/i16) and always reads both operands from bits [15:0], whereas vopc extracted upper halves when m.opsel bits were set. Read low 16 bits unconditionally for non-class f16/u16/i16 compares (leaving v_cmp_class_f16 and SDWA behavior unchanged). Fixes xcl-dev#1293 Assisted-by: Antigravity (Gemini 4 Hydrogen, high)
fd4f217 to
ad6921e
Compare
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Two contributors checked independently and found that this PR makes the same change as #1296 (for #1293): #1607, group D27. They suggest keeping #1296. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps. This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table. |
|
Closing this as a duplicate: #1296 makes the same change and was opened first (16-bit compares read the low halves whatever op_sel says). It stays open and is the one that will be reviewed and merged. This says nothing about the quality of the code here. I compared the two diffs; the pair was also found by independent checks in #1607. If this PR covers a case #1296 does not, or #1296 is closed without being merged, say so and I'll reopen it. A test that is only here is welcome on #1296. Thank you for the work. AI use: Claude Code (Claude Opus 5.5) compared the diffs and wrote this comment; the decision is the maintainer's. |
RDNA2 runs the VOP3 encodings of VOP2 (opcodes 0x100-0x13F) and VOP1 (0x180-0x1FF) instructions without op_sel: they read the low halves of their sources and write the low half of VDST, keeping the high one, whatever OP_SEL holds. Only the VOP3-only 16-bit opcodes (v_fma_f16, v_mad_u16, v_add_nc_u16, v_pack_b32_f16, ...) honour it. Both backends honoured it for every 16-bit op, so v_mul_f16 with OP_SEL 0b1001, for example, multiplied src0's high half and wrote VDST's high half. Measured on RDNA2 silicon (gfx1036, the Radeon iGPU of a Ryzen 7 9700X, through OpenCL inline asm with the OP_SEL bits patched into the dwords): all 31 16-bit opcodes in these ranges give the same dword with any one OP_SEL bit set as with none, while the VOP3-only controls change as op_sel says. LLVM's GFX10 tests (tests/data/llvm-amdgpu/gfx10_vop3.txt) set OP_SEL on none of the 2372 encodings in these ranges. rdna2::op_sel returns 0 for these encodings, and the mods() of both backends take Mods.opsel from it. The 16-bit compares (VOPC in VOP3, 0x000-0x0FF) are left as they are (xcl-dev#1296, xcl-dev#1572). The three tests that expected the op_sel forms now expect the measured results, a GPU test checks 80 measured cases, and a decoder test pins which encodings keep OP_SEL. The retail title's shader pack has no such instruction with OP_SEL set (none of its 44.4M instructions apart from the shader-hash v_nops), so it runs the same code as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Updates 16-bit non-class VOPC compares (f16/u16/i16) to always read both sources from the low 16 bits ([15:0]), ignoring VOP3 op_sel bits to match RDNA2 hardware behavior. Fixes #1293.
What is in it
Tested
Regression run
main:
PR:
Not tested
AI use