shader: lower SDWA forms of the f32 comparisons in pixel_aot #332
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/337"
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 Its3rr0rsWRLD on 2026-11-21T22:36:58Z.
Change
This lowers the SDWA forms of the 16
v_cmp_*_f32predicates when bothsrc0_selandsrc1_selareDWORD. With whole-dword selections an SDWA compare reads its operands exactly as the e32/e64 form does, so the new branch produces the same condition tracking and the same HLSL. A byte or word selection would compare a zero-extended field as binary32, which depends on the unmeasured binary32 denormal mode, so those forms are refused. LLVM 15 prints the mask asvcc_lo/sNin wave32 andvcc/s[N:N+1]in wave64. Both go through the existingLANE_MASKhandling.This is independent of #329 and #334. It touches neither their helpers nor the lines they edit.
Verification
Commit
b860dd5plus this change, Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC.pixel_aot_hardware: Passed on NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088.pixel_aot_warp: Passed on WARP 10.0.26100.9818.b860dd5. The 20 extra draws are the four predicate groups × five input pairs below. Every draw reportsdebug_errors=0andmax_absolute_error=0.tests/pixel_aot_check.py binarypasses with the four SDWA predicate groups added to the binary fixtures: LLVM 15.0.6llvm-mcandllvm-objcopy, disassembled throughlibLLVM-17.soandlibLLVM-18.soon Linux. The controls,tests/docs_links_check.pyandtests/bidi_controls_check.pypass.Evidence and follow-up
predicate_group(first, sdwa=True)writes the same four compares as the existing groups in SDWA form, with an SGPRsrc0. The new draw check repeats the existing inputs for every group: less, equal (-0 and +0), greater, and NaN on either side. A reference that inverts each group's unordered result must reportpixel_mismatch, and it does. A control asserts that the translated HLSL is identical to the e32 groups and that aWORD_1selection is refused. The translator onb860dd5rejects the SDWA compares.Not covered:
v_cmpx_*_f32_sdwa, which writes EXEC, andv_cmp_class_f32_sdwa, which would follow #293.This branch merges cleanly with #288, #293, #324, #329 and #334.
Checklist
AI-assisted: yes. Written with Claude Opus 5.5; verified on the hardware listed above.
🤖 Generated with Claude Code
https://claude.ai/code/session_01X1EBSe6YfE2ivQChRsx1hc
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T08:16:26Z.
Review: APPROVED
Reviewed and integrated main at
f250761. Preserved both the SCC tests and the SDWA fixture. On Windows I ran the merged pixel controls and check_sdwa_predicate_draws with the Windows SDK DXC and Microsoft WARP (driver 10.0.26100.9818, debug layer enabled). All 20 positive draws matched the reference over 4,096 pixels each, including unordered comparisons; the inverted unordered controls reported the expected mismatches. The added translator pattern stays limited to full-dword selectors.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T08:20:07Z.
The physical GPU also passed check_sdwa_predicate_draws at
f250761on Windows 11 25H2 build 26200.9974, NVIDIA GeForce RTX 4060 Laptop GPU, driver 32.0.16.1656, D3D12 debug layer enabled. All 20 positive draws had maximum absolute error 0 across 4,096 pixels (16,384 channels per draw), with zero debug warnings or errors. The four deliberately inverted unordered references were detected.