startup: keep gfx2hlsl f32 n-forms, o and u exact under FXC and DXC #1942
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1949"
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 R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-24T22:00:27Z.
Fixes #1936. Builds on the bit test from #1930 (merged); rebased onto
maincd5508e9.What
This is the narrow per-predicate fix agreed on #1936. Compiler flags are unchanged.
nltnlengtnge!(a OP b)!(ORDERED && a OP b)o(a == a && b == b)ORDEREDu(a != a || b != b)!ORDEREDORDEREDis the integer test(w & 0x7fffffffu) <= 0x7f800000uon both source words, read before neg/abs, aslg/nlguse since #1930.neqand the ordered relations are unchanged: both compilers keep them exact on NaN (measured below).Why
The startup cache compiles every
gfx2hlslpair with FXC and no flags (translate_to). Neither compiler keeps float compares IEEE-strict unless asked:!(a < b)toge a, b, and likewise for<=,>,>=. Sonlt/nle/ngt/ngegave 0 on every NaN pair, where the ISA gives 1.a != aanda == a. Souwas constant 0 andoconstant 1.With the integer NaN test in front, any rewrite of the float relation keeps the ISA result.
Tests
tests/startup_gfx2hlsl_f32_nan_check.py:gfx2hlsl.py, the controls fail._warp,_hardware):lg/nlg(13 of them) writes four results per pixel: e32, and e64 with(-a, |b|),(-|a|, -b)and(|a|, b). The six also keep pixels throughv_cmpx_*_e64. 16 × 16 pixels cover every source pair, compiled with default-flag FXCps_5_1and DXCps_6_0.f,oandudon't)./Gisand-Gis.binary <llvm-mc>anddecode <libLLVM>round-trip the 19 fixtures through LLVM 15. Both are added to the CI LLVM job.tests/startup_gfx2hlsl_f32_lg_check.pypinned the old text of these six conditions. That pin moves to the new test; the other 7 conditions stay pinned there.Results
Commit
583178d4(onmaincd5508e9); Windows 11 build 26300; Windows SDK 10.0.26100.0 FXC and DXC; D3D12 debug layer on.1002:7550), driver 32.0.31044.16./Gis(recorded)-Gis(recorded)nltnlengtngeouBoth backends flushed denormal compare sources to signed zero, which D3D allows, consistently across fixtures. WARP and the RX 9070 XT agree in every cell, so the bytecode decides it.
Not covered
v_cmp_class_*, which are not lowered.🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T22:20:04Z.
Ran both checks and broke all six changed predicates one at a time
Windows 11 build 26300.9974, device-free:
Each predicate reverted to its pre-#1936 text, one at a time, running only the new check:
nlt→!({0} < {1})nle→!({0} <= {1})ngt→!({0} > {1})nge→!({0} >= {1})o→({0} == {0} && {1} == {1})u→ `({0} != {0}u→({2})(the negation dropped, i.e.ubecomeso)The last one matters:
oanduare complements, so a test that only compared each against its own expected string would let aswapped pair through if both were wrong the same way. Yours catches the single-character version.
The edit to the existing
lgcheck does not weaken itRemoving six conditions from
UNCHANGEDand skipping them in thechangedloop is the kind of edit that quietly drops coverage, soI checked it two ways:
{'lg', 'nlg'} | set(NAN_FORMS), so a condition missing from both tables stillfails the coverage line rather than being silently unchecked;
neq→({0} == {1})caught,lt→{0} <= {1}caught.
So the six moved out, six moved in, and nothing fell between them.
What I like about the shape
o = ORDEREDandu = !ORDEREDreuses the integer test rather than writing a second NaN predicate, which is the reason abackend cannot fold either to a constant. The comment names the two compiler behaviours (
!Gis/-Gis) that forced this, so alater reader knows why the text is not simply
a == a.What this does not establish
The whole point is what FXC and DXC emit, and this check compares emitted text and evaluates it on the CPU — the compiler side
rests on the measurements in the description.
x != xfolding under DXC without-Gisis asserted there, not re-measured here; Ihave no DXC in this environment. That limitation is the honest one for this PR, and it is stated.
Verdict
Reviewed. Six behaviours, seven mutations, all caught, and the neighbouring check keeps its teeth.
Notes
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-24T22:21:41Z.
Hardware run of head
583178d4on two GPU families the PR text does not list, plus WARP. Windows 11 Pro 26100.9168, DXC and FXC from Windows SDK 10.0.26100,devpreset, debug layer unavailable here. The adapter was selected withXBOX2WINDOWS_ADAPTER.startup_gfx2hlsl_f32_nan_*startup_gfx2hlsl_f32_lg_*startup_gfx2hlsl_f32_nanandstartup_gfx2hlsl_f32_lgpass.recorded:observations (old and new text with and without/Gis, and "without the NaN bit test" under FXC and DXC) are identical across the three adapters. Each is "all 256 pixels matched", with the same denormal note.LLVM 15 (local):
decodewithLLVM-C.dll15.0.7: PASS.binarynot run. My localllvm-mcis a stand-in overclang -cc1as, which does not support-show-encoding, so the failure there is mine, not the PR's.No changes made.