Skip to content

startup: lower v_mul_hi_u32 in gfx2hlsl - #2425

Closed
stan495 wants to merge 1 commit into
R0Y00:mainfrom
stan495:startup/v-mul-hi-u32
Closed

stan495 wants to merge 1 commit into
R0Y00:mainfrom
stan495:startup/v-mul-hi-u32

Conversation

@stan495

@stan495 stan495 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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 7092683)
  • 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)

@MasterDomino MasterDomino left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants