startup: lower v_mul_hi_u32 in gfx2hlsl #2417

Closed
stan495 wants to merge 1 commit from upstream-pr/2425 into main
stan495 commented 2026-11-25 16:21:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T16:21:24Z.


Summary

Lower RDNA 2 unsigned 32-bit high-half vector multiply ( _mul_hi_u32 / _mul_hi_u32_e64) in ools/startup/gfx2hlsl.py by adding 'v_mul_hi_u32': (2, 'mul_hi_u32({0}, {1})') to VEC_U, reusing the existing overflow-free 32-bit mul_hi_u32(uint, uint) HLSL helper already emitted for s_mul_hi_u32.

  • ** ools/startup/gfx2hlsl.py**: Add _mul_hi_u32 to VEC_U.
  • ** ests/startup_gfx2hlsl_mul_hi_u32_check.py**: Pure-Python controls verifying _mul_hi_u32 and _mul_hi_u32_e64, literal and negative inline-constant operands, exact 64-bit high-half evaluation of mul_hi_u32 with no 32-bit intermediate overflow across boundary pairs, refusal of modifiers (clamp, -v2) and wrong operand counts, and a negative control that removes _mul_hi_u32 from VEC_U.
  • CMakeLists.txt, .github/workflows/windows.yml, AGENTS.md: Register startup_gfx2hlsl_mul_hi_u32_check.py.

Verification

  • Commit: 70c4b571 (based on upstream/main 7092683a)
  • Commands & Results:
    • python -B tests/startup_gfx2hlsl_mul_hi_u32_check.py -> PASS
    • python -B tests/startup_gfx2hlsl_int_med3_check.py -> PASS
    • python -B tests/startup_gfx2hlsl_operand_count_check.py -> PASS (VEC_U: 42 operations, 0 failed)
    • python -B tests/startup_gfx2hlsl_handler_arity_check.py -> PASS (33 accepted instructions, 99 scalar refusals, 16 load refusals)
    • python -B tests/docs_links_check.py -> PASS (19 Markdown files, 464 links)
    • python -B tests/bidi_controls_check.py -> PASS (1723 tracked files)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6608773753 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2425). Originally posted by [stan495](https://github.com/stan495) on 2026-11-25T16:21:24Z. --- ## Summary Lower RDNA 2 unsigned 32-bit high-half vector multiply ( _mul_hi_u32 / _mul_hi_u32_e64) in ools/startup/gfx2hlsl.py by adding 'v_mul_hi_u32': (2, 'mul_hi_u32({0}, {1})') to VEC_U, reusing the existing overflow-free 32-bit mul_hi_u32(uint, uint) HLSL helper already emitted for s_mul_hi_u32. - ** ools/startup/gfx2hlsl.py**: Add _mul_hi_u32 to VEC_U. - ** ests/startup_gfx2hlsl_mul_hi_u32_check.py**: Pure-Python controls verifying _mul_hi_u32 and _mul_hi_u32_e64, literal and negative inline-constant operands, exact 64-bit high-half evaluation of mul_hi_u32 with no 32-bit intermediate overflow across boundary pairs, refusal of modifiers (clamp, -v2) and wrong operand counts, and a negative control that removes _mul_hi_u32 from VEC_U. - **CMakeLists.txt, .github/workflows/windows.yml, AGENTS.md**: Register startup_gfx2hlsl_mul_hi_u32_check.py. ## Verification - **Commit**: `70c4b571` (based on upstream/main 7092683a) - **Commands & Results**: - `python -B tests/startup_gfx2hlsl_mul_hi_u32_check.py` -> PASS - `python -B tests/startup_gfx2hlsl_int_med3_check.py` -> PASS - `python -B tests/startup_gfx2hlsl_operand_count_check.py` -> PASS (VEC_U: 42 operations, 0 failed) - `python -B tests/startup_gfx2hlsl_handler_arity_check.py` -> PASS (33 accepted instructions, 99 scalar refusals, 16 load refusals) - `python -B tests/docs_links_check.py` -> PASS (19 Markdown files, 464 links) - `python -B tests/bidi_controls_check.py` -> PASS (1723 tracked files)
upstream-sync closed this pull request 2026-11-25 17:01:38 +00:00
MasterDomino commented 2026-11-25 17:01:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T16:23:45Z.

Review: COMMENTED


Review of head 70c4b571 (base 7092683a).

P1 (process): this duplicates #1747, which is further along. The two can't both land.

  • Same change: the translator edit is identical to #1747's. Both add 'v_mul_hi_u32': (2, 'mul_hi_u32({0}, {1})') to VEC_U, reusing the mul_hi_u32 helper main already emits for s_mul_hi_u32. The two would conflict on that VEC_U line and would register two tests for the same op.
  • #1747 has more coverage: binary <llvm-mc> and draw modes, a helper-arithmetic check on 361 edge pairs, a carry-drop mutation, the encoded literal from #1792, and an experiments entry. R0Y00 re-reviewed it today at 02328b26: Release 5/5 on WARP and RTX 4060 Laptop, FXC and DXC matched all 12 operand pairs, and the LLVM round trip passed. Earlier duplicates (#1793, #1952) were closed in its favour.
  • #2425's own test is translator-level only: no GPU draw and no binary mode, which gfx2hlsl lowering PRs normally carry.

Suggestion: close this in favour of #1747. If you want to keep the parts #1747 doesn't have, the explicit negative control that removes the VEC_U entry and the negative inline-constant operand could go to #1747's author as a small follow-up to tests/startup_gfx2hlsl_mul_hi_check.py. The AGENTS.md list entry would then point at that test instead.

What I ran (Windows 11 build 26300)

  • This PR: python -B tests/startup_gfx2hlsl_mul_hi_u32_check.py gives PASS.
  • For comparison, #1747 at 02328b26: it merges cleanly with current main. Controls pass; binary with llvm-mc 15.0.7 gives fixture words match llvm-mc. The draws pass with FXC ps_5_1 and DXC ps_6_0, debug layer on, on WARP 10.0.26100.9818 and on an AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010), with the low-word mutation diverging. Posted on #1747 too.

Nit

  • PR body escapes: the body has stray escape characters. \t and \v were rendered, so tools/ reads as a tab plus "ools" and v_mul_hi_u32 shows as _mul_hi_u32.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6061096537 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2425#pullrequestreview-6061096537). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T16:23:45Z. **Review:** COMMENTED --- Review of head `70c4b571` (base `7092683a`). **P1 (process): this duplicates #1747, which is further along. The two can't both land.** - **Same change:** the translator edit is identical to #1747's. Both add `'v_mul_hi_u32': (2, 'mul_hi_u32({0}, {1})')` to `VEC_U`, reusing the `mul_hi_u32` helper `main` already emits for `s_mul_hi_u32`. The two would conflict on that `VEC_U` line and would register two tests for the same op. - **#1747 has more coverage:** `binary <llvm-mc>` and `draw` modes, a helper-arithmetic check on 361 edge pairs, a carry-drop mutation, the encoded literal from #1792, and an experiments entry. R0Y00 re-reviewed it today at `02328b26`: Release 5/5 on WARP and RTX 4060 Laptop, FXC and DXC matched all 12 operand pairs, and the LLVM round trip passed. Earlier duplicates (#1793, #1952) were closed in its favour. - **#2425's own test is translator-level only:** no GPU draw and no `binary` mode, which `gfx2hlsl` lowering PRs normally carry. Suggestion: close this in favour of #1747. If you want to keep the parts #1747 doesn't have, the explicit negative control that removes the `VEC_U` entry and the negative inline-constant operand could go to #1747's author as a small follow-up to `tests/startup_gfx2hlsl_mul_hi_check.py`. The `AGENTS.md` list entry would then point at that test instead. ### What I ran (Windows 11 build 26300) - **This PR:** `python -B tests/startup_gfx2hlsl_mul_hi_u32_check.py` gives `PASS`. - **For comparison, #1747 at `02328b26`:** it merges cleanly with current `main`. Controls pass; `binary` with llvm-mc 15.0.7 gives `fixture words match llvm-mc`. The draws pass with FXC `ps_5_1` and DXC `ps_6_0`, debug layer on, on WARP 10.0.26100.9818 and on an **AMD Radeon RX 9070 XT** (1002:7550, driver 32.0.32029.2010), with the low-word mutation diverging. Posted on #1747 too. ### Nit - **PR body escapes:** the body has stray escape characters. `\t` and `\v` were rendered, so `tools/` reads as a tab plus "ools" and `v_mul_hi_u32` shows as `_mul_hi_u32`. AI-assisted; commands listed were executed locally.

Pull request closed

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!2417
No description provided.