Skip to content

startup: lower v_mul_hi_u32 in gfx2hlsl - #1747

Merged
MasterDomino merged 6 commits into
R0Y00:mainfrom
R0D4X:fix/issue-870-gfx2hlsl-mul-hi-u32
Nov 25, 2026
Merged

MasterDomino merged 6 commits into
R0Y00:mainfrom
R0D4X:fix/issue-870-gfx2hlsl-mul-hi-u32

Conversation

@R0D4X

@R0D4X R0D4X commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Refs #870

Summary

  • Lower v_mul_hi_u32 (VOP3A unsigned 32x32 -> high-32 vector multiply) in tools/startup/gfx2hlsl.py by adding it to VEC_U and emitting an overflow-free 16-bit halfword-split mul_hi_u32(uint a, uint b) helper in Pipeline.common() (same decomposition as tools/pixel_aot.py, portable across both FXC ps_5_1 and DXC ps_6_0, which have no scalar umul intrinsic).
  • Preserve strict refusals for unmodeled modifiers (clamp, mul:2, div:2, op_sel, -v, |v|) and wrong operand counts.
  • Add tests/startup_gfx2hlsl_mul_hi_check.py (modeled on tests/startup_gfx2hlsl_bit_alu_check.py) with:
    • Pure-Python translation checks, 361-pair edge-case verification of the emitted mul_hi_u32 helper against ((a * b) >> 32), carry-drop negative control (0xffffffff * 0xffffffff), low-word mutation control, exec-masked emission check, and modifier/operand-count refusal controls.
    • binary <llvm-mc> round-trip verification of all fixture encodings for the Ubuntu pixel-binary CI job.
    • draw <dxc> <offscreen_check> <warp|hardware> [fxc] end-to-end FXC ps_5_1 + DXC ps_6_0 offscreen readback tests across 3 draw sets (12 input pairs) plus a GPU low-word mutation control.
  • Register startup_gfx2hlsl_mul_hi_controls, startup_gfx2hlsl_mul_hi_warp, and startup_gfx2hlsl_mul_hi_hardware in CMakeLists.txt, and wire tests/startup_gfx2hlsl_mul_hi_check.py into pixel-binary and python-linux in .github/workflows/windows.yml.

Verification

  • Base commit: 9ffb8529 (upstream/main)
  • Branch commit: 6c6b638e
  • Host environment: Windows 11 x64 (10.0.26300.9974), MSVC 19.44.35230, Windows SDK 10.0.26100.0, FXC + DXC 1.9.2602.17
  • WARP: Microsoft Basic Render Driver (1414:008c), driver 10.0.26100.9818, D3D12 debug layer enabled
  • Hardware GPU: NVIDIA GeForce RTX 5080 (10de:2c02), driver 32.0.16.2124, D3D12 debug layer enabled

Commands and Observed Results

.\out\pe-env\Scripts\python.exe -B tests/startup_gfx2hlsl_mul_hi_check.py
.\out\pe-env\Scripts\python.exe -B tests/startup_gfx2hlsl_operand_count_check.py
.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
  • Observed: all passed (startup_gfx2hlsl_mul_hi_check.py: 8/8 checks ok; startup_gfx2hlsl_operand_count_check.py: 0 failed across 32 VEC_F and 35 VEC_U ops; docs_links_check.py: 17 files / 365 links ok; bidi_controls_check.py: 1297 files ok).
cmake --preset dev
ctest --preset dev --no-tests=error -j 1 -R '^startup_gfx2hlsl_mul_hi_' -V
  • Observed: 3 passed, 0 skipped, 0 failed (3.20 s total):

    • startup_gfx2hlsl_mul_hi_controls: passed (0.13 s)
    • startup_gfx2hlsl_mul_hi_warp: passed (0.66 s), both FXC ps_5_1 and DXC ps_6_0 matched expected readbacks (fffffffe,00000001,b092ab7b,00000001, 00000000,00000000,0000fffe,0000ffff, 3fffffff,40000001,0001fffd,52c48c43), low-word mutation failed as expected (actual=00000001,00000000,88cf5b62,00020001), debug_errors=0 debug_warnings=0.
    • startup_gfx2hlsl_mul_hi_hardware: passed (2.38 s) on NVIDIA GeForce RTX 5080 (driver 32.0.16.2124, D3D12 debug layer enabled), identical readbacks and mutation failure for both FXC ps_5_1 and DXC ps_6_0, debug_errors=0 debug_warnings=0.
  • Note: tests/startup_gfx2hlsl_mul_hi_check.py binary llvm-mc-15 was not run locally (llvm-mc is not installed on this Windows host); fixture words were cross-checked against tools/disasm_rdna2.py / gfx2hlsl.decode() and are exercised by the Ubuntu pixel-binary CI job.

  • Scope note: these passing fixtures verify v_mul_hi_u32 lowering and desktop GPU execution in isolation; they do not establish full-game startup.

@tedin7 tedin7 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.

Peer review at commit 6c6b638e05aa92412733b1f332c66980c5ea297c (PRODUCTION_REVIEW_ONLY).

Assessment

No P1/P2 issues found.

  • Semantics & overflow safety (tools/startup/gfx2hlsl.py): v_mul_hi_u32 is added to VEC_U (mul_hi_u32({0}, {1})) and lowered via a 16-bit halfword-split mul_hi_u32(uint a, uint b) helper in Pipeline.common(). Every intermediate term (al * bl, (a >> 16) * bl + ((al * bl) >> 16), and (m & 0xffffu) + al * (b >> 16)) is bounded strictly below 2^32, avoiding 32-bit unsigned wraparound across all edge cases including 0xffffffff * 0xffffffff (0xfffffffe). Unmodeled modifiers (clamp, mul:2, div:2, op_sel, -v, |v|) and wrong operand counts remain refused.

Verification

  • Linux checks:
    • python3 -B tests/startup_gfx2hlsl_mul_hi_check.py → 8/8 checks ok (361-pair edge grid, carry-drop negative control, low-word mutation control, exec-masked emission, modifier/operand-count refusals)
    • python3 -B tests/startup_gfx2hlsl_mul_hi_check.py binary llvm-mc-19 → fixture words match llvm-mc
    • python3 -B tests/startup_gfx2hlsl_operand_count_check.py → operand count checks: 0 failed (32 VEC_F, 35 VEC_U)
    • python3 -B tests/docs_links_check.py → Checked 17 Markdown files and 365 links.
    • python3 -B tests/bidi_controls_check.py → Checked 1298 tracked source, script and build/CI files: no bidirectional controls.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at 6c6b638e05aa92412733b1f332c66980c5ea297c:
    • Debug (--preset dev): cmake --build --preset dev --target offscreen_check -- -j 8 (3.47s), ctest --preset dev -R '^(startup_gfx2hlsl_mul_hi_controls|startup_gfx2hlsl_mul_hi_warp|startup_gfx2hlsl_operand_count|startup_translator)$' --parallel 6 --no-tests=error --output-on-failure → 4/4 passed (1.11s).
    • Release /O2 (--preset release): cmake --build --preset release --target offscreen_check -- -j 8 (1.10s), ctest --preset release -R '^(startup_gfx2hlsl_mul_hi_controls|startup_gfx2hlsl_mul_hi_warp|startup_gfx2hlsl_operand_count|startup_translator)$' --parallel 6 --no-tests=error --output-on-failure → 4/4 passed (1.15s).
  • Local mutation checks (each reverted immediately):
    1. Replaced + ((al * bl) >> 16) with + 0u in mul_hi_u32 (tools/startup/gfx2hlsl.py) → caught by tests/startup_gfx2hlsl_mul_hi_check.py (rc=1: emitted helper matches reference on 361 edge pairs: MISMATCH).
    2. Lowered v_mul_hi_u32 to {0} * {1} in VEC_U (tools/startup/gfx2hlsl.py) → caught by tests/startup_gfx2hlsl_mul_hi_check.py (rc=1: four lane calls emitted: MISMATCH).

AI-assisted; commands listed were executed locally.

@tedin7 tedin7 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.

Re-review of #1747 at exact head f2e319ce82111d2aec0c39a0ccabcb9ebb4ad652 (fetched from pull/1747/head, HEAD equals current headRefOid; no conflicts with current main). The previous review was at 6c6b638e.

Verdict: no P1/P2 found. Comment only, not an approval.

What changed since the last review

  • The head moved only through merges of main. I diffed the PR's own change (git diff origin/main...<head> for tools/startup/gfx2hlsl.py, tests/startup_gfx2hlsl_mul_hi_check.py, CMakeLists.txt, .github) at both heads: the same 203 added/removed lines, only hunk positions and context differ. git diff 6c6b638e HEAD -- tests/startup_gfx2hlsl_mul_hi_check.py is empty.
  • Helper arithmetic re-derived by hand: m = ah*bl + ((al*bl)>>16) is at most 2^32 - 2^17 + 1 + 2^16 - 2, and (m & 0xffff) + al*bh is at most 65535 + 2^32 - 2^17 + 1; both stay below 2^32, so no 32-bit wraparound, and the sum equals the true high word.

Commands run locally

  • git diff --check origin/main...HEAD -> exit 0
  • python -B tests/startup_gfx2hlsl_mul_hi_check.py -> 8 checks, all ok (361-pair edge grid, carry-drop control, lane mutation control, exec-masked emission, modifier and operand-count refusals)
  • python -B tests/startup_gfx2hlsl_mul_hi_check.py binary llvm-mc-19 -> fixture words match llvm-mc (llvm-mc-19, the only one on this host; CI pins llvm-mc-15)
  • startup_gfx2hlsl_operand_count_check.py -> operand count checks: 0 failed; startup_translator_check.py -> 0 failed; startup_gfx2hlsl_bit_alu_check.py -> ok
  • docs_links_check.py -> Checked 18 Markdown files and 376 links; bidi_controls_check.py -> Checked 1331 tracked source, script and build/CI files: no bidirectional controls

Mutations (applied to tools/startup/gfx2hlsl.py, suite re-run, then git checkout -- .)

Mutation Result
drop + ((al * bl) >> 16) from the helper killed (361-pair grid mismatch)
lower v_mul_hi_u32 as {0} * {1} killed (four lane calls emitted)
drop the (m >> 16) term killed (grid mismatch)
final >> 16 of the cross term changed to >> 15 killed (grid mismatch)

4/4 killed.

Not run (honest limits)

  • The FXC/DXC compile and D3D12 draw cases (startup_gfx2hlsl_mul_hi_warp|hardware) need DXC, offscreen_check and a D3D12 adapter, none on this Linux host. I did not re-run the Windows results quoted in the earlier review; they were taken at 6c6b638e, and since the PR's own diff is unchanged I have no reason to expect a difference, but they are not reproduced at this head by me.

AI-assisted; commands listed were executed locally.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I tested a local merge into 8150d800. The conflicts are in CMakeLists.txt and .github/workflows/windows.yml; the existing registrations and all three new tests fit together. There is also a semantic merge conflict: main already emits a mul_hi_u32 HLSL helper for s_mul_hi_u32. Keeping the helper from both sides produces a function redefinition in FXC (X3003) and DXC. I kept main’s helper, pointed the vector lowering at it, and updated the carry mutation to exercise the shared helper and assert there is exactly one definition.

The resulting Windows Release candidate passed ctest --test-dir <build> --no-tests=error -j 1 -R '^startup_gfx2hlsl_mul_hi_', 3 passed and 0 skipped. FXC and DXC matched all three readback sets on WARP (10.0.26100.9818) and RTX 4060 Laptop (32.0.16.1656), debug layers enabled with zero errors and warnings. Both low-word mutation controls diverged. The focused operand-count and handler-arity controls also passed. Please merge current main into the PR with both sets of registrations, and reuse main’s helper so the refreshed head can get CI.

R0Y00 commented Nov 25, 2026

Copy link
Copy Markdown
Owner

I fast-forwarded the original branch to aaea481e, preserving your commits. The merge keeps both sets of test registrations and uses main’s existing mul_hi_u32 helper for the scalar and vector forms. The current head passes the multiply, operand-count and handler-arity controls. The same shared-helper change previously passed the FXC/DXC WARP and RTX 4060 Laptop readbacks and LLVM 15.0.7 assembly round trip. The PR can now run its usual checks.

@tedin7 tedin7 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.

Re-review of head aaea481e8b77290e3aa460999b7ff215ef1bfc7b (merge of current main; real diff vs main is 4 files, +233/-1).

Result: no P1, no P2.

Scope checked

  • tools/startup/gfx2hlsl.py:2922: v_mul_hi_u32 added to VEC_U as mul_hi_u32({0}, {1}). It reuses the existing halfword helper (:3190) already used by s_mul_hi_u32, so no new HLSL math. The helper is correct (high word = ah*bh + (middle>>16) + carry from the low-half cross term).
  • Modifiers (clamp, mul:, div:, op_sel, neg/abs) and wrong operand counts stay refused. The exec-masked form is guarded.
  • tests/startup_gfx2hlsl_mul_hi_check.py: CPU evaluation of the emitted helper over 361 edge pairs against (a*b)>>32, a carry-drop control, a low-word mutation control, and FXC 5_1 + DXC 6_0 draw readback on WARP and hardware. The CTest wiring (controls, warp, hardware, SKIP 77) and the windows.yml entries match sibling tests.
  • Clean-room and neutral title: OK. PR is mergeable.

Commands run locally (Linux, in a worktree at this head)

  • git diff --stat origin/main...HEAD: 4 files, 233 insertions, 1 deletion
  • python3 tests/startup_gfx2hlsl_mul_hi_check.py: all 8 controls ok, "Self-test passed."
  • python3 tests/docs_links_check.py: 18 Markdown files, 417 links, ok
  • python3 tests/bidi_controls_check.py: 1519 files, no bidi controls
  • git diff --check origin/main...HEAD: clean
  • Mutation: changed the table entry to mul_hi_u32({1}, {1}). The test failed ("four lane calls emitted"), so it kills the mutation. Reverted with git checkout -- ..

Not run

  • binary mode (no llvm-mc-15 locally) and the draw mode (needs Windows). The Windows WARP/hardware draws should be confirmed by the CI job "Build and test on Windows". It was still pending when I checked, as were the Linux and fixture jobs. I did not queue a separate Win2025 run.

Nit (optional)

  • gfx2hlsl.py:2922: the line is already long. Putting v_mul_hi_u32 on its own line would make later diffs easier to read.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

@R0D4X could you rebase this branch onto current main (or recreate it with just the 3 commits on top of main) and force-push?

Why: the PR page still reports 357 changed files against an old base (23d9d12d), while the real change against current main is 4 files. Other open PRs that only touch shared files are held back by an overlap check because this PR's file list looks huge and gets truncated.

Commands run locally on head aaea481e:

git fetch origin main pull/1747/head:tmp-1747
git rev-list --count tmp-1747 ^origin/main   # 3
git rev-list --count origin/main ^tmp-1747   # 83
git diff --stat origin/main...tmp-1747       # 4 files changed, 233 insertions(+), 1 deletion(-)
gh api repos/R0Y00/Xbox2Windows/compare/main...aaea481e   # ahead 3, behind 83, 4 files
gh pr view 1747 --json changedFiles           # 357

No code changes requested; the content is unchanged by the rebase.

AI-assisted; commands listed were executed locally.

@legacy-code-archaeologist

Copy link
Copy Markdown
Contributor

Ran head aaea481e on three adapters. All pass. Windows 11 build 26100, debug layer unavailable, FXC and DXC from SDK 10.0.26100.0.

Test Adapter Driver Result
startup_gfx2hlsl_mul_hi_controls n/a n/a pass
startup_gfx2hlsl_mul_hi_warp Microsoft Basic Render Driver 10.0.26100.8972 pass
startup_gfx2hlsl_mul_hi_hardware (XBOX2WINDOWS_ADAPTER=Quadro) NVIDIA Quadro M1000M (Maxwell) 32.0.15.7371 pass
startup_gfx2hlsl_mul_hi_hardware (XBOX2WINDOWS_ADAPTER=Intel) Intel HD Graphics 530 (Gen9) 31.0.101.2111 pass

On each adapter, all 8 checks printed ok, and both mutation controls failed as expected, so the shared mul_hi_u32 helper reads back exactly on Maxwell and Gen9 too.

For context on priority: in a local census of start-up shader requests (aggregate counts only), v_mul_hi_u32 in vertex programs is the first refusal for 350 of 520 refused graphics requests, by far the largest single first refusal. Landing this unblocks most vertex stages there. The count is from one local input and is not checked in CI.

AI-assisted.

@R0D4X
R0D4X force-pushed the fix/issue-870-gfx2hlsl-mul-hi-u32 branch from aaea481 to a60128b Compare November 25, 2026 11:55
@R0D4X

R0D4X commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (a60128b4) and force-pushed — the PR now cleanly shows only the 4 changed files (tools/startup/gfx2hlsl.py, tests/startup_gfx2hlsl_mul_hi_check.py, CMakeLists.txt, and .github/workflows/windows.yml) with no functional changes.

@tedin7 tedin7 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 a60128b49e07fec7257912b0829a8256a5c96a90.

P1: duplicate mul_hi_u32 helper, Linux CI is red

  • tools/startup/gfx2hlsl.py:3857 adds a new uint mul_hi_u32(uint, uint) to the shared helper prelude.
  • tools/startup/gfx2hlsl.py:3861 already defines the same helper (from the merged s_mul_hi_u32 slice, #2176). The helper block is emitted into every translated shader.
  • Result: every shader gets two definitions of the same function. HLSL rejects that as a redefinition, so every draw would fail to compile, not only shaders using v_mul_hi_u32.
  • tests/startup_gfx2hlsl_sop2_complement_check.py already catches it. Its mul_hi_helper check fails with AssertionError: return (a >> 16) * (b >> 16) + .... This is the failing Run platform-independent Python checks on Linux job.
  • Fix: delete the new helper at 3857-3858. Keep only the 'v_mul_hi_u32': (2, 'mul_hi_u32({0}, {1})') table entry, which reuses the existing helper. Then re-check that the new test still passes.

Otherwise fine

  • The VEC_U entry is correct: v_mul_hi_u32 is the high 32 bits of the unsigned 64-bit product. The new tests/startup_gfx2hlsl_mul_hi_check.py also covers exec masking, refused modifiers and wrong operand counts. It has WARP and hardware draw tests registered in CMakeLists.txt.
  • Mutation: changing the emitted call to mul_hi_u32({1}, {0} + 1u) is killed by the lowering check (v_mul_hi_u32: four lane calls emitted).
  • Mergeable, title is neutral, no clean-room concerns seen.
  • A Windows run is not worth queuing until the duplicate is removed. With it, the shaders cannot compile.

Commands executed locally

  • git diff --stat origin/main...HEAD: 4 files, +234/-1.
  • python3 -B tests/startup_gfx2hlsl_mul_hi_check.py: controls pass.
  • python3 -B tests/startup_gfx2hlsl_sop2_complement_check.py: FAIL (duplicate helper, see P1).
  • python3 tests/docs_links_check.py: ok (447 links).
  • python3 tests/bidi_controls_check.py: ok.
  • git diff --check origin/main...HEAD: clean.
  • Mutation above, reverted with git checkout -- ..

AI-assisted; commands listed were executed locally.

Remove the duplicate mul_hi_u32 definition introduced during rebase so v_mul_hi_u32 reuses the shared helper from R0Y00#2176.

@tedin7 tedin7 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 2fadf5e (comment only, no approval or merge).

Scope: adds v_mul_hi_u32 to VEC_U in tools/startup/gfx2hlsl.py. It reuses the mul_hi_u32 helper already emitted for s_mul_hi_u32. It also adds tests/startup_gfx2hlsl_mul_hi_check.py, three CTest entries and CI wiring. The title is neutral and the clean-room and licence side looks fine.

Commands executed locally in the PR worktree:

  • git diff --stat origin/main...HEAD: 4 files, +231/-1.
  • gh pr checks 1747: the Linux Python job FAILS. Windows build and test pass. The fixtures job passes.
  • python3 -I -B tests/startup_gfx2hlsl_mul_hi_check.py: FAILS in controls(), test line 124, assert dropped != text (AssertionError).
  • python3 -I -B tests/docs_links_check.py: pass (18 files, 447 links).
  • python3 -I -B tests/bidi_controls_check.py: pass.
  • git diff --check origin/main...HEAD: tests/startup_gfx2hlsl_mul_hi_check.py:110 has trailing whitespace.
  • git merge-tree --write-tree origin/main HEAD: conflict in .github/workflows/windows.yml.

Findings:

P1: The new test fails on its own head, so the Linux CI check is red.

  • tests/startup_gfx2hlsl_mul_hi_check.py:123 replaces the text '+ ((al * bl) >> 16)'.
  • The helper actually emitted in gfx2hlsl.py (around line 3859) uses la, lb and middle. It has no al or bl. The replace changes nothing, and the assert at line 124 fires.
  • The "carry-drop" control never ran. Target the real expression, for example the ((la * lb) >> 16) term inside middle, and keep asserting that the mutated helper mismatches on 0xffffffff * 0xffffffff.

P1: The PR is not mergeable. .github/workflows/windows.yml conflicts with main, so a rebase is needed.

P2: A real mutation of the new lowering could not be measured, because the baseline test already fails. Re-run the mutation of 'v_mul_hi_u32': (2, 'mul_hi_u32({0}, {1})') after the P1 fix.

P2: The draw tests (startup_gfx2hlsl_mul_hi_warp and _hardware) only mean something on Windows. A useful WARP result needs the fixed test, so I did not queue the Windows VM here.

Nit: trailing whitespace at test line 110, which git diff --check flags.

The lowering change itself is small and reuses the existing helper. It is the high 32 bits of an unsigned product on uint operands, which looks right. The blockers are the test and the merge state.

AI-assisted; commands listed were executed locally.

@tedin7 tedin7 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 8ed83e67d9846af5e9221af3ce9fae1de727d03c (comment only).

Scope: one-line v_mul_hi_u32 entry in VEC_U of tools/startup/gfx2hlsl.py, reusing the existing mul_hi_u32 helper (already used by s_mul_hi_u32), plus a new check, CMake tests (controls, warp, hardware) and CI wiring.

Commands executed locally:

  • git diff --stat origin/main...HEAD: 4 files, +231/-1.
  • gh pr checks 1747: Linux Python checks, gfx1013 fixtures and Windows build pass; coverage chart and /O2 skipped.
  • python3 -B tests/startup_gfx2hlsl_mul_hi_check.py: all controls ok (361 edge pairs, refusal of modifiers and operand counts, exec-masked guard, mutation controls).
  • python3 tests/docs_links_check.py: pass. python3 tests/bidi_controls_check.py: pass.
  • git diff --check origin/main...HEAD: reports one finding (see P2).
  • Mutation 1: removed the carry term (((middle & 0xffffu) + la * (b >> 16)) >> 16) from the helper in gfx2hlsl.py: check fails at "emitted helper matches reference on 361 edge pairs".
  • Mutation 2: changed the v_mul_hi_u32 lowering to ({0} * {1}): check fails at "four lane calls emitted". Both reverted with git checkout -- ..
  • ... binary llvm-mc-15: not run, llvm-mc-15 is not installed locally (CI covers it and passes). Windows WARP/hardware draw not run by me: the change is a one-line table entry on a helper already exercised by s_mul_hi_u32; the draw tests are wired in CTest for Win2025.

Math check: with a = ah2^16 + la and b = bh2^16 + lb, middle = ah*lb + (la*lb >> 16) fits in 32 bits (max 0xffff0xffff + 0xffff), and (middle & 0xffff) + la*bh also fits (max 0xffff + 0xffff^2 < 2^32). The high word is ahbh + (middle >> 16) + carry, which is correct.

Findings:

  • P1: none.
  • P2: none.
  • nit: git diff --check flags trailing whitespace in tests/startup_gfx2hlsl_mul_hi_check.py (line 110). Trivial to strip.
  • nit: the windows.yml list entry for the new check sits between sopk_signext and scalar_brev_fold in the lint file list, not alphabetical. Cosmetic.

No clean-room or title concerns; title is neutral, PR is mergeable.

AI-assisted; commands listed were executed locally.

@legacy-code-archaeologist

Copy link
Copy Markdown
Contributor

Re-ran the current head 8ed83e67 after the rebase fix. All pass. Windows 11 build 26100, debug layer unavailable, FXC and DXC from SDK 10.0.26100.0.

Test WARP 10.0.26100.8972 NVIDIA Quadro M1000M (32.0.15.7371) Intel HD Graphics 530 (31.0.101.2111)
startup_gfx2hlsl_mul_hi_controls, startup_gfx2hlsl_operand_count, startup_gfx2hlsl_handler_arity pass n/a n/a
startup_gfx2hlsl_mul_hi_{warp,hardware} pass: 8 ok lines, both mutations fail as expected same same

The tree has exactly one uint mul_hi_u32 definition, so the duplicate-helper problem from a60128b4 is gone at this head.

AI-assisted.

@SuperCraft3M

Copy link
Copy Markdown
Contributor

The halfword lowering also passes when backported to the legacy startup translator from base 2010abb0. I reused this PR's source-built v_mul_hi_u32 fixture through its check_draw entry point, loading the legacy translator and running offscreen_check on both backends.

  • FXC and DXC matched all 12 operand pairs on both WARP and the RTX 4070.
  • A low-word mutation produced different readback values, as expected.
  • Windows build 26300.9711, WARP 10.0.26100.9711, NVIDIA driver 32.0.16.2114, D3D12 debug layer unavailable.

R0Y00 commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Re-reviewed 02328b26. The follow-up adds the exact encoded literal from #1792 and the experiment entry. Windows Release passed 5/5, including WARP and RTX 4060 Laptop. FXC and DXC matched all 12 operand pairs on both adapters, and the low-word mutation diverged. Required Windows and both Linux jobs passed at this head, including the LLVM round trip. Thanks to @triggered02 and the #1793 reviewers for the literal encoding and carry controls.

@MasterDomino

Copy link
Copy Markdown
Collaborator

AMD data point for head 02328b26. This is the first AMD run in this thread; the earlier runs were NVIDIA and Intel.

  • Host: Windows 11 build 26300, with FXC and DXC 1.8.2502.11 from SDK 10.0.26100.0. offscreen_check was a Release build at 7092683a. The head merges cleanly with current main.
  • Adapters: WARP 10.0.26100.9818 and AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010), debug layer on.
Check Result
python -B tests/startup_gfx2hlsl_mul_hi_check.py pass: 361 edge pairs, the carry-drop mutation caught, the encoded literal reaching the helper
... binary <llvm-mc 15.0.7> fixture words match llvm-mc
... draw <dxc> <offscreen_check> warp <fxc> pass, exit 0
... draw <dxc> <offscreen_check> hardware <fxc> (RX 9070 XT) pass, exit 0; mutation reads 00000001,00000000,88cf5b62,00020001, differing from fffffffe,00000001,b092ab7b,00000001

Also: #2425 adds the same VEC_U entry. I've suggested there that it close in favour of this PR.

AI-assisted; commands listed were executed locally.

@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.

Approving head 02328b26.

  • Change: one VEC_U entry that reuses the mul_hi_u32 helper already on main for s_mul_hi_u32. Exactly one helper definition is emitted.
  • CI: green on this head: Windows build and test, gfx1013 fixtures, Linux Python.
  • Merge check: the head merges cleanly with current main, checked locally with git merge-tree.
  • Earlier verification: R0Y00's re-review at this head (Release 5/5 on WARP and RTX 4060 Laptop, LLVM round trip), and the NVIDIA Quadro, Intel Gen9 and RTX 4070 runs in this thread.
  • Our run at this head: on Windows 11 build 26300, the controls, binary with llvm-mc 15.0.7, and FXC/DXC draws on WARP and an AMD Radeon RX 9070 XT (driver 32.0.32029.2010, debug layer on) all pass, and the low-word mutation diverges.

AI-assisted.

@MasterDomino

Copy link
Copy Markdown
Collaborator

@R0Y00, a question about merging. I approved this PR at 02328b26: CI green, mergeable, and your re-review at the same head. Then I tried to squash-merge it at that exact head, with the new push and triage access on our account. GitHub refused: "the base branch policy prohibits the merge". The PR still shows as blocked after the approval.

The rules on main aren't visible to our account, so I can't tell what's missing. Does main need an approval from you or a code owner, or is merging limited to specific accounts? I didn't use --admin or auto-merge. If merging this one should stay with you, that's fine too. Let us know what the policy expects, and we'll follow it.

AI-assisted.

@MasterDomino
MasterDomino merged commit e06aca8 into R0Y00:main Nov 25, 2026
5 checks passed
@MasterDomino

Copy link
Copy Markdown
Collaborator

@R0Y00, you can ignore my merge question above. This PR is now merged at 02328b26, from the web UI on the same account.

It most likely wasn't a branch policy. Our gh CLI token lacks the workflow scope, and this PR changes .github/workflows/windows.yml. GitHub reported that case as "the base branch policy prohibits the merge". The web UI doesn't go through that OAuth token, so the merge went through there.

AI-assisted.

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.

6 participants