feat: half-precision compares (v_cmp[x]_*_f16, v_cmp[x]_class_f16) in the RDNA 2 interpreter — 1,206/1,490 #244
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!244
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/244/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?
@lcg007xd-c on GitHub · 2026-11-25 21:00 UTC · original
lcg007xd-c:feat/rdna2-f16-compares→main· +277 −35 · 14 files · 1 commits · merged 2026-11-25 21:46 UTCChange
The reference interpreter now runs the 34 half-precision compares in VOPC and VOP3, 68 encodings that raised
Untranslateduntil now:v_cmp[x]_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f16andv_cmp[x]_class_f16. The code is a new module,emu/rdna2_exec_cmpf16.py(about 95 lines), plus one dispatch line each inrdna2_exec.pyandrdna2_exec_vop3.py.FLOAT_TESTS): ordered tests are false on NaN and theirn*negations true, -0 == +0, denormals are compared by valuev_cmp_class_f16tests the IEEE class of S0 against the bits S1[9:0]: bit 0 sNaN … bit 9 +inf.rdna2_exec_cmp64.float_classgets the 16-bit format (5, 10)rdna2_exec_f16._source, #218): a register's low half, an inline float as binary16 (1.0 = 0x3C00), an inline integer or a literal as its low 16 bits. S1 of class also reads an inline float as binary16, following the ISA's note: "the S1 has a format of f16 since floating point literal constants are interpreted as 16 bit value for this opcode"v_cmpwrites VCC (VOPC) or its SGPR (VOP3);v_cmpxwrites EXEC onlyabs/negact on bit 15 of a float sourceRefused by name (rule 3), as not documented or not measured:
op_sel(ISA §6.2.5: OPSEL is not for VOPC in the VOP3 encoding; same rule as the i16/u16 compares of #226);clampandomod;abs/negon the class mask S1;HLSL: not changed. The recompiler still refuses these instructions, which a test pins. Its translation can follow in a separate PR with GPU parity tests, the way #218 and #219 were split.
Coverage of the reference interpreter (
rdna2_exec.coverage()): 1,138 → 1,206 of 1,490 encodings. All 9 READMEs go from 76% to 81% (rounded to nearest, as in #218: 1,085 → 73%). Withmainat400e590the suite collects 1,405 tests, so the 9 READMEs now say1400+. Overlap: #230, #232 and #241 change the same README number; whichever merges later adds its own delta in a one-line rebase.Linked issue: Refs #115 (f16).
Verification
Linux (Arch, Python 3.14.10), no C++ runtime, no GPU (runtime and GPU tests skip), rebased on
main400e590:The suite is green on this machine since #237 and #238 merged.
Not run: the Windows CI job and GPU/WARP. There is no HLSL change; the HLSL refusal is tested on the CPU.
Oracle and test data
New
tests/test_rdna2_exec_cmpf16.py(48 tests). Expected masks come from a hand-labelled relation of 12 (S0, S1) pairs, with junk high halves that a 32-bit compare would see. The pairs cover:The tests:
v_cmpxin VOPC and VOP3, writing EXEC only;const(0);abs/negon bit 15;v_cmp_class_f16with one value per class against each single mask bit (unused bits 10 and 11 included), withconst(3), with inline 1.0 as the mask (0x3C00: no class bit), and withnegon S0;Failure case: 46 of the 48 fail on
main. The 2 that pass are the HLSL refusals.Not measured on hardware: no RDNA 2 GPU was available here. The semantics follow the ISA text and the existing f32/f16 rules of the interpreter.
Checklist
E_NOTIMPL), never a fake success. (Unsourced forms raiseUntranslatednaming the instruction.)test_readme_sync.pychecks it).Made with AI assistance (Claude Code).
🤖 Generated with Claude Code