startup: gfx2hlsl lowers f32 lg/nlg compares as unordered (wrong for NaN) #1920
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#1920
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@MasterDomino on GitHub · 2026-11-24 21:13 UTC · original
tools/startup/gfx2hlsl.pycompare()lowers the f32 conditionslgasa != bandnlgas!(a != b). In the gfx10 ISA:V_CMP_LG_F32is "less or greater", i.e. ordered and not equal: false when either operand is NaN.V_CMP_NLG_F32is its negation: true when either operand is NaN.HLSL
!=is unordered (true with NaN), so both lowerings give the opposite result whenever an operand is NaN. This applies to the plain,_e64and (with #1915) SDWA forms ofv_cmp_lg_f32,v_cmpx_lg_f32,v_cmp_nlg_f32andv_cmpx_nlg_f32. The other conditions in the table (eq,lt,le,gt,ge,neq,nlt,nle,ngt,nge,o,u) map correctly. One local shader cache on currentmainusesv_cmp_nlg_f32_e643 times.Scope. Lower
lgas(a < b || a > b)andnlgas its negation. Keep the other conditions unchanged. Check howpixel_aotlowerslg/nlgand keep the two consistent; ifpixel_aothas the same issue, note it rather than mixing both into one PR.Acceptance.
v_cmp_lg_f32andv_cmp_nlg_f32with a NaN operand decide pixel output, checked pixel by pixel.!=lowering must fail both.I'd like to take this. It builds on #1915's restructured
compare(), so I'll stack it on that branch, or rebase once #1915 lands.AI-assisted.
@MasterDomino on GitHub · 2026-11-24 21:37 UTC · original
PR: #1930. lg is now ordered-and-unequal behind a bit-level NaN test of both source words, nlg its negation; other conditions unchanged. One finding that shaped it: DXC without
-Gismarks the float compares fast, and on the RX 9070 XTa < b || a > balone returned 1 for lg and nlg on all 156 NaN pairs — hence the bit test (pixel_aot already lowers lg this way). Checks: 510 f32 forms × 256 value pairs (±0, denormals, ±inf, quiet/signalling/payload NaN) against the ISA reference; draws with 88 unequal, 12 equal and 156 NaN pairs — FXC and DXC, WARP and RX 9070 XT, every pixel matches; the old!=lowering fails every fixture. f32 SDWA compares stay refused.AI-assisted.