Recompiler: generalize bitmask and zero-shift folding via known_nonzero_bits #2547

Open
ramon-victor wants to merge 1 commit from upstream-pr/2557 into main
ramon-victor commented 2026-11-25 22:50:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ramon-victor on 2026-11-25T22:50:36Z.


Part of #1269.

Problem

Module::simplify_op in crates/xcl/src/gpu/dxil/module/opt.rs previously only recognized single-hop and masks over lshr, shl, and with a constant, or zext(i1). Multi-instruction bit-packing sequences common in translated RDNA2 shaders (or/xor/select/add/mul of byte/half masks, zext of wider sub-32-bit integers, dx.op.binary.i32(UMin/UMax), dx.op.unaryBits.i32(Countbits), non-constant disjoint and, and shifts that shift out all possibly-nonzero bits) missed mask elision and zero-shift folding.

Fix

  • Add 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 be 1 for integer widths 1..=32 up to depth 4 (leaving 64-bit values untouched so Int64Ops flags stay consistent).
    • Propagates zero-bit bounds through constants, And, Or, Xor, LShr, Shl, non-negative AShr, disjoint/non-overflowing Add, Mul (trailing-zero and non-overflowing product bounds), constant-divisor UDiv/URem, Select, ZExt, Trunc, dx.op.binary.i32 (UMax, UMin via highest-possible-bit fill), and dx.op.unaryBits.i32 (Countbits → 0x3F).
  • Replace the 1-hop BinOp::And special cases in Module::simplify_op with the general known_nonzero_bits check (covering both redundant masks and disjoint non-constant and → 0), and fold LShr, Shl, and sign-bit-zero AShr to 0 when all possibly-nonzero bits are shifted out.
  • Add unit and RTX 3070 GPU parity tests in opt::known_bits_tests, including soundness checks verifying that umin(x & 0x100, y) & 0xFF and sign-unknown ashr are not erroneously folded.

Measured impact

573-program retail direct-DXIL validation sweep (dxil.dll 1.8.2502.11):

  • Baseline (6d12f58): 573/573 validated (val_fail=0), 51,117,488 total DXIL bytes (p50=22,865 us, p95=408,132 us).
  • This PR (2a1fadc): 573/573 validated (val_fail=0), 51,111,472 total DXIL bytes (-6,016 B / -0.012%; p50=20,048 us, p95=376,645 us).

Tested

  • Targeted unit + GPU parity tests (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 existing opt tests).
  • Full workspace (.\scripts\test.ps1, NVIDIA GeForce RTX 3070, Windows 11): 1425 passed, 0 failed, 46 ignored.
  • 573-shader direct DXIL dxil.dll validation sweep: 573/573 passed, 0 failures.
  • Release build (cargo build --release -p xcl) and 60 s retail smoke run (see below).

Not tested

  • Wave64-only GPU paths (the RTX 3070 runs wave32; wave64 GPU tests skipped automatically on this adapter).

Regression run

Main (f087b99):

xcl-smoke v1
commit: f087b998d0d51a9f11bbfa0761967a63e778edd9
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14467 MB

This PR (2a1fadc):

xcl-smoke v1
commit: 2a1fadcf8eb4c67079e0b1646528a8603c804be7
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1620 (PresentX 1620)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14006 MB

AI use

  • Antigravity (Gemini 4 Neon): implementation, soundness & GPU parity tests, 573-shader DXIL sweep, and PR drafting.
<!-- greyfinch-sync:ivall/xcl:issue:5500531472 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557). Originally posted by [ramon-victor](https://github.com/ramon-victor) on 2026-11-25T22:50:36Z. --- Part of #1269. **Problem** `Module::simplify_op` in `crates/xcl/src/gpu/dxil/module/opt.rs` previously only recognized single-hop `and` masks over `lshr`, `shl`, `and` with a constant, or `zext(i1)`. Multi-instruction bit-packing sequences common in translated RDNA2 shaders (`or`/`xor`/`select`/`add`/`mul` of byte/half masks, `zext` of wider sub-32-bit integers, `dx.op.binary.i32(UMin/UMax)`, `dx.op.unaryBits.i32(Countbits)`, non-constant disjoint `and`, and shifts that shift out all possibly-nonzero bits) missed mask elision and zero-shift folding. **Fix** - Add `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 be `1` for integer widths `1..=32` up to depth 4 (leaving 64-bit values untouched so `Int64Ops` flags stay consistent). - Propagates zero-bit bounds through constants, `And`, `Or`, `Xor`, `LShr`, `Shl`, non-negative `AShr`, disjoint/non-overflowing `Add`, `Mul` (trailing-zero and non-overflowing product bounds), constant-divisor `UDiv`/`URem`, `Select`, `ZExt`, `Trunc`, `dx.op.binary.i32` (`UMax`, `UMin` via highest-possible-bit fill), and `dx.op.unaryBits.i32` (`Countbits` → `0x3F`). - Replace the 1-hop `BinOp::And` special cases in `Module::simplify_op` with the general `known_nonzero_bits` check (covering both redundant masks and disjoint non-constant `and` → `0`), and fold `LShr`, `Shl`, and sign-bit-zero `AShr` to `0` when all possibly-nonzero bits are shifted out. - Add unit and RTX 3070 GPU parity tests in `opt::known_bits_tests`, including soundness checks verifying that `umin(x & 0x100, y) & 0xFF` and sign-unknown `ashr` are *not* erroneously folded. **Measured impact** 573-program retail direct-DXIL validation sweep (`dxil.dll` 1.8.2502.11): - Baseline (`6d12f58`): `573/573` validated (`val_fail=0`), `51,117,488` total DXIL bytes (`p50=22,865 us`, `p95=408,132 us`). - This PR (`2a1fadc`): `573/573` validated (`val_fail=0`), `51,111,472` total DXIL bytes (`-6,016 B` / `-0.012%`; `p50=20,048 us`, `p95=376,645 us`). **Tested** - Targeted unit + GPU parity tests (`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 existing `opt` tests). - Full workspace (`.\scripts\test.ps1`, NVIDIA GeForce RTX 3070, Windows 11): `1425 passed, 0 failed, 46 ignored`. - 573-shader direct DXIL `dxil.dll` validation sweep: `573/573` passed, `0` failures. - Release build (`cargo build --release -p xcl`) and 60 s retail smoke run (see below). **Not tested** - Wave64-only GPU paths (the RTX 3070 runs wave32; wave64 GPU tests skipped automatically on this adapter). **Regression run** Main (`f087b99`): ``` xcl-smoke v1 commit: f087b998d0d51a9f11bbfa0761967a63e778edd9 gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14467 MB ``` This PR (`2a1fadc`): ``` xcl-smoke v1 commit: 2a1fadcf8eb4c67079e0b1646528a8603c804be7 gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1620 (PresentX 1620) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14006 MB ``` **AI use** - Antigravity (Gemini 4 Neon): implementation, soundness & GPU parity tests, 573-shader DXIL sweep, and PR drafting.
upipibi commented 2026-11-26 00:05:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-25T23:12:29Z.


NVIDIA test report for 2a1fadc: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug.

cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4 (the hle::xaudio2 tests hang on this machine, also on main):

  • this PR 2a1fadc: 1291 passed, 0 failed, 26 ignored.
  • main at e1d84b7 (this PR's base): 1289 passed, 0 failed, 26 ignored.
  • The same 25 SKIPPED lines on both sides (no wave64 etc.).

Lib tests only; no title run.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7177266319 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557#issuecomment-7177266319). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T23:12:29Z. --- NVIDIA test report for `2a1fadc`: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. `cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4` (the `hle::xaudio2` tests hang on this machine, also on `main`): - this PR `2a1fadc`: **1291 passed, 0 failed**, 26 ignored. - `main` at `e1d84b7` (this PR's base): 1289 passed, 0 failed, 26 ignored. - The same 25 `SKIPPED` lines on both sides (no wave64 etc.). Lib tests only; no title run. AI-assisted (Claude Code, Claude Opus 5.5).
DarkPanda69 commented 2026-11-26 00:05:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T23:12:15Z.


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 2a1fadc applied on main e1d84b7, debug, Windows 11 Pro 26200, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4 on main and with the PR, card chosen with XCL_ADAPTER:

main this PR
RX 9070 XT (RDNA4, 32.0.32029.2010) 698 passed, 2 failed, 6 SKIPPED 700 passed, 2 failed, 6 SKIPPED
RTX 3060 (32.0.16.1088) 700 passed, 0 failed, 24 SKIPPED 702 passed, 0 failed, 24 SKIPPED

On both cards, the only result changes against main are the new known_nonzero_bits_folds_compound_masks_and_shifts and known_nonzero_bits_gpu_parity, both ok, with no new skips. known_nonzero_bits_gpu_parity itself runs a wave32 kernel. The wave64 coverage here comes from the rest of the suite: on the RTX 3060, 21 wave64 cases skip. On the RX 9070 XT, 18 of them ran over the new folding 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 on main.

Not tested: Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7177261740 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557#issuecomment-7177261740). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-25T23:12:15Z. --- 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 `2a1fadc` applied on `main` `e1d84b7`, debug, Windows 11 Pro 26200, `XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4` on `main` and with the PR, card chosen with `XCL_ADAPTER`: | | `main` | this PR | |---|---|---| | RX 9070 XT (RDNA4, 32.0.32029.2010) | 698 passed, 2 failed, 6 SKIPPED | 700 passed, 2 failed, 6 SKIPPED | | RTX 3060 (32.0.16.1088) | 700 passed, 0 failed, 24 SKIPPED | 702 passed, 0 failed, 24 SKIPPED | On both cards, the only result changes against `main` are the new `known_nonzero_bits_folds_compound_masks_and_shifts` and `known_nonzero_bits_gpu_parity`, both ok, with no new skips. `known_nonzero_bits_gpu_parity` itself runs a wave32 kernel. The wave64 coverage here comes from the rest of the suite: on the RTX 3060, 21 wave64 cases skip. On the RX 9070 XT, 18 of them ran over the new folding 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 on `main`. Not tested: Intel, a title. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
emirduran707 commented 2026-11-26 00:05:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T23:16:59Z.


Independent AMD RDNA4 (native wave64) verification of exact PR head 2a1fadcf8eb4c67079e0b1646528a8603c804be7 on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver 32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC 1.9.2602.17).

Tested

  • cargo build --workspace (debug): passed (0 errors).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1423 passed, 2 failed, 46 ignored (8 SKIPPED: 6 per-lane DXIL forms refused by host adapter/driver, 1 heap_window_out_of_memory_falls_back_to_the_switch_form no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record Windows Developer Mode off).
    • Both new tests passed on this GPU:
      • gpu::dxil::module::opt::known_bits_tests::known_nonzero_bits_folds_compound_masks_and_shifts
      • gpu::dxil::module::opt::known_bits_tests::known_nonzero_bits_gpu_parity
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and fuzz_validate_and_gpu_3) are pre-existing on unmodified main on this RX 9060 XT / driver 32.0.31044.16.
  • cargo build --release -p xcl + 60 s retail-title smoke test (scripts/smoke.ps1, offline):
xcl-smoke v1
commit: 2a1fadcf8eb4c67079e0b1646528a8603c804be7
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1578 (PresentX 1578)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13963 MB

(Compare against main 68a284a on this machine: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.
<!-- greyfinch-sync:ivall/xcl:comment:7177356106 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557#issuecomment-7177356106). Originally posted by [emirduran707](https://github.com/emirduran707) on 2026-11-25T23:16:59Z. --- Independent AMD RDNA4 (native wave64) verification of exact PR head `2a1fadcf8eb4c67079e0b1646528a8603c804be7` on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver `32.0.31044.16`, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC `1.9.2602.17`). **Tested** - `cargo build --workspace` (debug): passed (`0` errors). - `cargo test --workspace --no-fail-fast -- --test-threads=4`: `1423 passed, 2 failed, 46 ignored` (`8 SKIPPED`: 6 per-lane DXIL forms refused by host adapter/driver, 1 `heap_window_out_of_memory_falls_back_to_the_switch_form` no heap windows, 1 `pso_measurement_compiles_an_exact_synthetic_record` Windows Developer Mode off). - Both new tests passed on this GPU: - `gpu::dxil::module::opt::known_bits_tests::known_nonzero_bits_folds_compound_masks_and_shifts` - `gpu::dxil::module::opt::known_bits_tests::known_nonzero_bits_gpu_parity` - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` and `fuzz_validate_and_gpu_3`) are pre-existing on unmodified `main` on this RX 9060 XT / driver `32.0.31044.16`. - `cargo build --release -p xcl` + 60 s retail-title smoke test (`scripts/smoke.ps1`, offline): ``` xcl-smoke v1 commit: 2a1fadcf8eb4c67079e0b1646528a8603c804be7 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1578 (PresentX 1578) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13963 MB ``` (Compare against `main` `68a284a` on this machine: `1573 frames, 14420 MB peak, 0 device removals, 0 crashes`.) **Not tested** - NVIDIA / Intel GPUs, Linux / Wine. **AI use** - Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.
DavidM1911 commented 2026-11-26 00:05:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T23:19:12Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7177403251 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557#issuecomment-7177403251). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T23:19:12Z. --- 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
SlopTart commented 2026-11-26 00:05:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-25T23:41:16Z.


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 target x86_64-pc-windows-gnu run 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): 166 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.
known_nonzero_bits_gpu_parity ran inside the suite. Targeted run of known_nonzero_bits_folds_compound_masks_and_shifts (IR-level, outside the gpu_ 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.

<!-- greyfinch-sync:ivall/xcl:comment:7177909679 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557#issuecomment-7177909679). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-25T23:41:16Z. --- **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 target `x86_64-pc-windows-gnu` run 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): 166 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. `known_nonzero_bits_gpu_parity` ran inside the suite. Targeted run of `known_nonzero_bits_folds_compound_masks_and_shifts` (IR-level, outside the `gpu_` 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.
Decodere commented 2026-11-27 02:13:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T02:13:55Z.


Independent desktop NVIDIA (Wave32-only Ada) verification of PR #2557 at head 2a1fadcf8eb4c67079e0b1646528a8603c804be7 (1 commit; exact parent & merge-base: e1d84b7d9153f86a97d2ec5d209d196046fc0bea, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, Wave32-only Ada), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (2a1fadcf)

Command Result
cargo test --release -p xcl --lib known_nonzero_bits_folds_compound_masks_and_shifts -- --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 known_nonzero_bits_gpu_parity -- --nocapture (3 consecutive runs) 1 passed; 0 failed; 0 ignored; 1325 filtered out × 3 (0.21s, 0.19s, 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.33s, 3.56s, 3.54s; 184 executed + 1 expected Wave32-only skip dispatch_chain_native_wave64_builds_whole: no wave64)
cargo build --release -p xcl Clean build (1m 12s, 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 #2557 (2a1fadcf8eb4c67079e0b1646528a8603c804be7):

xcl-smoke v1
commit: 2a1fadcf8eb4c67079e0b1646528a8603c804be7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1632 (PresentX 1632)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB

Runtime log observations (xcl.log)

  • 9222 log lines, 0 [ERROR] / device-removal / panic lines.
  • Final draw/memory telemetry in log: 19633 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample 14017 MB committed by the process; video memory 6116 MB local, 4682 MB non-local.

Limits of coverage

  • known_nonzero_bits compound bitmask and zero-shift folding were verified both at IR level (known_nonzero_bits_folds_compound_masks_and_shifts × 3) and end-to-end on desktop Wave32-only NVIDIA RTX 4060 (known_nonzero_bits_gpu_parity × 3, 0 skipped, plus gpu::dxil:: 184 executed + 1 expected no wave64 skip × 3).
  • Native Wave64 GPU execution is not available on this Wave32-only RTX 4060, and the warm-cache 60 s retail smoke on title: 29640639 confirms zero runtime regression rather than re-compiling a cold XCL_DIRECT_DXIL=1 shader set (frame-count and commit deltas vs. cached parent reflect single-run startup variance, not this PR).

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

<!-- greyfinch-sync:ivall/xcl:comment:7207943647 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557#issuecomment-7207943647). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-27T02:13:55Z. --- Independent desktop NVIDIA (Wave32-only Ada) verification of **PR #2557** at head `2a1fadcf8eb4c67079e0b1646528a8603c804be7` (`1` commit; exact parent & merge-base: `e1d84b7d9153f86a97d2ec5d209d196046fc0bea`, pre-`#2555` ancestor of `main`). ### Environment - **GPU:** NVIDIA GeForce RTX 4060 (8 GB / `7956 MiB` reported by D3D12, Wave32-only Ada), driver `32.0.16.2114` (NVIDIA `621.14`, WDDM 3.2) - **CPU / RAM / OS:** Intel Core i5-11400F (6C / 12T), 32 GB RAM (`31.9 GiB` usable), Windows 11 Home `26200` (Developer Mode off) - **Toolchain:** `rustc 1.100.0 (0ef1bc386 2026-11-09)` MSVC, DXC `1.9.2609.5`, `--release` ### Targeted release tests & build (`2a1fadcf`) | Command | Result | | --- | --- | | `cargo test --release -p xcl --lib known_nonzero_bits_folds_compound_masks_and_shifts -- --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 known_nonzero_bits_gpu_parity -- --nocapture` (3 consecutive runs) | `1 passed; 0 failed; 0 ignored; 1325 filtered out` × 3 (`0.21s`, `0.19s`, `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.33s`, `3.56s`, `3.54s`; `184` executed + `1` expected Wave32-only skip `dispatch_chain_native_wave64_builds_whole: no wave64`) | | `cargo build --release -p xcl` | Clean build (`1m 12s`, 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 #2557 (`2a1fadcf8eb4c67079e0b1646528a8603c804be7`): ``` xcl-smoke v1 commit: 2a1fadcf8eb4c67079e0b1646528a8603c804be7 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1632 (PresentX 1632) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14018 MB ``` ### Runtime log observations (`xcl.log`) - `9222` log lines, `0` `[ERROR]` / device-removal / panic lines. - Final draw/memory telemetry in log: `19633 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped)`; last memory sample `14017 MB committed by the process; video memory 6116 MB local, 4682 MB non-local`. ### Limits of coverage - `known_nonzero_bits` compound bitmask and zero-shift folding were verified both at IR level (`known_nonzero_bits_folds_compound_masks_and_shifts` × 3) and end-to-end on desktop Wave32-only NVIDIA RTX 4060 (`known_nonzero_bits_gpu_parity` × 3, `0` skipped, plus `gpu::dxil::` `184` executed + `1` expected `no wave64` skip × 3). - Native Wave64 GPU execution is not available on this Wave32-only RTX 4060, and the warm-cache 60 s retail smoke on `title: 29640639` confirms zero runtime regression rather than re-compiling a cold `XCL_DIRECT_DXIL=1` shader set (frame-count and commit deltas vs. cached parent reflect single-run startup variance, not this PR). *AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).*
throny commented 2026-11-27 21:49:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T21:49:18Z.


merge-check claim
head: 2a1fadcf8e

<!-- greyfinch-sync:ivall/xcl:comment:7228784333 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557#issuecomment-7228784333). Originally posted by [throny](https://github.com/throny) on 2026-11-27T21:49:18Z. --- merge-check claim head: 2a1fadcf8eb4c67079e0b1646528a8603c804be7
throny commented 2026-11-27 22:11:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-27T22:11:28Z.


merge-check
base: 2c717a04
head: 2a1fadcf8e
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1468 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1466 passed, 0 failed, 47 ignored
review: none. Each known-bits rule was checked (and, or, xor; shifts only with an amount below the width; arithmetic shift only with a known-zero sign bit; add with non-overlapping bits or no overflow; mul; unsigned div and rem by a non-zero constant; zext, trunc, min, max, countbits); it applies to widths up to 32 and to ops without flags; the old one-step folds stay covered; the depth limit is safe because operands dominate. The IR test fails on main by reading the code.
performance: compile time only; folds remove instructions. It changes a direct-DXIL source: users of XCL_DIRECT_DXIL re-translate once, the default HLSL cache is not affected (reasoned).
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

<!-- greyfinch-sync:ivall/xcl:comment:7229107693 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557#issuecomment-7229107693). Originally posted by [throny](https://github.com/throny) on 2026-11-27T22:11:28Z. --- merge-check base: 2c717a04 head: 2a1fadcf8eb4c67079e0b1646528a8603c804be7 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1468 passed, 0 failed, 47 ignored (26 SKIPPED lines); base alone: 1466 passed, 0 failed, 47 ignored review: none. Each known-bits rule was checked (and, or, xor; shifts only with an amount below the width; arithmetic shift only with a known-zero sign bit; add with non-overlapping bits or no overflow; mul; unsigned div and rem by a non-zero constant; zext, trunc, min, max, countbits); it applies to widths up to 32 and to ops without flags; the old one-step folds stay covered; the depth limit is safe because operands dominate. The IR test fails on main by reading the code. performance: compile time only; folds remove instructions. It changes a direct-DXIL source: users of XCL_DIRECT_DXIL re-translate once, the default HLSL cache is not affected (reasoned). verdict: safe to merge hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
KOLESNiii commented 2026-11-28 02:45:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T02:45:51Z.


merge-check claim
head: 2a1fadcf8e

<!-- greyfinch-sync:ivall/xcl:comment:7232578647 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557#issuecomment-7232578647). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-28T02:45:51Z. --- merge-check claim head: 2a1fadcf8eb4c67079e0b1646528a8603c804be7
KOLESNiii commented 2026-11-28 03:52:50 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T03:52:50Z.


merge-check
base: e429936c10
head: 2a1fadcf8e
merge: conflicts (crates/xcl/src/gpu/dxil/module/opt.rs)
build: not run (the PR does not merge into this base)
tests: not run on this base. On the previous base 753e8b1a the trial merge was clean, built, and its suite gave 1513 passed, 1 failed, 47 ignored, 25 SKIPPED (pls_space_info_export failed only under the load of 6 other suites running at once and passed alone).
review: not repeated on this base. On 753e8b1a: none. Whole diff read (opt.rs known_nonzero_bits, And / LShr / Shl / AShr folds using it; known_bits_tests with a GPU parity test). Each rule is conservative: Add and Mul use value bounds (a value is at most its possible-bits mask), UDiv / URem bound by the divisor, AShr only when the sign bit is known zero, UMax as the union and UMin as the smaller bound (DXIL opcodes 39 / 40), Countbits (31) as 0..=32; phis and unknown calls give all bits. The old And special cases are covered by the new rule. Note: #1906, #2557, #2568 and #2552 all change Module::simplify_op in gpu/dxil/module/opt.rs and will conflict with each other once one is merged.
performance: not assessed on this base.
verdict: not yet: conflicts with main (crates/xcl/src/gpu/dxil/module/opt.rs); rebase onto main
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile. Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).

<!-- greyfinch-sync:ivall/xcl:comment:7233472862 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557#issuecomment-7233472862). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-28T03:52:50Z. --- merge-check base: e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd head: 2a1fadcf8eb4c67079e0b1646528a8603c804be7 merge: conflicts (crates/xcl/src/gpu/dxil/module/opt.rs) build: not run (the PR does not merge into this base) tests: not run on this base. On the previous base 753e8b1a the trial merge was clean, built, and its suite gave 1513 passed, 1 failed, 47 ignored, 25 SKIPPED (pls_space_info_export failed only under the load of 6 other suites running at once and passed alone). review: not repeated on this base. On 753e8b1a: none. Whole diff read (opt.rs known_nonzero_bits, And / LShr / Shl / AShr folds using it; known_bits_tests with a GPU parity test). Each rule is conservative: Add and Mul use value bounds (a value is at most its possible-bits mask), UDiv / URem bound by the divisor, AShr only when the sign bit is known zero, UMax as the union and UMin as the smaller bound (DXIL opcodes 39 / 40), Countbits (31) as 0..=32; phis and unknown calls give all bits. The old And special cases are covered by the new rule. Note: #1906, #2557, #2568 and #2552 all change Module::simplify_op in gpu/dxil/module/opt.rs and will conflict with each other once one is merged. performance: not assessed on this base. verdict: not yet: conflicts with main (crates/xcl/src/gpu/dxil/module/opt.rs); rebase onto main hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile. Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
Foniass commented 2026-12-01 08:22:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:22:52Z.


Triage (#1607) – head 2a1fadc

No open or merged PR adds a known-bits analysis to module/opt.rs; main still has the pattern-by-pattern And folding this replaces (main's simplify_int_minmax from 110db2f sits next to it, hence the conflict). I checked each case of known_nonzero_bits (add/mul/udiv/urem bounds, umin/umax, sign-guarded ashr, zext/trunc) and found them conservative. No problems found in the diff.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305240752 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2557#issuecomment-7305240752). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:22:52Z. --- **Triage (#1607)** – head 2a1fadc No open or merged PR adds a known-bits analysis to `module/opt.rs`; main still has the pattern-by-pattern `And` folding this replaces (main's `simplify_int_minmax` from 110db2f sits next to it, hence the conflict). I checked each case of `known_nonzero_bits` (add/mul/udiv/urem bounds, umin/umax, sign-guarded ashr, zext/trunc) and found them conservative. No problems found in the diff. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2557:upstream-pr/2557'
git switch 'upstream-pr/2557'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2557'
git switch 'upstream-pr/2557'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2557'
git switch 'upstream-pr/2557'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2557'
git switch 'main'
git merge --squash 'upstream-pr/2557'
git switch 'main'
git merge --ff-only 'upstream-pr/2557'
git switch 'main'
git merge 'upstream-pr/2557'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2547
No description provided.