feat: half-precision compares (v_cmp[x]_*_f16, v_cmp[x]_class_f16) in the HLSL recompiler #250
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!250
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/250/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:27 UTC · original
lcg007xd-c:feat/hlsl-f16-compares→main· +218 −15 · 5 files · 1 commits · merged 2026-11-26 00:15 UTCChange
The HLSL recompiler now translates the 68 f16 compare encodings that #244 added to the interpreter:
v_cmp[x]_{f,lt,…,tru}_f16andv_cmp[x]_class_f16, in VOPC and VOP3, for wave32 and wave64. Until now it refused them.The code is a new module,
emu/rdna2_hlsl_cmpf16.py(about 50 lines), with one branch each in the VOPC and VOP3 paths ofrdna2_hlsl.pyandrdna2_hlsl_wave64.py:rdna2_hlsl_f16._operand): a register's low half, an inline float as binary16 (0x3C00), a literal's low half. VOP3abs/negact on bit 15 (rdna2_hlsl_f16._modified).F16ToF32, which is exact (an f16 denormal is a normal f32), and the existing f32 conditions are reused (compare_condition), so NaN is tested apart as in #134.v_cmp_class_f16reads the f16 bits through a newClassF16helper, because widening would make a signalling NaN quiet and a denormal normal.op_sel,clamp,omod, andabs/negon the class mask. The f16 compares are routed before the SDWA path, so their SDWA/DPP forms are refused by name too.Linked issue: Refs #115 (f16).
Verification
Linux (Arch, Python 3.14.10), no C++ runtime, no GPU:
GPU parity: Windows CI only. CI run 45704586464 (WARP):
tests/test_rdna2_hlsl_cmpf16.py11 passed, the 4 GPU tests included; whole suite 1411 passed, 3 skipped. Not run on an AMD or NVIDIA card.Locally: I have no Windows,
dxcor WARP; the Windows CI job runs them. On the CPU I checked that:F16ToF32,IsNanF32,ClassF16andBallot64where expected.Oracle and test data
New
tests/test_rdna2_hlsl_cmpf16.py:0x3C00; a literal's low half; abs/neg on bit 15; refusals of SDWA, op_sel, clamp and abs/neg on the mask; wave64 usingBallot64.v_cmpandv_cmpx, in VOPC and VOP3, under a partial EXEC (68 masks, in two programs);The inputs are the hand-labelled pairs of #244 (±0, quiet and signalling NaN, ± denormals, ±inf, neighbours), one value per class against single class bits, and pseudo-random words, all with junk high halves.
The interpreter tests of #244 that asserted the HLSL refusal are removed, since the recompiler now translates these instructions.
Made with AI assistance (Claude Code).
🤖 Generated with Claude Code
@LooperSalty on GitHub · 2026-11-25 21:56 UTC · original
Thanks — this one is approved, but it now conflicts with main after #242, #244 and #248 were merged (mostly the README RDNA 2 line, plus shared rdna2 files for some). Could you merge or rebase onto main, recount the README line with
rdna2_exec.coverage()on the merged tree (all 9 languages), and push? I will merge it as soon as CI is green.@lcg007xd-c on GitHub · 2026-11-25 22:01 UTC · original
Rebased onto
main(9a06443); the only conflict was therdna2_hlsl_wave64.pyimport line next to #248'sLDS_ADD_TID. No README change in this one.