fix(shader): flush scalar f16 add/mul/sub denormals to signed zero #2987
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2987"
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?
Imported from boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-10T19:48:55Z.
What
On
main, scalar f16 add/mul/sub ignoreFLOAT_MODEf16 denormal bits and keep denormals the hardware flushes.float16Binarynow flushes inputs when denorm16 bit 0 is clear and results when bit 1 is clear (nearest-even, known float mode). Multiply checks tininess after rounding to 11 significant bits (0x387ff000); add/sub use0x38800000.v_sub_f16/v_subrev_f16share the same helper. Unknown float mode and other rounding modes stay as onmain. NaN payload selection is unchanged (still driver-dependent).Tested
CachyOS Linux; RTX 4070 Ti (NVIDIA), Radeon 610M (RADV / gfx1036 hw-oracle), lavapipe (CI ICD).
7fffvs hardwarefe00), and 40 of the 70 (denormal x infinity in v_mul_f16) moved from an infinity to that NaN.agc_driver_float16_rounding(add and mul only) fails on main with the line above and passes on the branch on all three drivers.0x3bff*0x0400→0,0x3c01*0x03ff→0x0400(after-rounding at threshold0x387ff000).check_conventions.py --base origin/main;git diff --check.Not tested here: Windows, packed f16, ternary f16, directed
round16≠ 0. Sub and subrev are covered by the replay above, not byagc_driver_float16_rounding.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:51:43Z.
Measured on RDNA2 (gfx1035) with the HW oracle:
v_add/sub/subrev/mul_f16over 10492 operand pairs in all four f16 denormal modes, at IEEE 0/1 and FP16_OVFL 0/1, match this PR's lowering bit for bit (NaN results compared as NaN only), and so do the 32 × 4 test vectors including the FP16_OVFL override and the VOP3clampforms.agc_driver_float16_roundingpasses on current main and fails without the change. The macos-15-intel write-watch failure was a flake; it passes on rerun. Merging.Optional follow-up: the test only runs add and mul, so a sub/subrev row set in ctest would keep those two covered.