You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
startup: v_mul_hi_u32 has no lowering (1 of the remaining loading-screen shader refusals) #1792
tools/pixel_aot.py already implements this operation for the pixel AOT path with a halfword-product helper; tools/startup/gfx2hlsl.py did not have it.
Fix
The lowering calls a helper added to the shader preamble:
uintmul_hi_u32(uint a, uint b) {
uint la = a & 0xffffu, lb = b & 0xffffu;
uint middle = (a >> 16) * lb + ((la * lb) >> 16);
return (a >> 16) * (b >> 16) + (middle >> 16) + (((middle & 0xffffu) + la * (b >> 16)) >> 16);
}
It is computed from halfword products because these shader stages have no 64-bit multiply, and the low half of a * b is not the high half — so a plain * would be silently wrong.
Measured
VOP3A encodings built in the test (0b110101 prefix, opcode 0x16a), main at b9f355f1:
form
before
after
v_mul_hi_u32 v1, v1, v2
refused
v1 = mul_hi_u32(v1, v2);
v_mul_hi_u32 v1, v0, 0xaaaaaaab
refused
v1 = mul_hi_u32(v0, 0xaaaaaaabu);
v_mul_lo_u32 v1, v1, v2
v1 = v1 * v2;
unchanged
Done when
Both the register form and the literal form lower to the helper.
The helper is in the preamble the generated shader is built with, and uses halfword products.
A ctest starts from synthetic encoded instructions, decodes, then translates, and fails if the lowering uses a plain multiply or the helper is missing.
docs/experiments.md records the change.
Not in this slice: v_mul_hi_i32 (its signed correction), the 24-bit _u24 forms, and DXC/draw results.
I compared #1747 (f2e319ce) and #1793 (6782e724) on top of current main (1949b265). This adds to the comparison on #1793 and the maintainer's merge note on #1747. The new part is what each test does once the PR is rebased onto the helper main already has from #2176.
Translator change: both PRs add the same VEC_U entry, 'v_mul_hi_u32': (2, 'mul_hi_u32({0}, {1})'). After a rebase, neither should add a helper of its own:
ctest from synthetic encodings, fails on plain multiply or missing helper
yes, plus an LLVM 15 binary mode
yes
docs/experiments.md records the change
no
yes
WARP and hardware draw (not required here)
yes, verified by the maintainer on WARP and RTX 4060 Laptop
no
Nits: #1793's CMake comment cites #1781, a merged DirectStorage PR, instead of #1792. #1747 also adds binary llvm-mc-15 to the Linux job in windows.yml, and that hunk conflicts with main too.
Summary: #1793 is the smaller rebase, because it only drops its helper hunk. #1747 has the stronger evidence, its WARP and hardware draws, but it needs the helper removed, the test parser ported and a docs entry. A combined result could take #1747's draw modes and #1793's value-level evaluator and docs row. Which one lands is the maintainer's call.
Not run here: either draw (no Windows or D3D12 on this host) and #1747's binary mode (this host has LLVM 21/22, not 15).
#1747 landed at e06aca8b. The startup translator now lowers both register and encoded literal forms through the existing halfword helper. The source-built tests include the exact 0xaaaaaaab example, LLVM round trip, the carry and low-word controls, and FXC/DXC readback. Windows Release 5/5 passed on WARP and RTX 4060 Laptop, and the required cloud checks passed for the merged candidate. This closes the original lowering scope.
Activity
winne42 commentedon Nov 25, 2026
I compared #1747 (
f2e319ce) and #1793 (6782e724) on top of currentmain(1949b265). This adds to the comparison on #1793 and the maintainer's merge note on #1747. The new part is what each test does once the PR is rebased onto the helpermainalready has from #2176.Translator change: both PRs add the same
VEC_Uentry,'v_mul_hi_u32': (2, 'mul_hi_u32({0}, {1})'). After a rebase, neither should add a helper of its own:main's, so itsgfx2hlsl.pyhunk reduces to theVEC_Uline.al/bl/m) merges intogfx2hlsl.pywithout a textual conflict. The result definesmul_hi_u32twice, which is the FXC/DXC redefinition noted in the review on startup: lower v_mul_hi_u32 in gfx2hlsl #1747. A plain rebase that keeps both sides would not show it until the shader compiles.Each PR's own test on the resolved merge (
main+ theVEC_Uline + the PR'stests/startup_gfx2hlsl_mul_hi_check.py, default mode, Linux, Python 3):eval_emitted_helpermatches onlyuint al = …, bl = …, m = …and asserts onmain'sla/lb/middlebodySo #1747 also needs its test parser ported to
main's helper. The review on #1747 says that was done locally, but the PR head doesn't have it yet.Mutation controls on the #1793 candidate. Each mutation went into
main's helper or the lowering, and each one made the test fail:Against the "Done when" list in this issue:
0x12345678)0xaaaaaaab)main'smain's)binarymodedocs/experiments.mdrecords the changeNits: #1793's CMake comment cites
#1781, a merged DirectStorage PR, instead of #1792. #1747 also addsbinary llvm-mc-15to the Linux job inwindows.yml, and that hunk conflicts withmaintoo.Summary: #1793 is the smaller rebase, because it only drops its helper hunk. #1747 has the stronger evidence, its WARP and hardware draws, but it needs the helper removed, the test parser ported and a docs entry. A combined result could take #1747's draw modes and #1793's value-level evaluator and docs row. Which one lands is the maintainer's call.
Not run here: either draw (no Windows or D3D12 on this host) and #1747's
binarymode (this host has LLVM 21/22, not 15).AI-assisted (Claude Code).
R0Y00 commentedon Nov 25, 2026
#1747 landed at
e06aca8b. The startup translator now lowers both register and encoded literal forms through the existing halfword helper. The source-built tests include the exact 0xaaaaaaab example, LLVM round trip, the carry and low-word controls, and FXC/DXC readback. Windows Release 5/5 passed on WARP and RTX 4060 Laptop, and the required cloud checks passed for the merged candidate. This closes the original lowering scope.