Recompiler: lower 32-bit VALU add/sub with carry without i64 in direct DXIL #2565
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2565
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2565"
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?
@ramon-victor on GitHub · 2026-11-25 23:03 UTC · original
ramon-victor:opt/dxil-valu-carry-32bit→main· +118 −8 · 1 files · 1 commits · openPart of #1269.
Problem
In
crates/xcl/src/gpu/dxil/lower_valu.rs,v_add_co_ci_u32,v_sub_co_ci_u32, andv_subrev_co_ci_u32widened all three 32-bit operands (x,y,cin) toi64viazext64, performed 64-bitadd/sub, unpacked the 64-bit result (unpack64), and testedhi != 0for carry/borrow out.Every shader using 64-bit VALU address arithmetic (
v_add_co_u32+v_add_co_ci_u32) was therefore forced to emiti64instructions and declareFeature::Int64Opseven when no 64-bit integer operations were otherwise needed, andopt.rscould not fold or dead-code-eliminate thei64carry-out path (because 64-bit instructions are preserved to keepInt64Opsconsistent).Fix
v_add_co_ci_u32,v_sub_co_ci_u32, andv_subrev_co_ci_u32incrates/xcl/src/gpu/dxil/lower_valu.rsusing pure 32-bit carry/borrow arithmetic matchings_addc_u32/s_subb_u32inlower.rs:t0 = x + y,t = t0 + cin,carry = (t0 < x) | (t < t0).t0 = x - y,t = t0 - cin,borrow = (x < y) | (t0 < cin).lower_valu::valu_carry_tests::valu_carry_ops_avoid_i64_and_match_gpuverifying DXIL validation, disassembly (zero64-Bit integershader flag and zerozext i32), and wave32 RTX 3070 GPU parity across 32 boundary(x, y, cin)triples for all three opcodes (checking both 32-bitVDSToutputs and all 32 carry/borrow-out mask bits).Measured impact
573-program retail direct-DXIL validation sweep (
dxil.dll1.8.2502.11):6d12f58):573/573validated (val_fail=0),51,117,488total DXIL bytes (p50=22,865 us,p95=408,132 us).97376ee):573/573validated (val_fail=0),51,110,868total DXIL bytes (-6,620 B/-0.013%;p50=20,462 us,p95=403,273 us).Tested
cargo test --lib -p xcl valu_carry): 1 passed, 0 failed..\scripts\test.ps1, NVIDIA GeForce RTX 3070, Windows 11):1424 passed, 0 failed, 46 ignored.dxil.dllvalidation sweep:573/573passed,0failures.cargo build --release -p xcl) and 60 s retail smoke run (see below).Not tested
Regression run
Main (
f087b99):This PR (
97376ee):AI use
@DavidM1911 on GitHub · 2026-11-25 23:19 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 26 ignored.Thanks!
— Devin
@DarkPanda69 on GitHub · 2026-11-25 23:37 UTC · original
Wave64 run (listed as untested; the wave64 GPU tests skipped on the RTX 3070) on an AMD RX 9070 XT, plus an RTX 3060: the new test passes, and nothing else changes in the direct-DXIL GPU suite.
Head
97376eeapplied onmain08db802, debug, Windows 11 Pro 26200,XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4onmainand with the PR, card chosen withXCL_ADAPTER:mainOn both cards, the only result change against
mainis the newvalu_carry_ops_avoid_i64_and_match_gpu(ok), with no new skips. That test translates withwave64: false, so its own GPU run is wave32. On the RTX 3060, 21 wave64 cases skip, among them the suite'sinteger carries, wave64case. On the RX 9070 XT, 18 of them ran with this PR applied,integer carries, wave64included, and still pass; the other 3 are per-lane forms refused on both cards. The 2 RX 9070 XT failures are the AMD fuzz seeds tracked in #2115, the same onmain.Not tested: Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@SlopTart on GitHub · 2026-11-25 23:41 UTC · original
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. This PR does not change the mad/mac red on RADV.Targeted run of
valu_carry_ops_avoid_i64_and_match_gpu(name sits outside thegpu_filter): passed.Not tested: retail titles (no title data on this lane, counts only).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
github-bot referenced this pull request2026-11-26 12:40:17 +00:00
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.