shader: lower gfx1013 v_frexp_mant_f32 and v_ldexp_f32 in pixel_aot #305

Merged
alexander-src merged 2 commits from upstream-pr/310 into main 2026-11-22 04:28:06 +00:00
alexander-src commented 2026-11-21 21:44:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-21T21:44:26Z.


Change

Lower v_frexp_mant_f32 (in both _e32 and _e64 encodings) and v_ldexp_f32 in tools/pixel_aot.py (3 gfx1013 forms).

Both lower through explicit IEEE-754 binary32 bit helpers (frexp_mant32 and ldexp32) in PREAMBLE so subnormals, signed zero, infinity, NaN, round-to-nearest-even underflow, and extreme exponent deltas do not depend on desktop driver flush-to-zero behavior. v_frexp_mant_f32 joins the existing ALU path with source modifiers and clamp; v_ldexp_f32 decodes src0 as float (accepting -, |x|, abs(...)), decodes src1 as a signed 32-bit integer (rejecting float modifiers), and supports clamp.

Add control, binary assembly/disassembly, and D3D12 draw fixtures in tests/pixel_aot_check.py, plus documentation in docs/experiments.md.

Verification

Commit cd1055f on Linux x86_64 (Python 3.14, LLVM 23.1, g++):

  • python3 -B tests/pixel_aot_check.py binary llvm-mc llvm-objcopy libLLVM.so: passed (assembles both new fixtures for gfx1013, extracts, disassembles, lowers, and matches source lowering).
  • C++ bit-exact cross-check (g++ -std=c++17 -O2 -Wall -Wextra -Werror) of frexp_mant32 and ldexp32 extracted directly from pixel_aot.PREAMBLE against std::frexp and std::ldexp: 21/21 frexp_mant32 cases and 588/588 ldexp32 pairs (including +0, -0, subnormals, normal/subnormal tie boundaries, INT32_MIN/INT32_MAX deltas, +/-Inf, and NaN) matched bit-for-bit (asuint).
  • Negative controls against main:tools/pixel_aot.py: rejected v_frexp_mant_f32_e32 (Unsupported instruction 20) and v_ldexp_f32 (Unsupported instruction 21).
  • python3 -B tests/docs_links_check.py, tests/bidi_controls_check.py, tests/rdna2_tools_check.py (26 ran, 1 skipped without LLVM_LIB), and the 5 non-iced_x86 checks in tests/form_coverage_check.py: all passed.
  • Could not run DXC compilation or offscreen_check.exe D3D12 draws locally because this environment is Linux without MSVC/DXC/Windows; check_frexp_ldexp_draws() will execute under the Windows CI job.

Evidence and follow-up

All fixtures are synthetic AMDGPU assembly programs authored inline in tests/pixel_aot_check.py under the repository's MIT license. Semantics follow the AMD RDNA Shader ISA reference.

This shares the int_operand() helper with #306 and #308; whichever lands later will need a small rebase.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted: yes.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6534775534 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/310). Originally posted by [alexander-src](https://github.com/alexander-src) on 2026-11-21T21:44:26Z. --- ## Change Lower `v_frexp_mant_f32` (in both `_e32` and `_e64` encodings) and `v_ldexp_f32` in `tools/pixel_aot.py` (3 gfx1013 forms). Both lower through explicit IEEE-754 binary32 bit helpers (`frexp_mant32` and `ldexp32`) in `PREAMBLE` so subnormals, signed zero, infinity, NaN, round-to-nearest-even underflow, and extreme exponent deltas do not depend on desktop driver flush-to-zero behavior. `v_frexp_mant_f32` joins the existing `ALU` path with source modifiers and `clamp`; `v_ldexp_f32` decodes `src0` as float (accepting `-`, `|x|`, `abs(...)`), decodes `src1` as a signed 32-bit integer (rejecting float modifiers), and supports `clamp`. Add control, binary assembly/disassembly, and D3D12 draw fixtures in `tests/pixel_aot_check.py`, plus documentation in `docs/experiments.md`. ## Verification Commit `cd1055f` on Linux x86_64 (Python 3.14, LLVM 23.1, g++): - `python3 -B tests/pixel_aot_check.py binary llvm-mc llvm-objcopy libLLVM.so`: passed (assembles both new fixtures for `gfx1013`, extracts, disassembles, lowers, and matches source lowering). - C++ bit-exact cross-check (`g++ -std=c++17 -O2 -Wall -Wextra -Werror`) of `frexp_mant32` and `ldexp32` extracted directly from `pixel_aot.PREAMBLE` against `std::frexp` and `std::ldexp`: 21/21 `frexp_mant32` cases and 588/588 `ldexp32` pairs (including `+0`, `-0`, subnormals, normal/subnormal tie boundaries, `INT32_MIN`/`INT32_MAX` deltas, `+/-Inf`, and `NaN`) matched bit-for-bit (`asuint`). - Negative controls against `main:tools/pixel_aot.py`: rejected `v_frexp_mant_f32_e32` (`Unsupported instruction 20`) and `v_ldexp_f32` (`Unsupported instruction 21`). - `python3 -B tests/docs_links_check.py`, `tests/bidi_controls_check.py`, `tests/rdna2_tools_check.py` (26 ran, 1 skipped without `LLVM_LIB`), and the 5 non-`iced_x86` checks in `tests/form_coverage_check.py`: all passed. - Could not run DXC compilation or `offscreen_check.exe` D3D12 draws locally because this environment is Linux without MSVC/DXC/Windows; `check_frexp_ldexp_draws()` will execute under the Windows CI job. ## Evidence and follow-up All fixtures are synthetic AMDGPU assembly programs authored inline in `tests/pixel_aot_check.py` under the repository's MIT license. Semantics follow the [AMD RDNA Shader ISA reference](https://gpuopen.com/wp-content/uploads/2019/08/RDNA_Shader_ISA_5August2019.pdf). This shares the `int_operand()` helper with #306 and #308; whichever lands later will need a small rebase. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted: yes.
upstream-sync closed this pull request 2026-11-24 06:42:21 +00:00
R0Y00 commented 2026-11-24 06:48:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T21:58:54Z.


At cd1055f the merge conflicts are in tests/pixel_aot_check.py. Keep both exponent boundary controls and the landed arithmetic cases.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069854886 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/310#issuecomment-7069854886). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T21:58:54Z. --- At `cd1055f` the merge conflicts are in `tests/pixel_aot_check.py`. Keep both exponent boundary controls and the landed arithmetic cases.
alexander-src commented 2026-11-24 06:48:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-21T22:20:17Z.


Rebased onto main (6ee2406) in a51742b, preserving both exponent boundary fixtures alongside all landed scalar64, v_cvt_f32_f16, and fmaak/fmamk controls. Updated int_operand() to reuse scalar_u32() identically to #306 and #308.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070109726 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/310#issuecomment-7070109726). Originally posted by [alexander-src](https://github.com/alexander-src) on 2026-11-21T22:20:17Z. --- Rebased onto `main` (`6ee2406`) in `a51742b`, preserving both exponent boundary fixtures alongside all landed scalar64, `v_cvt_f32_f16`, and `fmaak`/`fmamk` controls. Updated `int_operand()` to reuse `scalar_u32()` identically to #306 and #308.
R0Y00 commented 2026-11-24 06:48:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T02:56:29Z.


A test merge of a51742b against main conflicts in docs/experiments.md, tests/pixel_aot_check.py and tools/pixel_aot.py. Reconcile with #306’s int_operand and retain its comparison draws along with your exponent-boundary controls. Please refresh the branch and rerun the relevant fixture and Windows CI.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7073227646 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/310#issuecomment-7073227646). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T02:56:29Z. --- A test merge of `a51742b` against main conflicts in `docs/experiments.md`, `tests/pixel_aot_check.py` and `tools/pixel_aot.py`. Reconcile with #306’s `int_operand` and retain its comparison draws along with your exponent-boundary controls. Please refresh the branch and rerun the relevant fixture and Windows CI.
R0Y00 commented 2026-11-24 06:48:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T04:24:37Z.


I resolved the conflicts with #306 and #308 on your branch at 04790b3. The combined pixel_aot_hardware test passed in 58.50 s and pixel_aot_warp in 11.58 s locally. Hardware is close to its 60 s limit, consistent with the measurements in #448. Auto-merge is enabled while CI tests this head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7074160015 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/310#issuecomment-7074160015). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-22T04:24:37Z. --- I resolved the conflicts with #306 and #308 on your branch at 04790b3. The combined pixel_aot_hardware test passed in 58.50 s and pixel_aot_warp in 11.58 s locally. Hardware is close to its 60 s limit, consistent with the measurements in #448. Auto-merge is enabled while CI tests this head.
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!305
No description provided.