startup: lower v_cmp_class_f16 and v_cmpx_class_f16 in gfx2hlsl #1812
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!1812
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1812/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?
@tedin7 on GitHub · 2026-11-24 19:04 UTC · original
tedin7:x2w-frontier-gfx-cmpclass16→main· +303 −0 · 5 files · 2 commits · closed without mergingRelated to #1723 and #870 (no
Fixes).v_cmp_class_f16andv_cmpx_class_f16had no lowering intools/startup/gfx2hlsl.py.Change
The instruction tests whether the binary16 value in the low half of SRC0 falls in one of ten classes named by the mask in SRC1: bit 0 signalling NaN, 1 quiet NaN, 2 -inf, 3 -normal, 4 -denormal, 5 -0, 6 +0, 7 +denormal, 8 +normal, 9 +inf.
class_f16(reached throughop_v_cmp_class_f16andop_v_cmpx_class_f16) reads the encoding, so a denormal stays a denormal whatever the denormal mode and a NaN keeps its signalling bit. The_e32and_e64spellings, a vector-condition, scalar or exec destination and a narrowed EXEC followcompare(). Theabsandnegthat the instruction encodes act on the sign bit of the half (abs clears it, then neg flips it). Refused:op_sel,clampand any other modifier, a source that is not a register (inline float, literal), unbalanced|, a wrong operand count and the SDWA spelling.The new code sits in its own methods and does not touch
compare()orcommon(), where #1798 lowersv_cmp_class_f32; the two do not share a helper.Tests
tests/startup_gfx2hlsl_cmp_class_f16_check.py, registered inCMakeLists.txt(startup_gfx2hlsl_cmp_class_f16) and in.github/workflows/windows.yml:-v1,|v1|,-|v1|) are compiled as C++ from the emitted statements and run over all 65,536 binary16 values and 25 masks (the ten single class bits, none, all, mixed and bits above 9) against a reference that classifies through Python's binary16 conversion. Six planted faults in the emitted text must each be detected.-1mask) and eight refusals.binary <llvm-mc>: five spellings assemble to recorded encodings (value in SRC0, mask in SRC1).Verified (Linux)
binary llvm-mc-19passes (gfx1013).gfx2hlsl.py, each failing the check, original restored: signalling bit read from the wrong mantissa bit, denormal threshold off by one, mask test changed from&to|, neg flipping the wrong bit.git diff --check origin/main...HEAD,tests/docs_links_check.py,tests/bidi_controls_check.py: pass.git merge-tree: no conflicts withmain, #1755, #1778, #1796, #1798, #1699. #1783 already conflicts withmainon its own.Not verified
No draw on a GPU and no HLSL compiler run: the C++ stand-in treats
uintasunsigned, which matches the HLSL semantics used (no signed or float arithmetic is involved).AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-24 19:14 UTC · original
Closing this draft for now to help keep the open PR queue manageable; the branch stays preserved on the fork so it can be reopened once the queue clears.
Pull request closed