Repository navigation
Recompiler: generalize bitmask and zero-shift folding via known_nonzero_bits - #2557
ramon-victor wants to merge 1 commit into
Conversation
|
Wave64 run (listed as untested; the wave64 GPU tests skipped on the RTX 3070) on an AMD RX 9070 XT, plus an RTX 3060: both new tests pass, and nothing else changes in the direct-DXIL GPU suite. Head
On both cards, the only result changes against Not tested: Intel, a title. |
|
NVIDIA test report for
Lib tests only; no title run. AI-assisted (Claude Code, Claude Opus 5.5). |
|
Independent AMD RDNA4 (native wave64) verification of exact PR head Tested
(Compare against Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! — Devin |
|
Tested: current PR head merged onto current
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. |
Integrates upstream amd-dev 9f02a3b (BVH null/OOB guard), b67375b (scratch SADDR 0x7F), 4ae5668/xcl-dev#2565 (32-bit VALU add/sub carry without i64), plus open PRs xcl-dev#2559 (bfm/ffbh_i), xcl-dev#2557 (known_nonzero_bits folding), xcl-dev#2552 (f16-to-f32 fold), xcl-dev#2568 (integer min/max range opt), and xcl-dev#2580 (empty DXC blob null slice). Assisted-by: Antigravity (Gemini 4 Neon)
…l-dev#2557/xcl-dev#2568 - real.rs: require 8-byte alignment in UnadoptGuard::new before atomic vtable load (fixes debug misaligned-pointer panic on synthetic unaligned test handles). - list_x.rs: add UnadoptGuard and create_raw_fence in Wine GPU tests. - opt.rs: revert unmerged xcl-dev#2557/xcl-dev#2568 passes while keeping xcl-dev#2552. Assisted-by: Antigravity (Gemini 4 Neon)
Part of #1269.
Problem
Module::simplify_opincrates/xcl/src/gpu/dxil/module/opt.rspreviously only recognized single-hopandmasks overlshr,shl,andwith a constant, orzext(i1). Multi-instruction bit-packing sequences common in translated RDNA2 shaders (or/xor/select/add/mulof byte/half masks,zextof wider sub-32-bit integers,dx.op.binary.i32(UMin/UMax),dx.op.unaryBits.i32(Countbits), non-constant disjointand, and shifts that shift out all possibly-nonzero bits) missed mask elision and zero-shift folding.Fix
Module::known_nonzero_bits(&self, v: Value, w: u32, depth: u8) -> u64(crates/xcl/src/gpu/dxil/module/opt.rs), computing a conservative bitmask of bits that may be1for integer widths1..=32up to depth 4 (leaving 64-bit values untouched soInt64Opsflags stay consistent).And,Or,Xor,LShr,Shl, non-negativeAShr, disjoint/non-overflowingAdd,Mul(trailing-zero and non-overflowing product bounds), constant-divisorUDiv/URem,Select,ZExt,Trunc,dx.op.binary.i32(UMax,UMinvia highest-possible-bit fill), anddx.op.unaryBits.i32(Countbits→0x3F).BinOp::Andspecial cases inModule::simplify_opwith the generalknown_nonzero_bitscheck (covering both redundant masks and disjoint non-constantand→0), and foldLShr,Shl, and sign-bit-zeroAShrto0when all possibly-nonzero bits are shifted out.opt::known_bits_tests, including soundness checks verifying thatumin(x & 0x100, y) & 0xFFand sign-unknownashrare not erroneously folded.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).2a1fadc):573/573validated (val_fail=0),51,111,472total DXIL bytes (-6,016 B/-0.012%;p50=20,048 us,p95=376,645 us).Tested
cargo test --lib -p xcl module::opt): 9 passed, 0 failed (known_nonzero_bits_folds_compound_masks_and_shifts,known_nonzero_bits_gpu_parity, plus all 7 existingopttests)..\scripts\test.ps1, NVIDIA GeForce RTX 3070, Windows 11):1425 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 (
2a1fadc):AI use