tombox-xshader: f16 MODE path NaNs, before-rounding flush and SDWA, as measured on RDNA2 #389
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!389
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-389"
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?
@SchmashinPrunes on GitHub · 2026-11-25 19:38 UTC · original
SchmashinPrunes:mode-path-f16-nan-sdwa→main· +37 −9 · 2 files · 1 commits · open@omonkeyz, this fixes the f16 MODE path: the code used when a shader writes MODE with
s_setreg, or when its initial MODE (PGM_RSRC1) flushes f16/f64 denormals. I found the problems by running the ISA sweep on gfx1036 silicon under five initial MODEs (the #387 harness) and comparing the translator's output with the hardware on every lane, on WARP and on an RX 9060 XT. Only differences seen on both hosts count as translator bugs.What was wrong, with f16/f64 denormals flushed
tb_h_rndtestedx != x, which both hosts fold away for this double. A NaN fell through to the overflow branch and came out as0x7c00. Hit:v_cvt_f16_f32,v_add/sub/subrev/mul_f16,v_fma_f16,v_fmaak/fmamk/fmac_f16,v_ldexp_f16,v_pk_add/mul/fma/fmac_f16andv_fma_mixlo/hi_f16.tb_h_rndnow tests the double's bits, astb_fsubdoes for f32 (#375).0xfe00, for examplev_mul_f16(inf, 0)andv_fma_f16(inf, 0, c). That's the f16 counterpart of the f32 default NaN0xffc00000;v_fma_mix*quiets an f32 signalling-NaN input on silicon (0x7fa97056gives0x7f4b), so the mix call passes the quiet bit.v_fmaak_f16(1 − 2⁻¹¹, 2⁻¹⁴, 0)gives0x0000; the translator rounded it to0x0400and then saw nothing to flush. This is the same before-rounding rule #363 measured for f16 omod.v_fma_mix*is the exception: silicon returns0x0400there in every MODE, so mix keeps its previous behaviour.v_sub/subrev_f16negated with(-x), and WARP keeps a NaN's sign there while AMD flips it. Silicon flips it (v_subrev_f16(NaN, 0)gives0xfe00), so these now flip the sign bit directly. The VOP3negmodifier invop3_modsstill uses(-x); it's shared with the f64 path, so I left it for a follow-up.mode_ownran beforeemit_vec's SDWA lowering. It now steps aside for SDWA, so the lowering materialises the operands and the MODE path handles the plain instruction. In this sweep that refusal had taken down 13 more mnemonics, because each pack is one program.Results
Translator vs gfx1036, number of mnemonics that differ on both hosts:
0x30(f16/f64 flushed)0x00(all flushed)0xf0,0xc0,0xf0+ IEEEThe 20 that remain are out of scope here:
v_mul_lo_i32, absent on gfx103x;v_div_fixup/fmas/scale_f64in the f64 MODE path;v_pack_b32_f16flushing;f16tof32, which the hosts quiet. That one also happens at MODE 0xf0.The IEEE 1 list (signalling-NaN quieting in transcendentals and
v_min/max_f64) is a separate change.Tests
New
f16_flush_mode_nan_tininess_and_sdwa_as_rdna2: 9 cases taken from the gfx1036 outputs, run under f16/f64 flush set bys_setreg. They cover generated NaN (mul, fma), propagated NaN (add, subrev, ldexp, cvt_f16_f32), the before-rounding flush, a default-MODE control for it, and an SDWAv_add_f16.mode.rschange0x7c00, the tininess case gives0x0400, SDWA is refusedtests/exec.rstests/exec.rstombox-xshadersuiteThe PR gate is clean.
🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.