Repository navigation
Recompiler: simplify integer min/max (dx.op.binary.i32) via range bounds and absorption in direct DXIL opt - #2568
ramon-victor wants to merge 1 commit into
Conversation
…nds and absorption in direct DXIL opt
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! — Devin |
|
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. |
|
Independent RX 6800M focused report for exact PR head Tested
Not tested
AI use
|
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)
Track conservative signed and unsigned i32 intervals through common SSA forms, then fold min/max identities, absorption, and non-overlapping bounds. This collapses translated clamp and med3 sequences after mem2reg without removing soundness guards for signed masks. Adapted from xcl-dev#2568. Upstream reports 573/573 DXIL validation, direct GPU parity across NVIDIA and AMD, and 133,484 fewer emitted bytes across the corpus. Locally cross-checked only with the GNU Windows target; Windows GPU execution remains untested here. Part of xcl-dev#2508 Assisted-by: Google Antigravity (Gemini 4 Neon) Assisted-by: Codex (GPT-5.6-sol)
Track conservative signed and unsigned i32 intervals through common SSA forms, then fold min/max identities, absorption, and non-overlapping bounds. This collapses translated clamp and med3 sequences after mem2reg without removing soundness guards for signed masks. Adapted from xcl-dev#2568. Upstream reports 573/573 DXIL validation, direct GPU parity across NVIDIA and AMD, and 133,484 fewer emitted bytes across the corpus. Locally cross-checked only with the GNU Windows target; Windows GPU execution remains untested here. Part of xcl-dev#2508 Assisted-by: Google Antigravity (Gemini 4 Neon) Assisted-by: Codex (GPT-5.6-sol)
|
Independent desktop NVIDIA (Wave32-only Ada) verification of PR #2568 at head Environment
Targeted release tests & build (
|
| Command | Result |
|---|---|
cargo test --release -p xcl --lib simplify_int_minmax_folds_bounds_absorption_and_clamps -- --nocapture (3 consecutive runs) |
1 passed; 0 failed; 0 ignored; 1325 filtered out × 3 (0.00s × 3, 0 skipped) |
cargo test --release -p xcl --lib med3_via_sgpr_bounds_collapses_and_matches_gpu -- --nocapture (3 consecutive runs) |
1 passed; 0 failed; 0 ignored; 1325 filtered out × 3 (0.21s, 0.18s, 0.18s, 0 skipped — live Wave32 GPU parity on RTX 4060) |
cargo test --release -p xcl --lib gpu::dxil:: -- --test-threads=4 (3 consecutive runs) |
185 passed; 0 failed; 3 ignored; 1138 filtered out × 3 (4.45s, 3.59s, 3.59s; 184 executed + 1 expected Wave32-only skip dispatch_chain_native_wave64_builds_whole: no wave64) |
cargo build --release -p xcl |
Clean build (1m 07s, exit 0, 0 new warnings) |
Paired quiet 60 s retail smoke (title: 29640639)
Exact parent & merge-base (e1d84b7d9153f86a97d2ec5d209d196046fc0bea, cached baseline on the same machine):
xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1531 (PresentX 1531)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13982 MB
PR #2568 (4094ff9cb9c3eea2af33f2556dae05a28987bb05):
xcl-smoke v1
commit: 4094ff9cb9c3eea2af33f2556dae05a28987bb05
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1598 (PresentX 1598)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14006 MB
Runtime log observations (xcl.log)
9220log lines,0[ERROR]/ device-removal / panic lines.- Final draw/memory telemetry in log:
19540 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14006 MB committed by the process; video memory 6115 MB local, 4683 MB non-local.
Limits of coverage
- Range-bound/absorption simplification of
dx.op.binary.i32integermin/maxandmed3collapse were verified both at IR level (simplify_int_minmax_folds_bounds_absorption_and_clamps× 3) and end-to-end on desktop Wave32-only NVIDIA RTX 4060 (med3_via_sgpr_bounds_collapses_and_matches_gpu× 3,0skipped, plusgpu::dxil::184executed +1expectedno wave64skip × 3). - Native Wave64 GPU execution is not available on this Wave32-only RTX 4060, and the warm-cache 60 s retail smoke on
title: 29640639confirms zero runtime regression rather than re-compiling a coldXCL_DIRECT_DXIL=1shader set (frame-count delta vs. cached parent reflects single-run startup variance, not this PR).
AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Track conservative signed and unsigned i32 intervals through common SSA forms, then fold min/max identities, absorption, and non-overlapping bounds. This collapses translated clamp and med3 sequences after mem2reg without removing soundness guards for signed masks. Adapted from xcl-dev#2568. Upstream reports 573/573 DXIL validation, direct GPU parity across NVIDIA and AMD, and 133,484 fewer emitted bytes across the corpus. Locally cross-checked only with the GNU Windows target; Windows GPU execution remains untested here. Part of xcl-dev#2508 Assisted-by: Google Antigravity (Gemini 4 Neon) Assisted-by: Codex (GPT-5.6-sol)
Track conservative signed and unsigned i32 intervals through common SSA forms, then fold min/max identities, absorption, and non-overlapping bounds. This collapses translated clamp and med3 sequences after mem2reg without removing soundness guards for signed masks. Adapted from xcl-dev#2568. Upstream reports 573/573 DXIL validation, direct GPU parity across NVIDIA and AMD, and 133,484 fewer emitted bytes across the corpus. Locally cross-checked only with the GNU Windows target; Windows GPU execution remains untested here. Part of xcl-dev#2508 Assisted-by: Google Antigravity (Gemini 4 Neon) Assisted-by: Codex (GPT-5.6-sol)
|
RX 9070 / RADV / Wine verification of exact head Tested
Main fails the new CPU/IR optimization assertions, with 14 rather than 6 binary.i32 calls in the captured original med3 shader; its original fixture stops before GPU dispatch. Head/integration validate with 6 calls and match all 32 captured lanes, including the zero-initialized lanes outside the ten original input pairs. Additional owned filter
All three sources match the independent Python integer model. In both matrix wave sizes, captured min/max calls drop from 59 on main to 10 on head/integration, with identical GPU payloads. Across both groups: 292 captured GPU dispatches, 144 native wave64, 765,440 output/guard words, zero differences from the reference. Physical width is checked for every matrix lane. Captures repeat byte-for-byte within each source; exact head and integration captures also match. 0 ignored, 0 skipped. Inherited Not tested Full suite, HLSL backend, graphics or guest Compute ABI integration, native Windows, other GPUs, retail workload, AI use OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the diff, wrote the owned test-only matrix and captures, ran comparisons, independently verified inputs, integer outputs, neighbors, wave widths and source/executable provenance, and drafted this report. Publication authorized by the account owner. |
|
merge-check claim |
|
merge-check |
|
merge-check claim |
Track conservative signed and unsigned i32 intervals through common SSA forms, then fold min/max identities, absorption, and non-overlapping bounds. This collapses translated clamp and med3 sequences after mem2reg without removing soundness guards for signed masks. Adapted from #2568. Upstream reports 573/573 DXIL validation, direct GPU parity across NVIDIA and AMD, and 133,484 fewer emitted bytes across the corpus. Locally cross-checked only with the GNU Windows target; Windows GPU execution remains untested here. Part of #2508 Assisted-by: Google Antigravity (Gemini 4 Neon) Assisted-by: Codex (GPT-5.6-sol)
|
merge-check |
Part of #1269.
Problem
Module::simplify_opincrates/xcl/src/gpu/dxil/module/opt.rsdid not simplifydx.op.binary.i32integer min/max calls (IMax=37,IMin=38,UMax=39,UMin=40).In translated RDNA2 shaders, integer clamps (
v_med3_i32/v_med3_u32/v_med3_i16/v_med3_u16, each lowered as 4dx.op.binary.i32calls) and byte/half range clamps (v_cvt_pk_*,v_sat_pk_*) frequently receive constant bounds via SGPRs that only become constants aftermem2regpromotes them to SSA, or clamp values whose range is already constrained byand,lshr,ashr,zext,sext, or an outermin/max. Becausedx.op.binary.i32was opaque tosimplify_op, all 4 calls stayed live in the emitted DXIL.Fix
[lo, hi]interval helpersModule::unsigned_range_i32andModule::signed_range_i32(depth 4) incrates/xcl/src/gpu/dxil/module/opt.rs, tracking ranges acrossi32constants, constant-maskedAnd(requiring bit 31 clear for signed), constantLShr(shift>= 1for signed), constantAShr,ZExt/SExtfrom narrower widths,Select, and nesteddx.op.binary.i32min/max of matching signedness.Module::simplify_int_minmaxcalled fromModule::simplify_opondx.op.binary.i32(37..=40), folding:min(x, x) -> x,max(x, x) -> x).min(min(x, y), x) -> min(x, y),min(max(x, y), x) -> x,max(min(x, y), x) -> x,max(max(x, y), x) -> max(x, y)).ha <= lb/hb <= lafor min;la >= hb/lb >= hafor max), which subsumes constant folding, identity/absorbing bounds (0,u32::MAX,i32::MIN,i32::MAX), redundant byte/half clamps, and collapses every permutation of constant-boundv_med3_i32/v_med3_u32from 4 calls down to 2 (or 1 whenlo == 0/i32::MINorhi == u32::MAX/i32::MAX) automatically aftermem2reg.opt::int_minmax_tests(including soundness check thatimax(x & 0x8000_00FF, 0)is not 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).4094ff9):573/573validated (val_fail=0),50,984,004total DXIL bytes (-133,484 B/-0.261%;p50=21,870 us,p95=419,075 us).Tested
cargo test --lib -p xcl int_minmax): 2 passed, 0 failed (simplify_int_minmax_folds_bounds_absorption_and_clamps,med3_via_sgpr_bounds_collapses_and_matches_gpu)..\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 (
4094ff9):AI use