shader: lower v_min_f64 and v_max_f64 in the direct compute path #3530

Merged
legacy-code-archaeologist merged 1 commit from upstream-pr/3530 into main 2026-11-30 09:01:43 +00:00
legacy-code-archaeologist commented 2026-11-29 23:34:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-29T23:34:11Z.


Summary

Lowers v_min_f64 and v_max_f64 in the direct C++ compute path. They were refused with direct DXIL lowering for <name> (VOP3 probe, see #3518). The lowering uses 32-bit integer operations only (no double, no 64-bit integer shader ops), so it does not depend on the approach #3518 settles for binary64 arithmetic.

  • For a NaN and a number, and for signed zeros, the rules are the ones the f32 forms are checked against in tests/shader_signed_zero_minmax_check.py (reference_word): the number wins over a NaN, and -0 orders below +0.
  • Two NaNs give a NaN. The f32 reference has no such case, so returning the first operand quieted is an assumption here, and the doc says so.
  • Each pair maps to an unsigned two-word key in numeric order: a negative value has all its bits inverted, a positive one gets its sign bit set.
  • Abs/neg act on bit 63.
  • The ops are accepted only under the default MODE for the shared f16/f64 fields; the binary16 MODE tracking now also covers them.
  • Refused: clamp, omod, op_sel, constants, literals, an odd SGPR source.

Refs #3518, refs #2935. Independent of #3529 (v_ldexp_f64); git merge-tree against it and main is clean.

Tests

tests/native_minmax_f64_check.py (ir, controls, hardware), tests/cmake/native_minmax_f64.cmake, docs/experiments/native-direct-minmax-f64.md. The VOP3 words were assembled with LLVM 15.0.7.

On main 2ff74a6a plus this change, Windows 10.0.26100:

  • ctest --preset dev --no-tests=error -R '^native_minmax_f64_' -V:
    • ir passed: 161 cases, 966 words bit for bit through the IR interpreter of native_f16_alu_check.py, NaN included. The cases are 5 readback cases, 6 edge cases and a seeded sweep of 150, many with equal high words.
    • controls passed: no double, no i64 and no float compare in the module; 4 refusals; zero-equal, NaN-preferring and high-word-only references each differ.
    • hardware skipped (77). This machine's only D3D12 FL 12_0 adapter does not report SM 6.6 with wave32, so the readback is unmeasured.
  • Source mutants of native_compute_ir_dump, each rebuilt and then restored: comparing only the high words, letting a NaN win, or comparing the keys signed each fails ir.
  • ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' -j 2: 139/139 passed.

Not established: whether gfx1013 returns a signalling NaN operand quieted instead of the number. The f32 reference ignores any NaN, and so does this lowering.

AI-assisted: written with Claude Code. I reviewed it and ran the commands above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5556357777 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3530). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-29T23:34:11Z. --- ## Summary Lowers `v_min_f64` and `v_max_f64` in the direct C++ compute path. They were refused with `direct DXIL lowering for <name>` (VOP3 probe, see #3518). The lowering uses **32-bit integer operations only** (no double, no 64-bit integer shader ops), so it does not depend on the approach #3518 settles for binary64 arithmetic. - For a NaN and a number, and for signed zeros, the rules are the ones the f32 forms are checked against in `tests/shader_signed_zero_minmax_check.py` (`reference_word`): the number wins over a NaN, and -0 orders below +0. - Two NaNs give a NaN. The f32 reference has no such case, so returning the first operand quieted is an assumption here, and the doc says so. - Each pair maps to an unsigned two-word key in numeric order: a negative value has all its bits inverted, a positive one gets its sign bit set. - Abs/neg act on bit 63. - The ops are accepted only under the default MODE for the shared f16/f64 fields; the binary16 MODE tracking now also covers them. - Refused: clamp, omod, op_sel, constants, literals, an odd SGPR source. Refs #3518, refs #2935. Independent of #3529 (`v_ldexp_f64`); `git merge-tree` against it and `main` is clean. ## Tests `tests/native_minmax_f64_check.py` (`ir`, `controls`, `hardware`), `tests/cmake/native_minmax_f64.cmake`, `docs/experiments/native-direct-minmax-f64.md`. The VOP3 words were assembled with LLVM 15.0.7. On `main` `2ff74a6a` plus this change, Windows 10.0.26100: - `ctest --preset dev --no-tests=error -R '^native_minmax_f64_' -V`: - `ir` **passed**: 161 cases, 966 words bit for bit through the IR interpreter of `native_f16_alu_check.py`, NaN included. The cases are 5 readback cases, 6 edge cases and a seeded sweep of 150, many with equal high words. - `controls` **passed**: no double, no i64 and no float compare in the module; 4 refusals; zero-equal, NaN-preferring and high-word-only references each differ. - `hardware` **skipped (77)**. This machine's only D3D12 FL 12_0 adapter does not report SM 6.6 with wave32, so the readback is unmeasured. - Source mutants of `native_compute_ir_dump`, each rebuilt and then restored: comparing only the high words, letting a NaN win, or comparing the keys signed each fails `ir`. - `ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' -j 2`: 139/139 passed. Not established: whether gfx1013 returns a signalling NaN operand quieted instead of the number. The f32 reference ignores any NaN, and so does this lowering. AI-assisted: written with Claude Code. I reviewed it and ran the commands above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Alexofbulgaria commented 2026-11-30 04:13:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Alexofbulgaria on 2026-11-30T04:13:29Z.


Intel Arc A770 readback passed for v_min_f64 and v_max_f64

Tested on my Intel Arc A770 (8086:56a0), driver 32.0.101.9175, Windows build 26300.10075. Release build with MSVC 14.44.35207 and DXC 1.9.2602.17. I used the repository's synthetic fixtures. Source commit 7cc9994ad150af7133bf3204a15d90b6f111fb0a.

I ran ctest --test-dir <release-build> --no-tests=error -R '^native_minmax_f64_(ir|controls|hardware)$' -V. All three tests passed with zero skips.

  • IR: 966 words matched bit for bit across 161 cases.
  • DXIL controls: Passed, including the invalid-form checks.
  • A770 hardware: All 2,064 readback words matched the reference across the five-case fixture, including guard words. NaNs matched by class.

WARP: The same fixture and reference, run with --direct-warp, skipped with exit 77 at the Shader Model 6.6 and wave32 capability check. WARP arithmetic remains unverified.

AI assisted with setup and reporting. The test runs executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7268579637 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3530#issuecomment-7268579637). Originally posted by [Alexofbulgaria](https://github.com/Alexofbulgaria) on 2026-11-30T04:13:29Z. --- ### Intel Arc A770 readback passed for `v_min_f64` and `v_max_f64` Tested on my Intel Arc A770 (`8086:56a0`), driver `32.0.101.9175`, Windows build `26300.10075`. Release build with MSVC `14.44.35207` and DXC `1.9.2602.17`. I used the repository's synthetic fixtures. Source commit `7cc9994ad150af7133bf3204a15d90b6f111fb0a`. I ran `ctest --test-dir <release-build> --no-tests=error -R '^native_minmax_f64_(ir|controls|hardware)$' -V`. All three tests passed with zero skips. - **IR:** 966 words matched bit for bit across 161 cases. - **DXIL controls:** Passed, including the invalid-form checks. - **A770 hardware:** All 2,064 readback words matched the reference across the five-case fixture, including guard words. NaNs matched by class. **WARP:** The same fixture and reference, run with `--direct-warp`, skipped with exit 77 at the Shader Model 6.6 and wave32 capability check. WARP arithmetic remains unverified. AI assisted with setup and reporting. The test runs executed locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3530
No description provided.