tombox-xshader: order -0 below +0 in float min/max, as RDNA2 does #388
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!388
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-388"
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 18:37 UTC · original
SchmashinPrunes:minmax-signed-zero→main· +35 −12 · 2 files · 1 commits · open@omonkeyz, this came out of running the ISA sweep on RDNA2 silicon (#385/#387). I compared the translator's output with the gfx1036 output on every lane, including lanes the sweep models leave undefined.
The bug
Float min/max of equal zeros:
v_min_f32,v_max_f32,v_min3/max3/med3_f32, the f16 forms andv_pk_min/max_f16. The translator emitted HLSLmin/max, which leaves the choice between +0 and −0 to the host.On gfx1036, −0 orders below +0:
v_min_f32v_max_f32v_min3_f32v_max3_f32v_med3_f32The f16 forms behave the same. How the translator compared:
v_min_f32,v_max_f32,v_max_f16andv_med3_f16returned the wrong zero, on WARP and on an RX 9060 XT.v_min3/max3/med3_f32,v_min_f16,v_min3/max3_f16andv_pk_min/max_f16were wrong on WARP and matched on AMD, because both followed their host.These are among the most used float ops in the title corpus (
v_max3_f32about 24k uses,v_med3_f32about 7.7k).Change
tb_fmin/tb_fmaxin the prelude. They return the hostmin/maxunless the operands compare equal. In that case they combine the signs: OR for min, AND for max. That only matters for ±0. NaN handling is unchanged.v_med3now takes the same NaN branch asv_med3_f32: themin3of the inputs when any input is NaN. gfx1036 returns that too, for example(NaN, +0, −54.5)gives −54.5.v_min/max_f64is unchanged. No f64 signed-zero difference showed up.Tests
New
exec_vop::basic::float_min_max_order_signed_zeros_as_rdna2: 14 cases over 10 mnemonics, taken from the gfx1036 outputs.tests/exec.rsTOMBOX_EXEC_HW=1),tests/exec.rsThe 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.