Recompiler: simplify integer min/max (dx.op.binary.i32) via range bounds and absorption in direct DXIL opt #2558

Closed
ramon-victor wants to merge 1 commit from upstream-pr/2568 into main
ramon-victor commented 2026-11-25 23:16:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ramon-victor on 2026-11-25T23:16:55Z.


Part of #1269.

Problem

Module::simplify_op in crates/xcl/src/gpu/dxil/module/opt.rs did not simplify dx.op.binary.i32 integer 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 4 dx.op.binary.i32 calls) and byte/half range clamps (v_cvt_pk_*, v_sat_pk_*) frequently receive constant bounds via SGPRs that only become constants after mem2reg promotes them to SSA, or clamp values whose range is already constrained by and, lshr, ashr, zext, sext, or an outer min/max. Because dx.op.binary.i32 was opaque to simplify_op, all 4 calls stayed live in the emitted DXIL.

Fix

  • Add conservative bounded [lo, hi] interval helpers Module::unsigned_range_i32 and Module::signed_range_i32 (depth 4) in crates/xcl/src/gpu/dxil/module/opt.rs, tracking ranges across i32 constants, constant-masked And (requiring bit 31 clear for signed), constant LShr (shift >= 1 for signed), constant AShr, ZExt/SExt from narrower widths, Select, and nested dx.op.binary.i32 min/max of matching signedness.
  • Add Module::simplify_int_minmax called from Module::simplify_op on dx.op.binary.i32 (37..=40), folding:
    • Identical operands (min(x, x) -> x, max(x, x) -> x).
    • Lattice idempotence and absorption (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)).
    • Non-overlapping interval bounds (ha <= lb / hb <= la for min; la >= hb / lb >= ha for 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-bound v_med3_i32/v_med3_u32 from 4 calls down to 2 (or 1 when lo == 0/i32::MIN or hi == u32::MAX/i32::MAX) automatically after mem2reg.
  • Add unit, RDNA2 IR-collapse, and RTX 3070 GPU parity tests in opt::int_minmax_tests (including soundness check that imax(x & 0x8000_00FF, 0) is not 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 (4094ff9): 573/573 validated (val_fail=0), 50,984,004 total DXIL bytes (-133,484 B / -0.261%; p50=21,870 us, p95=419,075 us).

Tested

  • Targeted unit + RDNA2 IR-collapse + RTX 3070 GPU parity tests (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).
  • 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 (4094ff9):

xcl-smoke v1
commit: 4094ff9cb9c3eea2af33f2556dae05a28987bb05
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: 14002 MB

AI use

  • Antigravity (Gemini 4 Neon): implementation, soundness & GPU parity tests, 573-shader DXIL sweep, and PR drafting.
<!-- greyfinch-sync:ivall/xcl:issue:5500842359 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568). Originally posted by [ramon-victor](https://github.com/ramon-victor) on 2026-11-25T23:16:55Z. --- Part of #1269. **Problem** `Module::simplify_op` in `crates/xcl/src/gpu/dxil/module/opt.rs` did not simplify `dx.op.binary.i32` integer 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 4 `dx.op.binary.i32` calls) and byte/half range clamps (`v_cvt_pk_*`, `v_sat_pk_*`) frequently receive constant bounds via SGPRs that only become constants after `mem2reg` promotes them to SSA, or clamp values whose range is already constrained by `and`, `lshr`, `ashr`, `zext`, `sext`, or an outer `min`/`max`. Because `dx.op.binary.i32` was opaque to `simplify_op`, all 4 calls stayed live in the emitted DXIL. **Fix** - Add conservative bounded `[lo, hi]` interval helpers `Module::unsigned_range_i32` and `Module::signed_range_i32` (depth 4) in `crates/xcl/src/gpu/dxil/module/opt.rs`, tracking ranges across `i32` constants, constant-masked `And` (requiring bit 31 clear for signed), constant `LShr` (shift `>= 1` for signed), constant `AShr`, `ZExt`/`SExt` from narrower widths, `Select`, and nested `dx.op.binary.i32` min/max of matching signedness. - Add `Module::simplify_int_minmax` called from `Module::simplify_op` on `dx.op.binary.i32` (`37..=40`), folding: - Identical operands (`min(x, x) -> x`, `max(x, x) -> x`). - Lattice idempotence and absorption (`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)`). - Non-overlapping interval bounds (`ha <= lb` / `hb <= la` for min; `la >= hb` / `lb >= ha` for 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-bound `v_med3_i32`/`v_med3_u32` from 4 calls down to 2 (or 1 when `lo == 0`/`i32::MIN` or `hi == u32::MAX`/`i32::MAX`) automatically after `mem2reg`. - Add unit, RDNA2 IR-collapse, and RTX 3070 GPU parity tests in `opt::int_minmax_tests` (including soundness check that `imax(x & 0x8000_00FF, 0)` is *not* 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 (`4094ff9`): `573/573` validated (`val_fail=0`), `50,984,004` total DXIL bytes (`-133,484 B` / `-0.261%`; `p50=21,870 us`, `p95=419,075 us`). **Tested** - Targeted unit + RDNA2 IR-collapse + RTX 3070 GPU parity tests (`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`). - 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 (`4094ff9`): ``` xcl-smoke v1 commit: 4094ff9cb9c3eea2af33f2556dae05a28987bb05 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: 14002 MB ``` **AI use** - Antigravity (Gemini 4 Neon): implementation, soundness & GPU parity tests, 573-shader DXIL sweep, and PR drafting.
DavidM1911 commented 2026-11-26 00:05:41 +00:00 (Migrated from github.com)

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


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:7177615700 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7177615700). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T23:28:45Z. --- 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 commented 2026-11-26 00:05:42 +00:00 (Migrated from github.com)

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


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 4094ff9 applied on main 08db802, 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) 704 passed, 2 failed, 6 SKIPPED 706 passed, 2 failed, 6 SKIPPED
RTX 3060 (32.0.16.1088) 706 passed, 0 failed, 24 SKIPPED 708 passed, 0 failed, 24 SKIPPED

On both cards, the only result changes against main are the new simplify_int_minmax_folds_bounds_absorption_and_clamps and med3_via_sgpr_bounds_collapses_and_matches_gpu, both ok, with no new skips. med3_via_sgpr_bounds_collapses_and_matches_gpu translates with wave64: false, so its own GPU run is wave32. The wave64 coverage comes from the rest of the suite, which runs through this optimizer pass: on the RTX 3060, 21 wave64 cases skip. On the RX 9070 XT, 18 of them ran with this PR applied 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:7177829736 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7177829736). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-25T23:37:47Z. --- 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 `4094ff9` applied on `main` `08db802`, 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) | 704 passed, 2 failed, 6 SKIPPED | 706 passed, 2 failed, 6 SKIPPED | | RTX 3060 (32.0.16.1088) | 706 passed, 0 failed, 24 SKIPPED | 708 passed, 0 failed, 24 SKIPPED | On both cards, the only result changes against `main` are the new `simplify_int_minmax_folds_bounds_absorption_and_clamps` and `med3_via_sgpr_bounds_collapses_and_matches_gpu`, both ok, with no new skips. `med3_via_sgpr_bounds_collapses_and_matches_gpu` translates with `wave64: false`, so its own GPU run is wave32. The wave64 coverage comes from the rest of the suite, which runs through this optimizer pass: on the RTX 3060, 21 wave64 cases skip. On the RX 9070 XT, 18 of them ran with this PR applied 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.
luckyteagirl commented 2026-11-26 01:05:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T00:11:41Z.


Independent RX 6800M focused report for exact PR head 4094ff9cb9c3eea2af33f2556dae05a28987bb05 (clean detached worktree).

Tested

  • AMD Radeon RX 6800M, driver 30.0.13002.13003; Ryzen 9 5980HX; Windows 11 Home build 26200; Rust 1.99.0 MSVC; DXC 1.9.2609.5.
  • XCL_ADAPTER=6800M XCL_REQUIRE_GPU=1 XCL_DIRECT_DXIL=1 cargo test --locked -p xcl --lib -j 1 med3_via_sgpr_bounds_collapses_and_matches_gpu -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, 0 skipped (1325 filtered out). No explicit SKIPPED records. The fixture’s kernel uses the wave32 form and checks the RDNA2 SGPR-bound med3 clamp against GPU results; it does not test the native wave64 form. Resource guard: none. Log: filter-med3-via-sgpr-bounds-gpu-retry.log.

Not tested

  • Full suite, native wave64 form, retail-title smoke, other GPUs.

AI use

  • OpenAI Codex (exact model variant unavailable in this session) ran this focused test and drafted this report.
<!-- greyfinch-sync:ivall/xcl:comment:7178498210 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7178498210). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T00:11:41Z. --- Independent RX 6800M focused report for exact PR head `4094ff9cb9c3eea2af33f2556dae05a28987bb05` (clean detached worktree). **Tested** - AMD Radeon RX 6800M, driver `30.0.13002.13003`; Ryzen 9 5980HX; Windows 11 Home build 26200; Rust `1.99.0` MSVC; DXC `1.9.2609.5`. - `XCL_ADAPTER=6800M XCL_REQUIRE_GPU=1 XCL_DIRECT_DXIL=1 cargo test --locked -p xcl --lib -j 1 med3_via_sgpr_bounds_collapses_and_matches_gpu -- --test-threads=1 --show-output`: **1 passed, 0 failed, 0 ignored, 0 skipped** (`1325` filtered out). No explicit `SKIPPED` records. The fixture’s kernel uses the wave32 form and checks the RDNA2 SGPR-bound med3 clamp against GPU results; it does not test the native wave64 form. Resource guard: none. Log: `filter-med3-via-sgpr-bounds-gpu-retry.log`. **Not tested** - Full suite, native wave64 form, retail-title smoke, other GPUs. **AI use** - OpenAI Codex (exact model variant unavailable in this session) ran this focused test and drafted this report.
Decodere commented 2026-11-27 01:41:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T01:41:56Z.


Independent desktop NVIDIA (Wave32-only Ada) verification of PR #2568 at head 4094ff9cb9c3eea2af33f2556dae05a28987bb05 (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 (4094ff9c)

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)

  • 9220 log 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 sample 14006 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.i32 integer min/max and med3 collapse 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, 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 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).

<!-- greyfinch-sync:ivall/xcl:comment:7207505019 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7207505019). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-27T01:41:56Z. --- Independent desktop NVIDIA (Wave32-only Ada) verification of **PR #2568** at head `4094ff9cb9c3eea2af33f2556dae05a28987bb05` (`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 (`4094ff9c`) | 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`) - `9220` log 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 sample `14006 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.i32` integer `min`/`max` and `med3` collapse 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, `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 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).*
SzczepanGrela commented 2026-11-27 04:12:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SzczepanGrela on 2026-11-27T04:12:14Z.


RX 9070 / RADV / Wine verification of exact head 4094ff9cb9c3eea2af33f2556dae05a28987bb05, current main 8b957bec6f82495aec940944c6bf47faa02db590 and the PR applied to that main. This adds targeted native wave64 and GPU range-edge coverage beyond the original wave32 med3 fixture.

Tested

  • RX 9070 16 GB, RADV GFX1201 / Mesa 26.3.1-arch3.5, Ryzen 7 7700, CachyOS 7.3.0-5-cachyos. Windows GNU release executables, Rust 1.97.1, GE-Proton11-12 / Wine 11.0 Staging, native DXGI/D3D12 through vkd3d-proton 8293130ebe370b1+ (local asserts-disabled build), DXC/DXIL 1.9.2602.17.
  • Separate source copies with original assertions preserved and test-only captures. Exact parent is e1d84b7d9153f86a97d2ec5d209d196046fc0bea; the one-file change merges automatically onto current main, preserving main's optional test-only PHI-CSE branch. That switch was unset.
  • Build each: cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run --message-format=json-render-diagnostics.
  • Original filter through Wine: <unit.exe> int_minmax_tests --nocapture --test-threads=1, then --test-threads=4.
Source Threads 1 Threads 4
Main + original test additions 0 passed, 2 failed 0 passed, 2 failed
Exact head 2 passed, 0 failed 2 passed, 0 failed
Current-main integration 2 passed, 0 failed 2 passed, 0 failed

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 <unit.exe> workflow_minmax_range_matrix --nocapture --test-threads=1, three fresh processes per source: 1 passed, 0 failed in all nine runs. Each process dispatches 16 batches in native wave32 and 16 in native wave64. Every lane computes 55 outputs from deterministic boundary/random input pairs:

  • All four integer min/max operators: identity, idempotence and dual absorption.
  • Byte masks and the signed x & 0x800000ff counterexample.
  • Logical/arithmetic shifts by 0, 1, 16 and 31, with signed/unsigned bounds.
  • Direct bool/i16 zero/sign extensions; equivalent 8/31-bit extraction through i32 masks and shifts.
  • Bounded and potentially negative selects, a six-level select chain, and signed/unsigned med3 clamps.
  • Actual physical wave width, plus 16 untouched guard words after each output block.

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 XCL_* cleared; XCL_NETWORK=0, RX 9070 selected, XCL_REQUIRE_GPU=wave64, XCL_DXC_THREADS=1; private enabled caches per process.

Not tested

Full suite, HLSL backend, graphics or guest Compute ABI integration, native Windows, other GPUs, retail workload, scripts/smoke.ps1, timing or FPS. The additional fixture drives the direct DXIL builder/optimizer using owned synthetic shaders; it is not a title-level speedup measurement.

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.

<!-- greyfinch-sync:ivall/xcl:comment:7209606292 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7209606292). Originally posted by [SzczepanGrela](https://github.com/SzczepanGrela) on 2026-11-27T04:12:14Z. --- RX 9070 / RADV / Wine verification of exact head `4094ff9cb9c3eea2af33f2556dae05a28987bb05`, current main `8b957bec6f82495aec940944c6bf47faa02db590` and the PR applied to that main. This adds targeted native wave64 and GPU range-edge coverage beyond the original wave32 med3 fixture. **Tested** - RX 9070 16 GB, RADV GFX1201 / Mesa `26.3.1-arch3.5`, Ryzen 7 7700, CachyOS `7.3.0-5-cachyos`. Windows GNU release executables, Rust `1.97.1`, GE-Proton11-12 / Wine 11.0 Staging, native DXGI/D3D12 through vkd3d-proton `8293130ebe370b1+` (local asserts-disabled build), DXC/DXIL `1.9.2602.17`. - Separate source copies with original assertions preserved and test-only captures. Exact parent is `e1d84b7d9153f86a97d2ec5d209d196046fc0bea`; the one-file change merges automatically onto current main, preserving main's optional test-only PHI-CSE branch. That switch was unset. - Build each: `cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run --message-format=json-render-diagnostics`. - Original filter through Wine: `<unit.exe> int_minmax_tests --nocapture --test-threads=1`, then `--test-threads=4`. | Source | Threads 1 | Threads 4 | |---|---|---| | Main + original test additions | 0 passed, 2 failed | 0 passed, 2 failed | | Exact head | 2 passed, 0 failed | 2 passed, 0 failed | | Current-main integration | 2 passed, 0 failed | 2 passed, 0 failed | 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 `<unit.exe> workflow_minmax_range_matrix --nocapture --test-threads=1`, three fresh processes per source: **1 passed, 0 failed** in all nine runs. Each process dispatches 16 batches in native wave32 and 16 in native wave64. Every lane computes 55 outputs from deterministic boundary/random input pairs: - All four integer min/max operators: identity, idempotence and dual absorption. - Byte masks and the signed `x & 0x800000ff` counterexample. - Logical/arithmetic shifts by 0, 1, 16 and 31, with signed/unsigned bounds. - Direct bool/i16 zero/sign extensions; equivalent 8/31-bit extraction through i32 masks and shifts. - Bounded and potentially negative selects, a six-level select chain, and signed/unsigned med3 clamps. - Actual physical wave width, plus 16 untouched guard words after each output block. 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 `XCL_*` cleared; `XCL_NETWORK=0`, RX 9070 selected, `XCL_REQUIRE_GPU=wave64`, `XCL_DXC_THREADS=1`; private enabled caches per process. **Not tested** Full suite, HLSL backend, graphics or guest Compute ABI integration, native Windows, other GPUs, retail workload, `scripts/smoke.ps1`, timing or FPS. The additional fixture drives the direct DXIL builder/optimizer using owned synthetic shaders; it is not a title-level speedup measurement. **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.
throny commented 2026-11-27 22:11:43 +00:00 (Migrated from github.com)

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


merge-check claim
head: 4094ff9cb9

<!-- greyfinch-sync:ivall/xcl:comment:7229111546 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7229111546). Originally posted by [throny](https://github.com/throny) on 2026-11-27T22:11:43Z. --- merge-check claim head: 4094ff9cb9c3eea2af33f2556dae05a28987bb05
throny commented 2026-11-27 22:28:14 +00:00 (Migrated from github.com)

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


merge-check
base: 2c717a04
head: 4094ff9cb9
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 blocking. The interval rules were checked (and-mask or clear sign bit, logical and arithmetic shifts, zext / sext, select, nested min / max, absorption only for the same signedness), the opcode numbers are right, and the median-of-three collapses are correct including reversed bounds. The tests fail without the change; the exact call count one of them asserts is brittle. For whoever merges: textual conflicts with #2557 (both insert helpers at the same place and a test module at the end of opt.rs: keep both) and with #2552 (both insert an 'if let Op::Call ... return None' block at the same spot in simplify_op: the two blocks must be merged into one, because placed one after the other the second fold is silently dead; the tests would catch it).
performance: direct DXIL only, compile time (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:7229354148 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7229354148). Originally posted by [throny](https://github.com/throny) on 2026-11-27T22:28:14Z. --- merge-check base: 2c717a04 head: 4094ff9cb9c3eea2af33f2556dae05a28987bb05 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 blocking. The interval rules were checked (and-mask or clear sign bit, logical and arithmetic shifts, zext / sext, select, nested min / max, absorption only for the same signedness), the opcode numbers are right, and the median-of-three collapses are correct including reversed bounds. The tests fail without the change; the exact call count one of them asserts is brittle. For whoever merges: textual conflicts with #2557 (both insert helpers at the same place and a test module at the end of opt.rs: keep both) and with #2552 (both insert an 'if let Op::Call ... return None' block at the same spot in simplify_op: the two blocks must be merged into one, because placed one after the other the second fold is silently dead; the tests would catch it). performance: direct DXIL only, compile time (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:46:39 +00:00 (Migrated from github.com)

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


merge-check claim
head: 4094ff9cb9

<!-- greyfinch-sync:ivall/xcl:comment:7232587046 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7232587046). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-28T02:46:39Z. --- merge-check claim head: 4094ff9cb9c3eea2af33f2556dae05a28987bb05
KOLESNiii commented 2026-11-28 04:27:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T04:27:04Z.


merge-check
base: e429936c10
head: 4094ff9cb9
merge: clean
build: cargo build --workspace -> ok; the test build (cargo test --workspace --no-run) -> failed: error[E0428] the name int_minmax_tests is defined multiple times (crates/xcl/src/gpu/dxil/module/opt.rs:1999, first at :1827)
tests: not run (the test build fails)
review: main already has simplify_int_minmax and an int_minmax_tests module (110db2fb "Recompiler: simplify direct-DXIL integer min and max", merged with #2959), so the trial merge's only change is this PR's test module, added a second time under the same name. Whether anything of this PR is still missing from main needs the author's rebase.
performance: not assessed (the merge adds only tests)
verdict: not yet: the test build fails on the merge (duplicate int_minmax_tests module); main appears to carry this change already, 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; trial merge 02a4b429a768ffb0b00441a7e858ccd78f823acc (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).

<!-- greyfinch-sync:ivall/xcl:comment:7234046993 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7234046993). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-28T04:27:04Z. --- merge-check base: e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd head: 4094ff9cb9c3eea2af33f2556dae05a28987bb05 merge: clean build: cargo build --workspace -> ok; the test build (cargo test --workspace --no-run) -> failed: error[E0428] the name `int_minmax_tests` is defined multiple times (crates/xcl/src/gpu/dxil/module/opt.rs:1999, first at :1827) tests: not run (the test build fails) review: main already has simplify_int_minmax and an int_minmax_tests module (110db2fb "Recompiler: simplify direct-DXIL integer min and max", merged with #2959), so the trial merge's only change is this PR's test module, added a second time under the same name. Whether anything of this PR is still missing from main needs the author's rebase. performance: not assessed (the merge adds only tests) verdict: not yet: the test build fails on the merge (duplicate int_minmax_tests module); main appears to carry this change already, 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; trial merge 02a4b429a768ffb0b00441a7e858ccd78f823acc (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
futurepro62 commented 2026-12-01 05:54:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-12-01T05:54:29Z.


merge-check
base: d0832e614f
head: 4094ff9cb9
merge: clean
build: cargo build --workspace -> ok
tests: not run: cargo test --workspace --no-run fails on the merge with E0428, int_minmax_tests defined twice (crates/xcl/src/gpu/dxil/module/opt.rs, main's at line 2861, this PR's at 3033)
review: this PR is already on main, byte for byte. git patch-id --stable of its diff against its merge base (e1d84b7d) is 7ebf1986…, the same as main's 110db2fb ("Recompiler: simplify direct-DXIL integer min and max", bmjask, landed with #2959). Every line it adds is in main's opt.rs (254 of 254 distinct lines). Git merges the function once but adds the test module a second time, hence the error. So the "not yet" (KOLESNiii) and the "safe to merge" (throny, on an older base before #2959) don't conflict on the code: the code was right, and main already has it. Nothing is left to merge. The PR can be closed as carried by #2959 (author credit is the maintainer's call).
performance: none: no change against main.
verdict: not yet: already on main (identical patch to 110db2fb via #2959); the merge's test build fails on the duplicate module, close or rebase to nothing
hardware / tool and model: RTX 5070 Ti 16 GB + AMD Radeon iGPU, Ryzen 7 9800X3D, Windows 11 26300 (no suite ran: the test build fails). Claude Code, Claude Opus 5.5: merge, build, test build, patch-id comparison and review.

<!-- greyfinch-sync:ivall/xcl:comment:7302266102 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7302266102). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-12-01T05:54:29Z. --- merge-check base: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f head: 4094ff9cb9c3eea2af33f2556dae05a28987bb05 merge: clean build: cargo build --workspace -> ok tests: not run: `cargo test --workspace --no-run` fails on the merge with E0428, `int_minmax_tests` defined twice (`crates/xcl/src/gpu/dxil/module/opt.rs`, main's at line 2861, this PR's at 3033) review: this PR is already on `main`, byte for byte. `git patch-id --stable` of its diff against its merge base (`e1d84b7d`) is `7ebf1986…`, the same as main's `110db2fb` ("Recompiler: simplify direct-DXIL integer min and max", bmjask, landed with #2959). Every line it adds is in main's `opt.rs` (254 of 254 distinct lines). Git merges the function once but adds the test module a second time, hence the error. So the "not yet" (KOLESNiii) and the "safe to merge" (throny, on an older base before #2959) don't conflict on the code: the code was right, and `main` already has it. Nothing is left to merge. The PR can be closed as carried by #2959 (author credit is the maintainer's call). performance: none: no change against `main`. verdict: not yet: already on `main` (identical patch to 110db2fb via #2959); the merge's test build fails on the duplicate module, close or rebase to nothing hardware / tool and model: RTX 5070 Ti 16 GB + AMD Radeon iGPU, Ryzen 7 9800X3D, Windows 11 26300 (no suite ran: the test build fails). Claude Code, Claude Opus 5.5: merge, build, test build, patch-id comparison and review.
Foniass commented 2026-12-01 08:23:24 +00:00 (Migrated from github.com)

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


Triage (#1607) – head 4094ff9

This change is already on main: commit 110db2f ("Recompiler: simplify direct-DXIL integer min and max", adapted from this PR) adds the same unsigned_range_i32, signed_range_i32 and simplify_int_minmax to gpu/dxil/module/opt.rs; the added lines are identical to this diff.
Recommendation: close (superseded by main commit 110db2f).

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:7305252613 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7305252613). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:23:24Z. --- **Triage (#1607)** – head 4094ff9 This change is already on main: commit 110db2f ("Recompiler: simplify direct-DXIL integer min and max", adapted from this PR) adds the same `unsigned_range_i32`, `signed_range_i32` and `simplify_int_minmax` to `gpu/dxil/module/opt.rs`; the added lines are identical to this diff. Recommendation: close (superseded by main commit 110db2f). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 12:53:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:53:53Z.


Closing as superseded: this change is already on main (110db2fb). PR's changed lines are identical to main 110db2fb 'Adapted from #2568' (unsigned_range_i32 / signed_range_i32 / simplify_int_minmax and test); compared line by line

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311807801 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2568#issuecomment-7311807801). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:53:53Z. --- Closing as superseded: this change is already on `main` (110db2fb). PR's changed lines are identical to main 110db2fb 'Adapted from #2568' (unsigned_range_i32 / signed_range_i32 / simplify_int_minmax and test); compared line by line Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

Pull request closed

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!2558
No description provided.