Recompiler: build the wide unsigned multiply without UMul on a Mac #3525
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3525"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by vakaobr on 2026-11-30T13:20:37Z.
Stacked on #2361; only the top commit belongs here. Part of #258.
Apple's metal-shaderconverter, which D3DMetal runs on every pipeline, does not handle DXIL
UMul(binaryWithTwoOuts, opcode 42) in every program: on some it overflows its stack and the compile never returns. The direct translator emitsUMulfor thestride * indexterm of a windowed buffer address, so on a Mac those pipelines can stop there. On a Mac (util::mac_host),umul_widenow builds the high half from 16-bit parts, as the HLSL kernel'smul_hi_u32does, so the window code still needs noInt64Ops. Windows keepsUMul. #2172 would useumul_widein more places; on a Mac those go through the same halves.What is in it
crates/xcl/src/gpu/dxil/ops.rs:umul_widetakesumul_wide_halveson a Mac.crates/xcl/src/gpu/dxil/ops_tests.rs: newumul_wide_without_umul_matches_cpu.crates/xcl/src/gpu/dxil/core_tests.rs:window_at_lowers_to_32bit_carry_without_int64expects noUMulon a Mac andUMulelsewhere.Tested
x86_64-pc-windows-gnu, debug; this branch onmain9dfbe3ewith #2361.gpu_memory_windows_above_4_gib,gpu_memory_windows_reject_out_of_uma_aliasing,gpu_sparse_vram_descriptors_buffers_and_xmem: onmaineach reports "has overflowed its stack" and hangs; with this PR all three pass.umul_wide_without_umul_matches_cpu(new),window_at_lowers_to_32bit_carry_without_int64,gpu_window_at_32bit_carry_edge_cases,a_mac_host_is_darwin_under_wine_unless_forced: pass. WithXCL_MAC_HOST=0thewindow_attest still findsUMul.Regression run
scripts/smoke.ps1. On Windowsmac_host()is false, so the code path there is unchanged.Not tested
IMul's high half is also wrong on D3DMetal (1 * 0x9e377939gives 0); the runtime does not emitIMultoday, and this PR does not change it.AI use
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:43:00Z.
Review (head
3ebde06f, diff read, not a merge-check; draft withPR descriptionred, so not built or run):PR descriptionfails, and the full suite hasn't been run anywhere. It's stacked on #2361 (open draft), which providesutil::mac_host().0xFFFFFFFF x 0xFFFFFFFF) isn't covered; worth adding.Fine:
umul_wide_halvesis correct for all inputs (the middle sum stays below 2^18, and since the true high word fits in 32 bits no addition wraps). It's gated onmac_host()(ops.rs~444), so Windows still emitsUMuland the existing Windows test still asserts it; the only caller islower_window.rs~130. The new GPU test skips correctly without a GPU, and AI use names the model.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T10:09:29Z.
Triage (#1607) – head
3ebde06Stacked on #2361: the first commit (
69c0b04,util::mac_host) is #2361's; only3ebde06belongs here. No other open or merged PR avoidsUMulinumul_wide; #2363, #2402 and #2492 usemac_hostfor other changes.No problems found in the diff:
ops.rs::umul_wide_halvessums the two cross products' low halves with the carry out ofllbefore shifting, which gives the exact high word, andumul_wide_without_umul_matches_cpuchecks it against the CPU product. On Windowsmac_host()is false, so the emitted DXIL is unchanged there.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.