startup: lower v_ldexp_f32 to ldexp32 in gfx2hlsl (Refs #2618) #2913

Manually merged
github merged 3 commits from github-bot/gh-2913 into gh-pr/2913/base 2026-11-27 04:23:53 +00:00 AGit
Owner

@⁠Holastor on GitHub · 2026-11-26 19:29 UTC · original
Holastor:fix/gfx2hlsl-v-ldexp-f32 → main · +397 −6 · 4 files · 3 commits · merged 2026-11-27 04:19 UTC

Change

Refs #2618

RDNA 2 VOP3A instruction v_ldexp_f32 computes exact binary32 scaling by 2^delta on a float value and signed 32-bit integer exponent. While pixel_aot.py already lowers it via the bitwise IEEE-754 helper ldexp32 (preserving signed zero, subnormals, infinity, and NaN independently of driver FTZ modes), gfx2hlsl.py previously lacked lowering for v_ldexp_f32, causing translation refusals across pipelines that encounter this instruction.

  • Add ldexp32() to the common shader preamble in Pipeline.common().
  • Add Stage.op_v_ldexp_f32() lowering to ldexp32(), accepting float input modifiers on src0 (negation, absolute value) and output modifiers (such as clamp), while validating and decoding src1 as a signed 32-bit integer exponent.
  • Parenthesize negated negative inline float literals in Stage.f() as (-(-0.5)) when the float representation begins with - to avoid the HLSL pre-decrement syntax (--0.5).
  • Reject float modifiers on src1 in disassembly and assembly text.
  • Reject v_ldexp_f32_e32, SDWA, DPP, and unused src2 or modifier bits in VOP3 machine-code encodings.
  • Add tests/startup_gfx2hlsl_ldexp_check.py verifying helper parity with tools/pixel_aot.py, translation correctness across operand combinations, refusal of unencoded forms, and negative controls against mutants.
  • Register new test fixture in CTest and CI check lists.

Verification

Commit 78d7a404, based on upstream/main at 6ee878d8. Windows 11, Python 3.14.

python -B tests/startup_gfx2hlsl_ldexp_check.py
python -B tests/startup_gfx2hlsl_compute_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
python -B tests/run_checks_parallel_check.py
  • Controls: All 5 verification commands pass.
    • Translation of v_ldexp_f32 emits ldexp32 with expected HLSL expressions across float source modifiers on src0 (negation, absolute value, combined), exponent formats on src1 (inline integer, negative inline integer, SGPR/user data, VGPR), and output modifiers (clamp, mul:2).
    • Refusal controls:
      • Float negation or absolute modifiers on integer exponent (-s4, -v2, |s4|, abs(s4)) are rejected.
      • Exponent literals out of 32-bit range (0x100000000) are rejected.
      • Invalid operand counts and non-VGPR destinations are rejected.
      • Disallowed encodings (_e32, SDWA, DPP forms) are rejected.
      • Machine-code VOP3 check_encoding rejects NEG/ABS on exponent and unused src2 bits.
    • Negative controls (mutants):
      • Under a mutant removing op_v_ldexp_f32, translation raises Unsupported('v_ldexp_f32').
      • Under a mutant treating exponent as float (bypassing integer validation), float modifiers on exponent escape detection.
      • Under a mutant altering the helper body in Pipeline.common(), definition parity against tools/pixel_aot.py fails.
    • Synthetic decode and lower: A synthetic VOP3A v_ldexp_f32 word decodes, parses, and lowers cleanly through Stage.

Evidence and follow-up

  • Registration: tests/cmake/startup_gfx2hlsl_ldexp.cmake, tests/checks/python-linux/startup_gfx2hlsl_ldexp.txt.
  • Follow-up: Does not affect existing pixel_aot lowering. Does not measure console behavior or a title.

AI-assisted.

**@⁠Holastor** on GitHub · 2026-11-26 19:29 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2913) `Holastor:fix/gfx2hlsl-v-ldexp-f32` → `main` · +397 −6 · 4 files · 3 commits · merged 2026-11-27 04:19 UTC ## Change Refs #2618 RDNA 2 VOP3A instruction `v_ldexp_f32` computes exact binary32 scaling by `2^delta` on a float value and signed 32-bit integer exponent. While `pixel_aot.py` already lowers it via the bitwise IEEE-754 helper `ldexp32` (preserving signed zero, subnormals, infinity, and NaN independently of driver FTZ modes), `gfx2hlsl.py` previously lacked lowering for `v_ldexp_f32`, causing translation refusals across pipelines that encounter this instruction. - Add `ldexp32()` to the common shader preamble in `Pipeline.common()`. - Add `Stage.op_v_ldexp_f32()` lowering to `ldexp32()`, accepting float input modifiers on `src0` (negation, absolute value) and output modifiers (such as `clamp`), while validating and decoding `src1` as a signed 32-bit integer exponent. - Parenthesize negated negative inline float literals in `Stage.f()` as `(-(-0.5))` when the float representation begins with `-` to avoid the HLSL pre-decrement syntax (`--0.5`). - Reject float modifiers on `src1` in disassembly and assembly text. - Reject `v_ldexp_f32_e32`, SDWA, DPP, and unused `src2` or modifier bits in VOP3 machine-code encodings. - Add `tests/startup_gfx2hlsl_ldexp_check.py` verifying helper parity with `tools/pixel_aot.py`, translation correctness across operand combinations, refusal of unencoded forms, and negative controls against mutants. - Register new test fixture in CTest and CI check lists. ## Verification Commit 78d7a404, based on upstream/main at 6ee878d8. Windows 11, Python 3.14. ```powershell python -B tests/startup_gfx2hlsl_ldexp_check.py python -B tests/startup_gfx2hlsl_compute_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py python -B tests/run_checks_parallel_check.py ``` - **Controls:** All 5 verification commands pass. - Translation of `v_ldexp_f32` emits `ldexp32` with expected HLSL expressions across float source modifiers on `src0` (negation, absolute value, combined), exponent formats on `src1` (inline integer, negative inline integer, SGPR/user data, VGPR), and output modifiers (`clamp`, `mul:2`). - Refusal controls: - Float negation or absolute modifiers on integer exponent (`-s4`, `-v2`, `|s4|`, `abs(s4)`) are rejected. - Exponent literals out of 32-bit range (`0x100000000`) are rejected. - Invalid operand counts and non-VGPR destinations are rejected. - Disallowed encodings (`_e32`, SDWA, DPP forms) are rejected. - Machine-code VOP3 check_encoding rejects NEG/ABS on exponent and unused `src2` bits. - **Negative controls (mutants):** - Under a mutant removing `op_v_ldexp_f32`, translation raises `Unsupported('v_ldexp_f32')`. - Under a mutant treating exponent as float (bypassing integer validation), float modifiers on exponent escape detection. - Under a mutant altering the helper body in `Pipeline.common()`, definition parity against `tools/pixel_aot.py` fails. - **Synthetic decode and lower:** A synthetic VOP3A `v_ldexp_f32` word decodes, parses, and lowers cleanly through `Stage`. ## Evidence and follow-up - Registration: `tests/cmake/startup_gfx2hlsl_ldexp.cmake`, `tests/checks/python-linux/startup_gfx2hlsl_ldexp.txt`. - Follow-up: Does not affect existing pixel_aot lowering. Does not measure console behavior or a title. AI-assisted.
Refs #2618

RDNA 2 VOP3A instruction v_ldexp_f32 computes exact binary32 scaling by 2^delta on a float value and signed 32-bit integer exponent. While pixel_aot.py already lowers it via the bitwise IEEE-754 helper ldexp32 (preserving signed zero, subnormals, infinity, and NaN), gfx2hlsl.py previously lacked lowering for v_ldexp_f32, causing translation refusals across pipelines that use this instruction.

- Add ldexp32() to the common shader preamble in Pipeline.common().
- Add Stage.op_v_ldexp_f32() lowering to ldexp32(), accepting float modifiers on src0 and output modifiers (such as clamp), while validating and decoding src1 as a signed 32-bit integer exponent.
- Reject float modifiers on src1 in disassembly and assembly text.
- Reject v_ldexp_f32_e32, SDWA, DPP, and unused src2 or modifier bits in VOP3 machine-code encodings.
- Add tests/startup_gfx2hlsl_ldexp_check.py verifying float input modifiers, integer exponent formats, output clamp, encoding refusals, and negative controls against mutants. Register the test in CTest and CI check lists.
- Reject DPP forms of v_ldexp_f32 in Stage.dpp alongside VOP3_ONLY_VEC_U.
- Parenthesize negated negative inline float literals in Stage.f() to avoid HLSL pre-decrement syntax.
- Verify exact ldexp32 helper definition parity between Pipeline.common() and tools/pixel_aot.py with mutant negative control.
- Add test coverage for DPP refusal and negative inline float negation.
Remove check_real_cache_sample and reference to local shader cache key, replacing it with check_decode_and_lower exercising synthetic VOP3A machine-code decoding and Stage lowering.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:28:41 +00:00
Author
Owner

@⁠Leyukaka on GitHub · 2026-11-26 20:02 UTC · original

Review of head 3b17c83a, by reading the diff against main 6ee878d8 (not run).

The ldexp32 arithmetic reads as correct:

  • The ±512 clamp keeps INT_MIN and INT_MAX safe.
  • Overflow gives sign | 0x7f800000.
  • Subnormal results round to nearest even, including the 2^-150 tie and the carry into the smallest normal.
  • Subnormal inputs are normalised, and ±0 and ±inf pass through.
  • The body matches the one in tools/pixel_aot.py.

Three points:

  1. No test compiles or executes the gfx2hlsl.py copy of ldexp32.
    • Every assertion in tests/startup_gfx2hlsl_ldexp_check.py is a substring check of the emitted HLSL or of a refusal message.
    • check_real_cache_sample is skipped unless a local out/ file exists.
    • Neither negative control touches the helper body: one removes the handler, the other only asserts that a float-exponent mutant accepts -s4.
    • A wrong body would still pass. A body that fails to compile is only caught indirectly, by the existing draw tests that compile the shared preamble; none of them calls ldexp32.
    • The pixel_aot.py copy is executed by tests/pixel_fp32_vulkan_check.py, but nothing ties the two copies together. An equality check against that body, or a compiled and executed call of the helper, would close this.
  2. The DPP path does not refuse it. _lower() sends _dpp to dpp(), which only refuses VOP3_ONLY_VEC_U. dpp_pair() then ends with self.lower(base, ...), which now finds op_v_ldexp_f32. By reading, v_ldexp_f32_dpp v0, v1, v2 quad_perm:[1,1,3,3] row_mask:0xf bank_mask:0xf in a straight-line pixel stage after s_wqm is accepted. This is text input only: v_ldexp_f32 is VOP3-only on gfx10, so the disassembler never produces it. Adding it to the refusal next to VOP3_ONLY_VEC_U would keep the handler from accepting a form the hardware has no encoding for.
  3. Minor, and older than this PR: NEG on a negative inline float src0 (sources 241, 243, 245, 247) goes through f() as (--0.5), which should fail to compile rather than give a wrong value. This handler inherits it, and no test covers it.

AI-assisted.

**@⁠Leyukaka** on GitHub · 2026-11-26 20:02 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2913#issuecomment-7202223817) Review of head `3b17c83a`, by reading the diff against main `6ee878d8` (not run). The `ldexp32` arithmetic reads as correct: - The ±512 clamp keeps INT_MIN and INT_MAX safe. - Overflow gives `sign | 0x7f800000`. - Subnormal results round to nearest even, including the 2^-150 tie and the carry into the smallest normal. - Subnormal inputs are normalised, and ±0 and ±inf pass through. - The body matches the one in `tools/pixel_aot.py`. Three points: 1. **No test compiles or executes the `gfx2hlsl.py` copy of `ldexp32`.** - Every assertion in `tests/startup_gfx2hlsl_ldexp_check.py` is a substring check of the emitted HLSL or of a refusal message. - `check_real_cache_sample` is skipped unless a local `out/` file exists. - Neither negative control touches the helper body: one removes the handler, the other only asserts that a float-exponent mutant accepts `-s4`. - A wrong body would still pass. A body that fails to compile is only caught indirectly, by the existing draw tests that compile the shared preamble; none of them calls `ldexp32`. - The `pixel_aot.py` copy is executed by `tests/pixel_fp32_vulkan_check.py`, but nothing ties the two copies together. An equality check against that body, or a compiled and executed call of the helper, would close this. 2. **The DPP path does not refuse it.** `_lower()` sends `_dpp` to `dpp()`, which only refuses `VOP3_ONLY_VEC_U`. `dpp_pair()` then ends with `self.lower(base, ...)`, which now finds `op_v_ldexp_f32`. By reading, `v_ldexp_f32_dpp v0, v1, v2 quad_perm:[1,1,3,3] row_mask:0xf bank_mask:0xf` in a straight-line pixel stage after `s_wqm` is accepted. This is text input only: `v_ldexp_f32` is VOP3-only on gfx10, so the disassembler never produces it. Adding it to the refusal next to `VOP3_ONLY_VEC_U` would keep the handler from accepting a form the hardware has no encoding for. 3. Minor, and older than this PR: NEG on a negative inline float `src0` (sources 241, 243, 245, 247) goes through `f()` as `(--0.5)`, which should fail to compile rather than give a wrong value. This handler inherits it, and no test covers it. AI-assisted.
Author
Owner

@⁠Holastor on GitHub · 2026-11-26 20:14 UTC · original · edited 2026-11-26 20:16 UTC

Thank you for the thorough review and catch!

Addressed all three points in commit 4276e725:

  1. Helper body parity & test execution: Added check_helper_parity() in tests/startup_gfx2hlsl_ldexp_check.py asserting exact definition parity between Pipeline.common() and tools/pixel_aot.py (with a mutant negative control), as well as pure-Python execution of the bitwise IEEE-754 arithmetic across the edge cases (+/-0, +/-inf, NaN, overflow, underflow, and subnormal 2^-150 tie-to-even rounding).
  2. DPP refusal: Added v_ldexp_f32 to Stage.dpp() refusals next to VOP3_ONLY_VEC_U, ensuring that any v_ldexp_f32_dpp text forms (including quad-swaps) are rejected early. Added test coverage in check_refusals().
  3. Negative inline float formatting: In Stage.f(), parenthesized negated negative float literals as (-(-0.5)) when the float representation begins with -, avoiding the --0.5 pre-decrement syntax in HLSL. Added test coverage in check_translations().
**@⁠Holastor** on GitHub · 2026-11-26 20:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2913#issuecomment-7202452381) · edited 2026-11-26 20:16 UTC Thank you for the thorough review and catch! Addressed all three points in commit 4276e725: 1. **Helper body parity & test execution**: Added `check_helper_parity()` in `tests/startup_gfx2hlsl_ldexp_check.py` asserting exact definition parity between `Pipeline.common()` and `tools/pixel_aot.py` (with a mutant negative control), as well as pure-Python execution of the bitwise IEEE-754 arithmetic across the edge cases (+/-0, +/-inf, NaN, overflow, underflow, and subnormal 2^-150 tie-to-even rounding). 2. **DPP refusal**: Added `v_ldexp_f32` to `Stage.dpp()` refusals next to `VOP3_ONLY_VEC_U`, ensuring that any `v_ldexp_f32_dpp` text forms (including quad-swaps) are rejected early. Added test coverage in `check_refusals()`. 3. **Negative inline float formatting**: In `Stage.f()`, parenthesized negated negative float literals as `(-(-0.5))` when the float representation begins with `-`, avoiding the `--0.5` pre-decrement syntax in HLSL. Added test coverage in `check_translations()`.
Author
Owner

@⁠MasterDomino on GitHub · 2026-11-26 20:19 UTC · original · requested changes

Review of head 4276e725 on main 6ee878d8, with local runs. I started on 3b17c83a. The notes below cover both commits.

Environment: Windows 11 build 26300.9974, Python 3.13 (out/pe-env), Windows SDK 10.0.26100 FXC and DXC.

What passes

  • The five commands in the description exit 0 on 3b17c83a, and startup_gfx2hlsl_ldexp_check.py exits 0 on 4276e725.
  • All 132 tests/startup_gfx2hlsl_*_check.py run on 4276e725, because the f()/half f() negation change is shared by every float handler. 130 pass. The other two, export_null_draw and mul24_align_draw, need the CTest arguments and exit 1 the same way on main when run bare.
  • The ldexp32 body is line-for-line identical to tools/pixel_aot.py. Extracted with a cs entry that calls it, it compiles with fxc /T cs_5_0 and dxc -T cs_6_0. The new check_helper_parity() now pins that.
  • On 3b17c83a, v_ldexp_f32_dpp v0, v1, v2 quad_perm:[1,1,3,3] row_mask:0xf bank_mask:0xf was accepted through the pair path, which was @⁠Leyukaka's point 2. 4276e725 adds it to the dpp() refusal, so that is fixed.
  • The (-(...)) change only changes output that began with --, which never compiled, so it cannot change a previously valid translation.
  • Local shader-request census, counts only, on 3b17c83a. I took a copy of a local cache with results stripped and ran gfx2hlsl.py --pending with X2W_FXC= (translation only), once with main and once with the PR. 4,088 records each:
main this PR
translated (ok) 321 321
refused at v_ldexp_f32 31 0
records whose outcome changed — 31 (all former v_ldexp_f32 refusals)
previously ok, now refused — 0

The 31 records now stop at their next instruction: 15 at a wave operation, 6 s_nand_b*, 4 s_lshl*_add_u*, 2 descriptor, and 1 each of v_mul_f*, v_fmac_f*, s_or_b* and s_load. No record finishes yet, but nothing regresses.

Change requested (still open on 4276e725)

check_real_cache_sample reads a local title shader request and commits its cache key. It opens out/startup/shader_cache/req_<key>.a at tests/startup_gfx2hlsl_ldexp_check.py:225, and the description names the same key. The project accepts only source-built or synthetic fixtures (AGENTS.md "Hard rules"), and on every other machine, CI included, the check silently does nothing. Please remove the function and its call, and take the key out of the description. If you want the decode path covered, a source-built VOP3 v_ldexp_f32 word run through G.decode and lower does that without local data.

With that removed, this is ready from my side.

AI-assisted; the commands above were run locally.

**@⁠MasterDomino** on GitHub · 2026-11-26 20:19 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2913#pullrequestreview-6080061298) · **requested changes** Review of head `4276e725` on `main` `6ee878d8`, with local runs. I started on `3b17c83a`. The notes below cover both commits. **Environment:** Windows 11 build 26300.9974, Python 3.13 (`out/pe-env`), Windows SDK 10.0.26100 FXC and DXC. **What passes** - The five commands in the description exit 0 on `3b17c83a`, and `startup_gfx2hlsl_ldexp_check.py` exits 0 on `4276e725`. - All 132 `tests/startup_gfx2hlsl_*_check.py` run on `4276e725`, because the `f()`/half `f()` negation change is shared by every float handler. 130 pass. The other two, `export_null_draw` and `mul24_align_draw`, need the CTest arguments and exit 1 the same way on `main` when run bare. - The `ldexp32` body is line-for-line identical to `tools/pixel_aot.py`. Extracted with a `cs` entry that calls it, it compiles with `fxc /T cs_5_0` and `dxc -T cs_6_0`. The new `check_helper_parity()` now pins that. - On `3b17c83a`, `v_ldexp_f32_dpp v0, v1, v2 quad_perm:[1,1,3,3] row_mask:0xf bank_mask:0xf` was accepted through the pair path, which was @⁠Leyukaka's point 2. `4276e725` adds it to the `dpp()` refusal, so that is fixed. - The `(-(...))` change only changes output that began with `--`, which never compiled, so it cannot change a previously valid translation. - Local shader-request census, counts only, on `3b17c83a`. I took a copy of a local cache with results stripped and ran `gfx2hlsl.py --pending` with `X2W_FXC=` (translation only), once with `main` and once with the PR. 4,088 records each: | | `main` | this PR | |---|---|---| | translated (`ok`) | 321 | 321 | | refused at `v_ldexp_f32` | 31 | 0 | | records whose outcome changed | — | 31 (all former `v_ldexp_f32` refusals) | | previously `ok`, now refused | — | 0 | The 31 records now stop at their next instruction: 15 at a wave operation, 6 `s_nand_b*`, 4 `s_lshl*_add_u*`, 2 descriptor, and 1 each of `v_mul_f*`, `v_fmac_f*`, `s_or_b*` and `s_load`. No record finishes yet, but nothing regresses. **Change requested (still open on `4276e725`)** **`check_real_cache_sample` reads a local title shader request and commits its cache key.** It opens `out/startup/shader_cache/req_<key>.a` at `tests/startup_gfx2hlsl_ldexp_check.py:225`, and the description names the same key. The project accepts only source-built or synthetic fixtures (AGENTS.md "Hard rules"), and on every other machine, CI included, the check silently does nothing. Please remove the function and its call, and take the key out of the description. If you want the decode path covered, a source-built VOP3 `v_ldexp_f32` word run through `G.decode` and `lower` does that without local data. With that removed, this is ready from my side. AI-assisted; the commands above were run locally.
Author
Owner

@⁠Holastor on GitHub · 2026-11-26 20:31 UTC · original

Thank you for the verification and the census breakdown!

Addressed in commit 78d7a404:

  • Removed check_real_cache_sample() and the reference to the local shader request key.
  • Replaced it with check_decode_and_lower(), which tests decoding and Stage lowering using a synthetic source-built VOP3A v_ldexp_f32 instruction without any local cache files.
  • Updated the PR description to remove the cache key reference and document the synthetic decode verification.
**@⁠Holastor** on GitHub · 2026-11-26 20:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2913#issuecomment-7202790440) Thank you for the verification and the census breakdown! Addressed in commit 78d7a404: - Removed `check_real_cache_sample()` and the reference to the local shader request key. - Replaced it with `check_decode_and_lower()`, which tests decoding and `Stage` lowering using a synthetic source-built VOP3A `v_ldexp_f32` instruction without any local cache files. - Updated the PR description to remove the cache key reference and document the synthetic decode verification.
Author
Owner

@⁠MasterDomino on GitHub · 2026-11-26 21:08 UTC · original · approved these changes

Approving at 78d7a404.

  • check_real_cache_sample and the request key are gone, from the test and from the description. check_decode_and_lower builds a VOP3A word with opcode 0x362 (v_ldexp_f32 on gfx10), decodes it and lowers it through Stage without any local file.
  • Run here on this head (Windows 11 build 26300.9974, Python 3.13): startup_gfx2hlsl_ldexp_check.py, startup_gfx2hlsl_compute_check.py, docs_links_check.py and bidi_controls_check.py all exit 0.
  • Since 4276e725 only the test file changed. My earlier run of all 132 startup_gfx2hlsl_*_check.py on 4276e725 therefore still covers the translator: 130 passed, and the two draw checks need CTest arguments and fail the same way on main when run bare.
  • The CI required checks pass on this head.
  • The census in my earlier review still applies to the lowering: 31 of 4,088 local records move past v_ldexp_f32, and none regresses.

@⁠Leyukaka's three points were addressed in 4276e725, and mine in 78d7a404.

AI-assisted.

**@⁠MasterDomino** on GitHub · 2026-11-26 21:08 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2913#pullrequestreview-6080498152) · **approved these changes** Approving at `78d7a404`. - `check_real_cache_sample` and the request key are gone, from the test and from the description. `check_decode_and_lower` builds a VOP3A word with opcode `0x362` (`v_ldexp_f32` on gfx10), decodes it and lowers it through `Stage` without any local file. - Run here on this head (Windows 11 build 26300.9974, Python 3.13): `startup_gfx2hlsl_ldexp_check.py`, `startup_gfx2hlsl_compute_check.py`, `docs_links_check.py` and `bidi_controls_check.py` all exit 0. - Since `4276e725` only the test file changed. My earlier run of all 132 `startup_gfx2hlsl_*_check.py` on `4276e725` therefore still covers the translator: 130 passed, and the two draw checks need CTest arguments and fail the same way on `main` when run bare. - The CI required checks pass on this head. - The census in my earlier review still applies to the lowering: 31 of 4,088 local records move past `v_ldexp_f32`, and none regresses. @⁠Leyukaka's three points were addressed in `4276e725`, and mine in `78d7a404`. AI-assisted.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-27 04:09 UTC · original · reviewed

Solid V_LD_EXP_F32 lowering implementation. The ldexp32 helper mirrors pixel_aot.py exactly (verified by check_helper_parity), and the test suite is the gold standard for this project.

Key observations:

  1. The f() method fix for double-negation (line 2523) is spot-on: -(-0.5) was previously rendered as --0.5, which HLSL does not support. The new logic checks text.startswith('-') and wraps with parens to produce (-(-0.5)) instead.

  2. Encoding validation correctly isolates neg/abs bits on src1 exponent (w1[30] for neg, w0[9 for abs) and unused src2 field (w1[26:18]), rejecting them before they can be misinterpreted.

  3. The float_sources=1 marking in SCA ensures the exponent operand is treated as integer-only, with modifier detection refusing -s4, -v2, |s4|, abs(s4) on the exponent side.

  4. Negative controls are excellent: removing the handler entirely verifies it's present, and the mutant_op that treats the exponent as float verifies the refusal catches float modifiers.

  5. ldexp32 parity simulation tests: normal scaling, signed zero preservation, infinity/NaN passthrough, clamped overflow/underflow, and subnormal rounding (both tie-to-even cases). This covers the entire IEEE 754 half-life of a float.

  6. One small suggestion for PR #2618 tracking: could you add a one-line reference comment in the helper emission block linking to the issue, similar to the V_PERM_B32 and V_LERP_U8 helpers?

Looks ready to merge after the existing CHANGES_REQUESTED comments are addressed.

**@⁠KelboLive** on GitHub · 2026-11-27 04:09 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2913#pullrequestreview-6083385443) · **reviewed** Solid V_LD_EXP_F32 lowering implementation. The ldexp32 helper mirrors pixel_aot.py exactly (verified by check_helper_parity), and the test suite is the gold standard for this project. Key observations: 1. The f() method fix for double-negation (line 2523) is spot-on: `-(-0.5)` was previously rendered as `--0.5`, which HLSL does not support. The new logic checks `text.startswith('-')` and wraps with parens to produce `(-(-0.5))` instead. 2. Encoding validation correctly isolates neg/abs bits on src1 exponent (w1[30] for neg, w0[9 for abs) and unused src2 field (w1[26:18]), rejecting them before they can be misinterpreted. 3. The float_sources=1 marking in SCA ensures the exponent operand is treated as integer-only, with modifier detection refusing `-s4`, `-v2`, `|s4|`, `abs(s4)` on the exponent side. 4. Negative controls are excellent: removing the handler entirely verifies it's present, and the mutant_op that treats the exponent as float verifies the refusal catches float modifiers. 5. ldexp32 parity simulation tests: normal scaling, signed zero preservation, infinity/NaN passthrough, clamped overflow/underflow, and subnormal rounding (both tie-to-even cases). This covers the entire IEEE 754 half-life of a float. 6. One small suggestion for PR #2618 tracking: could you add a one-line reference comment in the helper emission block linking to the issue, similar to the V_PERM_B32 and V_LERP_U8 helpers? Looks ready to merge after the existing CHANGES_REQUESTED comments are addressed.
github-bot changed target branch from main to gh-pr/2913/base 2026-11-27 04:23:51 +00:00
github manually merged commit 78d7a4047d into gh-pr/2913/base 2026-11-27 04:23:53 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.