Repository navigation
startup: keep gfx2hlsl f32 n-forms, o and u exact under FXC and DXC - #1949
Conversation
The startup cache compiles gfx2hlsl pairs with FXC and no flags, and neither compiler keeps float compares IEEE-strict unless asked. FXC compiled !(a < b) to ge (and likewise for <=, >, >=), so v_cmp nlt, nle, ngt and nge gave 0 on every NaN pair; DXC folded a != a and a == a, so u was constant 0 and o constant 1. WARP and an RX 9070 XT agreed, and /Gis or -Gis restored the ISA result. The n-forms now read !(ORDERED && a OP b), and o and u read ORDERED and !ORDERED, with ORDERED the bit test of both source words that lg uses since R0Y00#1920. neq is unchanged. Compiler flags are unchanged. tests/startup_gfx2hlsl_f32_nan_check.py evaluates every f32 form under IEEE compares and under models of both rewrites, and draws every lowered condition but lg/nlg with FXC and DXC; the pre-fix text fails on the compiler that rewrote it and matches that rewrite's image. Strict-flag runs are recorded as a diagnostic. Fixes R0Y00#1936 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dfdcb7e to
583178d
Compare
Ran both checks and broke all six changed predicates one at a timeWindows 11 build 26300.9974, device-free: out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_f32_nan_check.py # exit 0
out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_f32_lg_check.py # exit 0Each predicate reverted to its pre-#1936 text, one at a time, running only the new check:
The last one matters: The edit to the existing
|
|
Hardware run of head 583178d on 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,
LLVM 15 (local):
No changes made. |
compare() refused every v_cmp_*_f32_sdwa and v_cmpx_*_f32_sdwa until the f32 predicates were exact on NaN (#1930, #1949). DWORD selections now read the register as binary32 with neg/abs as in the e64 form, so a src0_sel:DWORD src1_sel:DWORD compare emits the e64 text, NaN bit test included. Byte and word selections are refused: the selected field is always +0 or a denormal, so the result depends on the binary32 denormal mode, which gfx2hlsl does not read. pixel_aot refuses the same forms. sext() is integer-only and refused; LLVM 15 does not decode the bit on a float source. clamp, omod, dst_sel and dst_unused stay refused, and class compares are unchanged. LLVM's SIPeepholeSDWA models the sub-dword case as zero-extension read as binary32 bits; the RDNA 2 ISA guide gives only the SDWAB fields. tests/startup_gfx2hlsl_f32_sdwa_check.py: - builds every f32 SDWA form and checks the 720 DWORD/DWORD forms against the e64 text and the ISA reference: 256 NaN/denormal pairs under the IEEE, FXC and DXC models; - refuses all 34,560 byte/word forms with the denormal-mode message; - uses the text before #1930/#1949 as its negative control; - draws 30 DWORD fixtures with default-flag FXC ps_5_1 and DXC ps_6_0. The vopc_sdwa and f32_lg checks no longer assert the blanket refusal. They now check that DWORD selections lower as the e64 form and that byte/word selections are refused with the new message. Refs #1906 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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