Repository navigation
Description
Found in the refusal census (#870). 1 refused shader:
v_cmp_class_f16_e64 s14, 0x7c01, v0 -> REFUSED: v_cmp_class_f16
Problem
The binary16 class comparison had no lowering. The binary32 form is handled by the class-compare branch (PR #1798), but the half form needs a different helper: the value is the raw binary16 bit pattern in the low half of the operand word, the ten class bits follow the half format (exponent 5 bits, mantissa 10, quiet bit 0x0200), and an abs/neg modifier acts on bit 15 rather than bit 31.
Fix
tools/pixel_aot.py already carried the binary16 helper; it is ported into Pipeline.common() as class16, and the class-compare branch dispatches on the mnemonic:
if base in ('v_cmp_class_f32', 'v_cmpx_class_f32', 'v_cmp_class_f16', 'v_cmpx_class_f16'):
f16 = base.endswith('_f16')
...
cond = '(class16(%s) & %s) != 0u' % (bits, self.u(mask)) # f16Measured on the branch:
| form | before | after |
|---|---|---|
v_cmp_class_f16_e64 s14, 0x7c01, v0 |
refused | s14 = (((class16(0x00007c01u) & v0) != 0u) ? 1u : 0u); |
v_cmpx_class_f16_e64 vcc_lo, v0, -1 |
refused | exec = (((class16(v0) & 0xffffffffu) != 0u) ? 1u : 0u); |
v_cmpx_class_f16_e32 v0, v5 |
refused | exec = (((class16(v0) & v5) != 0u) ? 1u : 0u); |
The abs/neg modifier forms lower to class16((v0 & 0x7fffu)) and class16((v0 ^ 0x8000u)). A float-printed operand is refused by name, because it would otherwise be lowered as its binary32 bit pattern.
Test
startup_gfx2hlsl_cmp_class_f16 builds VOPC-in-VOP3 encodings from the checked-in decoder's layout, decodes them, then translates. Ten checks: the census form, both exec-mask shapes, the abs/neg handling on bit 15, the float-operand refusal, and — value-level — a Python binary16 classifier (written from the IEEE half layout) compared against the emitted helper body evaluated over all 65,536 binary16 patterns.
dev: 3/3 (cmp_class, cmp_class_f16, startup_translator)
release: startup_gfx2hlsl_cmp_class_f16 Passed 3.18 s
Fail-first, three genuine class-bit mutations (all fail the value-level check while the text checks pass):
swap -inf/+inf bits -> FAIL
swap quiet/signaling NaN -> FAIL
swap -subnormal/+subnormal -> FAIL
Depends on #1798
This branch is based on startup/cmp-class (#1798) because the class-compare branch and class32 helper are not on main yet. Merge #1798 first; after that this PR's diff is only the class16 helper, the mnemonic dispatch and the new test.
What this does not establish
- That the emitted HLSL compiles or computes the right predicate on a device — the test compares values from the emitted text; DXC/WARP were not run here.
v_cmp_class_f64and the arithmetic/compare f16 forms that are not class comparisons are out of scope.
AI-assisted (Claude Code).
Activity
ChazY11 commentedon Nov 25, 2026
Claiming this
Environment: x64 Windows 11 build 26300.9974, MSVC 19.44, Windows SDK 10.0.26100, DXC 10.0.26100 (x64), Python 3.13, physical GPU (RTX 5080 Laptop, 32.0.15.8142) and the in-box WARP.
State of
mainat6218beb2, checked rather than assumed:so the dependency you list (#1798, the
class32helper and the class-compare branch) has landed and this is now only the half form.What I will do
class16fromtools/pixel_aot.pyintoPipeline.common()unchanged (the ten class bits from bits [15:0], quiet bit0x0200), listed next toclass32.bitsbeing the operand's raw word, notself.f(value), so an inline0x7c01reaches the helper as0x00007c01uand not as abinary32 float.
abs/negon the half act on bit 15 ((v0 & 0x7fffu),(v0 ^ 0x8000u)), not bit 31, and are applied to the raw word before the helper.the emitted text for the census form, both exec shapes, the
abs/neghandling and the float-operand refusal — and, value level, a Pythonbinary16 classifier written from the IEEE half layout compared against the emitted helper body evaluated over all 65,536 halves.
Negative controls I will run before claiming the fixture is worth anything: three class-bit mutations (swap
-inf/+inf, swap quiet/signaling NaN,swap
-subnormal/+subnormal) must each fail the value-level check while the text checks still pass.Scope boundaries I will keep
v_cmp_class_f64, no f16 arithmetic or ordering compares: they are not class compares.DXC/WARP pass over it, say so and I will add a draw fixture rather than implying the translation was executed.
Nothing else of mine touches these lines: my only open changes are #2053 (an AGENTS.md list fix) and #2063 (a test that pins handler refusal
behaviour), neither of which edits
gfx2hlsl.py.AI-assisted.
startup: lower v_cmp_class_f16 and v_cmpx_class_f16 (issue #1855)
Merge pull request #2092 from ChazY11/startup/cmp-class-f16
R0Y00 commentedon Nov 25, 2026
The encoded 0x7c01 literal now lowers on main via #2092 (8e17f8f). The source-built controls cover that decoded literal, e32/e64 and both execution-mask shapes, and check the emitted binary16 helper against all 65,536 input bit patterns. The slice accepts the tested plain operands and rejects ambiguous immediates and half SDWA. Any additional SDWA coverage can follow in #2020. These checks establish the translator behavior for the reported refusal.