Recompiler: fold 64-bit ints, bitcast selects and commutative CSE in direct DXIL #1906

Open
github-bot wants to merge 1 commit from github-bot/gh-1906 into main AGit
Owner

@⁠Decodere on GitHub · 2026-11-24 22:56 UTC · original
Decodere:dxil-opt-post-phi → main · +344 −35 · 3 files · 1 commits · open

Extends the direct-DXIL optimizer (gpu::dxil::module::opt) to fold post-phi value redundancies that remain after initial lowering and trivial-phi elimination: 64-bit integer window/pack arithmetic, finite constant BitCasts, zero-duplication bitcast(select(...)) folding around VGPR float updates, nested same-condition Select chains, commutative integer ops and compares before dominator CSE, and expanded flag-neutral intrinsic DCE. Part of #1269.

Because the DXIL validator verifies that shader feature flags match the emitted instructions, f64 instructions stay untouched, BitCast constant folding excludes NaN and Inf in both directions, and Shader::infer_type_features clears Feature::Int64Ops after optimization when no surviving instruction uses i64 so folding away all 64-bit ops never fails Flags must match usage. Control-flow simplification stays in the existing #2194 simplify_cfg pass (composing cleanly with post-merge f64-only wide DCE) rather than adding terminator folding here.

What is in it

  • crates/xcl/src/gpu/dxil/module/opt.rs:
    • Separate XCL_DXIL_NO_OPT=fold from cse for independent bisecting (XCL_DXIL_NO_OPT=phi,fold,cse,dce,merge or all).
    • Enable 64-bit integer constant/identity folding and DCE (i64 arithmetic, shifts, LShr(ZExt) and LShr(Or(ZExt, Shl(ZExt))) window-high patterns, Trunc(ZExt|SExt), i1 select/compare identities, and ZExt(i1) compares), composing cleanly with #2279 algebraic bitmask folds.
    • Fold finite constant BitCast (i32 <-> f32, i16 <-> f16, excluding NaN and Inf symmetrically), reuse dominating BitCasts from CSE, collapse nested same-condition Select chains, and push BitCast through Select only when the Select has no surviving non-bitcast uses (accounting for bypassed same-condition inner selects, so no Select is duplicated) with scoped CSE alias registration.
    • Canonicalize commutative integer binops (Add/Mul/And/Or/Xor) and integer Cmp predicates before dominator CSE, and expand flag-neutral ReadNone dx.op.* DCE.
  • crates/xcl/src/gpu/dxil/shader.rs: clear Feature::Int64Ops in infer_type_features() when no surviving instruction uses i64.
  • crates/xcl/src/gpu/dxil/core_tests.rs: add opt_folds_i64_bitcast_selects_and_commutative_cse covering i64 window-high + Int64Ops cleanup, finite vs +Inf constant BitCasts, bitcast(select), nested selects, commutative CSE, zext(i1) compares, multi-window RDNA2 loop folding, DXC validation, and RTX 4060 GPU execution + HLSL parity.
  • Cache invalidation for direct-DXIL entries is handled automatically by XCL_DIRECT_DXIL_SOURCE_ID (#1947), so no manual TRANSLATOR_VERSION bump is needed.

(Rebased onto origin/main 6d12f58a to integrate cleanly with #2173 & #2368 in core_tests.rs and #2279 algebraic bitmask folds in opt.rs.)

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 4060 (8 GB, 32-lane waves, driver 621.14), Intel Core i5-11400F, 32 GB RAM, Windows 11 Home build 26200, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5; release build.
  • cargo test --release -p xcl --lib gpu::dxil::module::opt::tests -- --test-threads=1 --nocapture: 7 passed, 0 failed, 0 ignored (0.00 s, 0 skipped) on both RTX 4060 and WARP (XCL_ADAPTER=warp), including #2194 simplify_cfg_* and #2279 algebraic bitmask fold tests.
  • cargo test --release -p xcl --lib gpu::dxil::core_tests -- --test-threads=1 --nocapture: 20 passed, 0 failed, 1 ignored (1.26 s, 0 skipped) on RTX 4060, including #2173, #2368 flat-load tests, and opt_folds_i64_bitcast_selects_and_commutative_cse.
  • WARP (XCL_ADAPTER=warp): opt_folds_i64_bitcast_selects_and_commutative_cse 1 passed, 0 failed (0.02 s; DXC validation + disassembly checks ran; GPU parity portion cleanly SKIPPED: no wave32).
  • cargo build --release --workspace + cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1424 passed, 0 failed, 46 ignored across 37 test binaries (184/184 gpu::dxil::* passed, 0 failures).
  • SKIPPED GPU/runtime tests on this adapter (29 lines):
    • 21 no wave64 subcases (RTX 4060 is 32-lane waves only)
    • 3 intentional per-lane #1426 refusals (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32) in gpu::recomp::lower_dxil::tests
    • 3 D3D12 debug-layer tests (no d3d12SDKLayers.dll)
    • 1 shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode required)
    • 1 heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
  • Direct-DXIL validated corpus comparison (measured on pre-rebase baseline 689f2db4 vs this optimization pass on a 300-record seed-1 retail shader pack sample, 252/252 = 100.0% translated across 22 CS, 4 GS, 98 MS, 97 PS, 31 VS):
    • Validator errors: 0, panics: 0, timeouts: 0 (also 0 errors across 977/977 translated programs in a 1,000-record --max-bytes 65536 validated sweep, and 0 errors across 13/13 in a 20-record --validate check with XCL_DXIL_NO_OPT=fold).
    • Total DXIL size: 12,208,376 -> 11,811,244 B (-397,132 B, -3.25%; 252/252 shrank, 0 unchanged, 0 grew; per-shader median -3.35%, range -0.46% to -7.82%).
    • Total LLVM instructions: 1,683,483 -> 1,576,845 (-106,638, -6.33%); bitcast: 191,134 -> 136,196 (-54,938, -28.74%); select: 265,081 -> 258,991 (-6,090, -2.30%); i64 ops: 79,848 -> 49,251 (-30,597, -38.32%).
    • Translation wall time for the 252-program sweep: 2.1 s (main) vs 1.9 s (PR).
  • Cold RTX 4060 CreateComputePipelineState check on 15 unique-hash retail direct-DXIL compute shaders (28–37 KB, alternating main/PR order, verified cold vs 0.5–1.1 ms warm 2nd calls):
    • 15/15 compiled cleanly with 0 driver errors.
    • Total DXIL bytes: 497,560 -> 480,904 B (-3.35%).
    • Total cold PSO compile time: 3,037.9 ms -> 3,123.3 ms (+2.81%; 7 faster / 8 slower, median +1.70%, range -12.57% to +21.83%, within single-shot driver variance).

Regression run
scripts/smoke.ps1 on origin/main (889ef3e8aa7f267323ab4879e735e65da6bcef10) and on this PR's head commit (894e29d63b3a668f5d04bb74a6cc88f06798805f):

xcl-smoke v1
commit: 889ef3e8aa7f267323ab4879e735e65da6bcef10
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1550 (PresentX 1550)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13981 MB
xcl-smoke v1
commit: 894e29d63b3a668f5d04bb74a6cc88f06798805f
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1539 (PresentX 1539)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13970 MB

Not tested

  • AMD and Intel GPUs, native wave64 hardware, and heap-window hardware paths (skipped above; prior pre-rebase commits were verified on Intel Arc and AMD RX 6750 XT in PR comments).
  • Live in-game retail smoke with XCL_DIRECT_DXIL=1 enabled (the default smoke run above exercises the default HLSL runtime path; direct-DXIL coverage was verified via corpus DXC validation, cold RTX 4060 PSO creation, and direct-DXIL GPU execution parity tests).
  • Debug-profile full workspace test run (the full suite ran in --release), and re-running the 252-program corpus/cold-PSO measurement after the #2194/#2180/#2279 merge-conflict rebases.

AI use

  • Google Antigravity (Gemini 4 Neon) — implemented the optimization pass, tests, benchmarks, #2194/#2180/#2173/#2279 rebases, and PR description; every line of the diff, test output, benchmark run, and smoke check was verified on local RTX 4060 hardware.
  • Google Antigravity (Gemini 4 Carbon) — audited the diff, validator invariants, and live upstream PR collisions.
**@⁠Decodere** on GitHub · 2026-11-24 22:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906) `Decodere:dxil-opt-post-phi` → `main` · +344 −35 · 3 files · 1 commits · open Extends the direct-DXIL optimizer (`gpu::dxil::module::opt`) to fold post-phi value redundancies that remain after initial lowering and trivial-phi elimination: 64-bit integer window/pack arithmetic, finite constant `BitCast`s, zero-duplication `bitcast(select(...))` folding around VGPR float updates, nested same-condition `Select` chains, commutative integer ops and compares before dominator CSE, and expanded flag-neutral intrinsic DCE. Part of #1269. Because the DXIL validator verifies that shader feature flags match the emitted instructions, `f64` instructions stay untouched, `BitCast` constant folding excludes NaN and Inf in both directions, and `Shader::infer_type_features` clears `Feature::Int64Ops` after optimization when no surviving instruction uses `i64` so folding away all 64-bit ops never fails `Flags must match usage`. Control-flow simplification stays in the existing `#2194` `simplify_cfg` pass (composing cleanly with post-merge `f64`-only `wide` DCE) rather than adding terminator folding here. **What is in it** - `crates/xcl/src/gpu/dxil/module/opt.rs`: - Separate `XCL_DXIL_NO_OPT=fold` from `cse` for independent bisecting (`XCL_DXIL_NO_OPT=phi,fold,cse,dce,merge` or `all`). - Enable 64-bit integer constant/identity folding and DCE (`i64` arithmetic, shifts, `LShr(ZExt)` and `LShr(Or(ZExt, Shl(ZExt)))` window-high patterns, `Trunc(ZExt|SExt)`, `i1` select/compare identities, and `ZExt(i1)` compares), composing cleanly with `#2279` algebraic bitmask folds. - Fold finite constant `BitCast` (`i32 <-> f32`, `i16 <-> f16`, excluding NaN and Inf symmetrically), reuse dominating `BitCast`s from CSE, collapse nested same-condition `Select` chains, and push `BitCast` through `Select` only when the `Select` has no surviving non-bitcast uses (accounting for bypassed same-condition inner selects, so no `Select` is duplicated) with scoped CSE alias registration. - Canonicalize commutative integer binops (`Add`/`Mul`/`And`/`Or`/`Xor`) and integer `Cmp` predicates before dominator CSE, and expand flag-neutral `ReadNone` `dx.op.*` DCE. - `crates/xcl/src/gpu/dxil/shader.rs`: clear `Feature::Int64Ops` in `infer_type_features()` when no surviving instruction uses `i64`. - `crates/xcl/src/gpu/dxil/core_tests.rs`: add `opt_folds_i64_bitcast_selects_and_commutative_cse` covering `i64` window-high + `Int64Ops` cleanup, finite vs `+Inf` constant `BitCast`s, `bitcast(select)`, nested selects, commutative CSE, `zext(i1)` compares, multi-window RDNA2 loop folding, DXC validation, and RTX 4060 GPU execution + HLSL parity. - Cache invalidation for direct-DXIL entries is handled automatically by `XCL_DIRECT_DXIL_SOURCE_ID` (#1947), so no manual `TRANSLATOR_VERSION` bump is needed. *(Rebased onto `origin/main` `6d12f58a` to integrate cleanly with `#2173` & `#2368` in `core_tests.rs` and `#2279` algebraic bitmask folds in `opt.rs`.)* **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 4060 (8 GB, 32-lane waves, driver 621.14), Intel Core i5-11400F, 32 GB RAM, Windows 11 Home build 26200, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2609.5; release build. - `cargo test --release -p xcl --lib gpu::dxil::module::opt::tests -- --test-threads=1 --nocapture`: `7 passed, 0 failed, 0 ignored` (`0.00 s`, `0` skipped) on both RTX 4060 and WARP (`XCL_ADAPTER=warp`), including `#2194` `simplify_cfg_*` and `#2279` algebraic bitmask fold tests. - `cargo test --release -p xcl --lib gpu::dxil::core_tests -- --test-threads=1 --nocapture`: `20 passed, 0 failed, 1 ignored` (`1.26 s`, `0` skipped) on RTX 4060, including `#2173`, `#2368` flat-load tests, and `opt_folds_i64_bitcast_selects_and_commutative_cse`. - WARP (`XCL_ADAPTER=warp`): `opt_folds_i64_bitcast_selects_and_commutative_cse` `1 passed, 0 failed` (`0.02 s`; DXC validation + disassembly checks ran; GPU parity portion cleanly `SKIPPED: no wave32`). - `cargo build --release --workspace` + `cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture`: **`1424 passed, 0 failed, 46 ignored`** across `37` test binaries (`184/184` `gpu::dxil::*` passed, `0` failures). - `SKIPPED` GPU/runtime tests on this adapter (`29` lines): - `21` `no wave64` subcases (RTX 4060 is 32-lane waves only) - `3` intentional per-lane `#1426` refusals (`V_MUL_F16`, `V_PK_MUL_F16`, `V_CVT_F16_F32`) in `gpu::recomp::lower_dxil::tests` - `3` D3D12 debug-layer tests (no `d3d12SDKLayers.dll`) - `1` `shaders::tests::pso_measurement_compiles_an_exact_synthetic_record` (Windows Developer Mode required) - `1` `heap_window_out_of_memory_falls_back_to_the_switch_form` (`no heap windows`) - Direct-DXIL validated corpus comparison (measured on pre-rebase baseline `689f2db4` vs this optimization pass on a 300-record seed-1 retail shader pack sample, 252/252 = 100.0% translated across 22 CS, 4 GS, 98 MS, 97 PS, 31 VS): - Validator errors: `0`, panics: `0`, timeouts: `0` (also `0` errors across 977/977 translated programs in a 1,000-record `--max-bytes 65536` validated sweep, and `0` errors across 13/13 in a 20-record `--validate` check with `XCL_DXIL_NO_OPT=fold`). - Total DXIL size: `12,208,376 -> 11,811,244 B` (`-397,132 B`, `-3.25%`; 252/252 shrank, 0 unchanged, 0 grew; per-shader median `-3.35%`, range `-0.46%` to `-7.82%`). - Total LLVM instructions: `1,683,483 -> 1,576,845` (`-106,638`, `-6.33%`); `bitcast`: `191,134 -> 136,196` (`-54,938`, `-28.74%`); `select`: `265,081 -> 258,991` (`-6,090`, `-2.30%`); `i64` ops: `79,848 -> 49,251` (`-30,597`, `-38.32%`). - Translation wall time for the 252-program sweep: `2.1 s` (`main`) vs `1.9 s` (PR). - Cold RTX 4060 `CreateComputePipelineState` check on 15 unique-hash retail direct-DXIL compute shaders (`28–37 KB`, alternating `main`/`PR` order, verified cold vs `0.5–1.1 ms` warm 2nd calls): - 15/15 compiled cleanly with `0` driver errors. - Total DXIL bytes: `497,560 -> 480,904 B` (`-3.35%`). - Total cold PSO compile time: `3,037.9 ms -> 3,123.3 ms` (`+2.81%`; 7 faster / 8 slower, median `+1.70%`, range `-12.57%` to `+21.83%`, within single-shot driver variance). **Regression run** `scripts/smoke.ps1` on `origin/main` (`889ef3e8aa7f267323ab4879e735e65da6bcef10`) and on this PR's head commit (`894e29d63b3a668f5d04bb74a6cc88f06798805f`): ``` xcl-smoke v1 commit: 889ef3e8aa7f267323ab4879e735e65da6bcef10 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1550 (PresentX 1550) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13981 MB ``` ``` xcl-smoke v1 commit: 894e29d63b3a668f5d04bb74a6cc88f06798805f gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1539 (PresentX 1539) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 13970 MB ``` **Not tested** - AMD and Intel GPUs, native wave64 hardware, and heap-window hardware paths (skipped above; prior pre-rebase commits were verified on Intel Arc and AMD RX 6750 XT in PR comments). - Live in-game retail smoke with `XCL_DIRECT_DXIL=1` enabled (the default smoke run above exercises the default HLSL runtime path; direct-DXIL coverage was verified via corpus DXC validation, cold RTX 4060 PSO creation, and direct-DXIL GPU execution parity tests). - Debug-profile full workspace test run (the full suite ran in `--release`), and re-running the 252-program corpus/cold-PSO measurement after the `#2194`/`#2180`/`#2279` merge-conflict rebases. **AI use** - Google Antigravity (Gemini 4 Neon) — implemented the optimization pass, tests, benchmarks, `#2194`/`#2180`/`#2173`/`#2279` rebases, and PR description; every line of the diff, test output, benchmark run, and smoke check was verified on local RTX 4060 hardware. - Google Antigravity (Gemini 4 Carbon) — audited the diff, validator invariants, and live upstream PR collisions.
Extend `gpu::dxil::module::opt` to fold remaining post-phi redundancies in
direct-DXIL shaders without colliding with CFG-level folding or violating DXC
validator shader-flag invariants:

- Enable 64-bit integer constant/identity folding and DCE (`i64` arithmetic,
  shifts, `LShr(ZExt)` / `LShr(Or(ZExt, Shl(ZExt)))` window-high patterns,
  `Trunc(ZExt|SExt)`, and `i1` / `ZExt(i1)` compares) and clear
  `Feature::Int64Ops` in `Shader::infer_type_features` when no surviving
  instruction uses `i64`.
- Fold finite constant `BitCast` (`i32 <-> f32`, `i16 <-> f16`, excluding NaN
  and Inf in both directions), reuse dominating `BitCast`s from CSE, collapse
  nested same-condition `Select` chains, and push `BitCast` through `Select`
  only when the `Select` has no surviving non-bitcast uses (preventing select
  duplication).
- Canonicalize commutative integer binops (`Add`/`Mul`/`And`/`Or`/`Xor`) and
  integer `Cmp` predicates before dominator CSE, separate `XCL_DXIL_NO_OPT=fold`
  from `cse`, and expand flag-neutral `ReadNone` intrinsic DCE.
- Add validator + RTX 4060 GPU execution parity tests (direct-DXIL cache
  invalidation is automatic via `XCL_DIRECT_DXIL_SOURCE_ID`).

On a 252-program validated direct-DXIL corpus sample (100% across CS/GS/MS/PS/VS):
-3.25% DXIL bytes (-397 KB, 252/252 shrank), -6.33% instructions, -28.74%
bitcasts, -2.30% selects, -38.32% i64 ops, 0 validator errors (and 0 errors
across 977 programs in a 1,000-record sample).

Assisted-by: Google Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:09:01 +00:00
Author
Owner

@⁠Decodere on GitHub · 2026-11-24 23:19 UTC · original

Thanks @⁠upipibi for the RTX 3070 verification and @⁠ruipedro-pinheiro for the thorough review! Confirming all three points on 9ea9ad1:

  1. BitCast alias_key in the scoped CSE table (module/opt.rs:151-162, 674-677): Confirmed sound — when bitcast(select(...)) rewrites an instruction at index i, inserting alias_key = (Op::Cast(BitCast, s, to), to) mapped to repl[i].unwrap_or(Value::Inst(i)) (which dominates the subtree) and pushing the prior entry onto undo ensures dominated free_bitcast/CSE lookups reuse the rewritten value while Step::Leave cleanly restores the parent scope.
  2. Value ordering in canonicalize_commutative (module/opt.rs:187-204): Confirmed — Value: Ord provides a deterministic total order per module, applied after operand resolution purely to normalize commutative BinOp/Cmp keys for dominator CSE.
  3. DCE of threadId / groupId / flattenedThreadIdInGroup (module/opt.rs:413): Confirmed flag-neutral — Shader::infer_type_features (shader.rs:212-233) sets no Feature flags or PSV0/signature entries for them, Module::write_bitcode (module.rs:819-865) omits declarations of unreferenced dx.op.* intrinsics, and compute_init / setup_lanes_compute (kernel.rs:563, lanes.rs:142,176) already emit unused groupId / threadIdInGroup / flattenedThreadIdInGroup calls that DCE cleanly with 0 DXC validator errors across the 252-program and 977-program --direct --validate sweeps.

Leaving 9ea9ad1 untouched for now so the existing RTX 3070 test report and smoke blocks stay current; happy to push a dedicated unit test pinning points 1 & 3 if a maintainer would like one before merge.

AI use: Google Antigravity (Gemini 4 Neon) checked the line citations against 9ea9ad1 and drafted this confirmation.

**@⁠Decodere** on GitHub · 2026-11-24 23:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7147280385) Thanks @⁠upipibi for the RTX 3070 verification and @⁠ruipedro-pinheiro for the thorough review! Confirming all three points on `9ea9ad1`: 1. **BitCast `alias_key` in the scoped CSE table (`module/opt.rs:151-162, 674-677`):** Confirmed sound — when `bitcast(select(...))` rewrites an instruction at index `i`, inserting `alias_key = (Op::Cast(BitCast, s, to), to)` mapped to `repl[i].unwrap_or(Value::Inst(i))` (which dominates the subtree) and pushing the prior entry onto `undo` ensures dominated `free_bitcast`/CSE lookups reuse the rewritten value while `Step::Leave` cleanly restores the parent scope. 2. **`Value` ordering in `canonicalize_commutative` (`module/opt.rs:187-204`):** Confirmed — `Value: Ord` provides a deterministic total order per module, applied after operand resolution purely to normalize commutative `BinOp`/`Cmp` keys for dominator CSE. 3. **DCE of `threadId` / `groupId` / `flattenedThreadIdInGroup` (`module/opt.rs:413`):** Confirmed flag-neutral — `Shader::infer_type_features` (`shader.rs:212-233`) sets no `Feature` flags or PSV0/signature entries for them, `Module::write_bitcode` (`module.rs:819-865`) omits declarations of unreferenced `dx.op.*` intrinsics, and `compute_init` / `setup_lanes_compute` (`kernel.rs:563`, `lanes.rs:142,176`) already emit unused `groupId` / `threadIdInGroup` / `flattenedThreadIdInGroup` calls that DCE cleanly with `0` DXC validator errors across the 252-program and 977-program `--direct --validate` sweeps. Leaving `9ea9ad1` untouched for now so the existing RTX 3070 test report and smoke blocks stay current; happy to push a dedicated unit test pinning points 1 & 3 if a maintainer would like one before merge. AI use: Google Antigravity (Gemini 4 Neon) checked the line citations against `9ea9ad1` and drafted this confirmation.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 01:07 UTC · original

Diff audit passed across opt.rs, shader.rs, kernel.rs, and core_tests.rs (bc_only pre-pass, free_bitcast infinity/NaN guards, Int64Ops cleanup, and zext/LShr identities all look solid).

Remaining before merge:

  1. Rebase onto main — #1950 bumped TRANSLATOR_VERSION to 8, and #1947 just landed automatic XCL_DIRECT_DXIL_SOURCE_ID hashing for gpu/dxil sources, so you can drop the manual TRANSLATOR_VERSION bump in kernel.rs.
  2. Let Build and test (Windows, no GPU) run cleanly.
  3. One independent AMD GPU run on the rebased head (current reports on d73513a are NVIDIA + CPU only).
**@⁠raylitebull** on GitHub · 2026-11-25 01:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7149237238) Diff audit passed across `opt.rs`, `shader.rs`, `kernel.rs`, and `core_tests.rs` (`bc_only` pre-pass, `free_bitcast` infinity/NaN guards, `Int64Ops` cleanup, and `zext`/`LShr` identities all look solid). **Remaining before merge:** 1. Rebase onto `main` — `#1950` bumped `TRANSLATOR_VERSION` to `8`, and `#1947` just landed automatic `XCL_DIRECT_DXIL_SOURCE_ID` hashing for `gpu/dxil` sources, so you can drop the manual `TRANSLATOR_VERSION` bump in `kernel.rs`. 2. Let `Build and test (Windows, no GPU)` run cleanly. 3. One independent **AMD** GPU run on the rebased head (current reports on `d73513a` are NVIDIA + CPU only).
Author
Owner

@⁠Decodere on GitHub · 2026-11-25 01:29 UTC · original

@⁠raylitebull Done — rebased cleanly onto main (ae0518c2) at c640e80d and dropped the manual TRANSLATOR_VERSION bump in kernel.rs (relying on #1947's XCL_DIRECT_DXIL_SOURCE_ID). Re-ran gpu::dxil (110 passed, 0 failed), full RTX 4060 release workspace suite (1,087 passed, 0 failed, 46 ignored), and paired 60s scripts/smoke.ps1 (1,568 -> 1,544 frames, 0 crashes/removals); PR description updated. Ready for CI whenever convenient!

AI use: Google Antigravity (Gemini 4 Neon).

**@⁠Decodere** on GitHub · 2026-11-25 01:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7149602107) @⁠raylitebull Done — rebased cleanly onto `main` (`ae0518c2`) at `c640e80d` and dropped the manual `TRANSLATOR_VERSION` bump in `kernel.rs` (relying on `#1947`'s `XCL_DIRECT_DXIL_SOURCE_ID`). Re-ran `gpu::dxil` (`110 passed, 0 failed`), full RTX 4060 release workspace suite (`1,087 passed, 0 failed, 46 ignored`), and paired 60s `scripts/smoke.ps1` (`1,568 -> 1,544` frames, `0` crashes/removals); PR description updated. Ready for CI whenever convenient! AI use: Google Antigravity (Gemini 4 Neon).
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 01:34 UTC · original

Rebased head c640e80 (XCL_DIRECT_DXIL_SOURCE_ID via #1947, manual TRANSLATOR_VERSION bump dropped) now passes Build and test (Windows, no GPU) and PR description.

Remaining before merge: one independent AMD GPU run confirming opt_folds_i64_bitcast_selects_and_commutative_cse and gpu::dxil on c640e80 (current reports cover RTX 4060, RTX 3070 on 9ea9ad1, and CPU on d73513a).

**@⁠raylitebull** on GitHub · 2026-11-25 01:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7149707561) Rebased head `c640e80` (`XCL_DIRECT_DXIL_SOURCE_ID` via `#1947`, manual `TRANSLATOR_VERSION` bump dropped) now passes `Build and test (Windows, no GPU)` and `PR description`. **Remaining before merge:** one independent **AMD** GPU run confirming `opt_folds_i64_bitcast_selects_and_commutative_cse` and `gpu::dxil` on `c640e80` (current reports cover RTX 4060, RTX 3070 on `9ea9ad1`, and CPU on `d73513a`).
Author
Owner

@⁠Decodere on GitHub · 2026-11-25 01:55 UTC · original

Rebased cleanly onto main (3da2abb8) at 5ca498af to resolve the core_tests.rs end-of-file test conflict from #1922; module/opt.rs and shader.rs are unchanged from c640e80d.

Re-verified locally on RTX 4060 (release): gpu::dxil (113 passed, 0 failed), full workspace (1,112 passed, 0 failed, 46 ignored), and paired 60 s scripts/smoke.ps1 (1,582 -> 1,568 frames, 0 crashes/removals). Ready for CI and the remaining independent AMD GPU check.

AI use: Google Antigravity (Gemini 4 Neon & Gemini 4 Carbon).

**@⁠Decodere** on GitHub · 2026-11-25 01:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7150115959) Rebased cleanly onto `main` (`3da2abb8`) at `5ca498af` to resolve the `core_tests.rs` end-of-file test conflict from `#1922`; `module/opt.rs` and `shader.rs` are unchanged from `c640e80d`. Re-verified locally on RTX 4060 (release): `gpu::dxil` (`113 passed, 0 failed`), full workspace (`1,112 passed, 0 failed, 46 ignored`), and paired 60 s `scripts/smoke.ps1` (`1,582 -> 1,568` frames, `0` crashes/removals). Ready for CI and the remaining independent AMD GPU check. AI use: Google Antigravity (Gemini 4 Neon & Gemini 4 Carbon).
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 02:15 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 02:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7150509903) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠fallow64 on GitHub · 2026-11-25 04:04 UTC · original

Independent AMD verification on RX 6750 XT, driver 32.0.21045.5002, Windows 11 build 26200, exact head 5ca498af.

opt_folds_i64_bitcast_selects_and_commutative_cse: 1 passed, 0 failed, no skips.

A local stack of #1974 + #1946 + #1906 passed all four DXIL fuzz partitions: 2,000 validated, 1,232 GPU-compared, 0 mismatches.

Not tested: full suite or retail title.

AI use: OpenAI Codex (GPT-5) ran and analyzed the tests; I reviewed the results.

**@⁠fallow64** on GitHub · 2026-11-25 04:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7152499415) Independent AMD verification on RX 6750 XT, driver `32.0.21045.5002`, Windows 11 build 26200, exact head `5ca498af`. `opt_folds_i64_bitcast_selects_and_commutative_cse`: **1 passed, 0 failed, no skips**. A local stack of #1974 + #1946 + #1906 passed all four DXIL fuzz partitions: **2,000 validated, 1,232 GPU-compared, 0 mismatches**. Not tested: full suite or retail title. AI use: OpenAI Codex (GPT-5) ran and analyzed the tests; I reviewed the results.
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 01:36 UTC · original · edited 2026-11-25 05:42 UTC

Tested

Independent Intel Arc A770 validation of clean detached head 5ca498afcb7dd97accc91427e1e0f5b3a1bcb577 on STOR-WINLAB. Windows 11 Enterprise Evaluation 25H2 (26200.9974), Ryzen 7 3800X, Arc A770 driver 32.0.101.9175, Rust and Cargo 1.100.0 (x86_64-pc-windows-msvc), DXC and DXIL 1.9.2609.5 (DXC 01b62ad4).

Prebuilt outside the GPU lock with cargo test --locked -p xcl --lib --no-run (exit 0), using the unoptimized test profile, two build jobs, disabled incremental compilation, zero dev/test debuginfo, an exclusive target directory, and private TEMP/TMP.

Ran the prebuilt executable in a fresh Windows PowerShell process with process-scoped RemoteSigned, XCL_ADAPTER=A770, XCL_DIRECT_DXIL=0, and XCL_DXC_DIR set to %LOCALAPPDATA%\XclTooling\dxc-1.9.2609\bin\x64. The fixture invokes both backends explicitly.

& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & 'L:\XclTooling\verify-pr1523-1362129-t3-cf2e05e7\target\debug\build\xcl\97fdf2b9ff8e1482\out\xcl-97fdf2b9ff8e1482.exe' gpu::dxil::core_tests::opt_folds_i64_bitcast_selects_and_commutative_cse --exact --nocapture --test-threads=1
}

1 passed, 0 failed, 0 ignored, 0 skipped (1,088 filtered out, 0.84 s). The native test and Arc wrapper each exited 0, and the lock was released.

DXIL validation and disassembly checks passed for the synthetic shader and four-window loop, including the absence of the checked 64-bit integer requirement and constant bitcast instructions. On wave32, the synthetic direct-DXIL shader returned alternating 4.0f32 bits and zero across all 32 lanes. The one-window loop's direct DXIL and HLSL/DXC outputs matched in VGPRs 2 and 3 across all 32 lanes.

PR #1906 was open at the tested head before and after the run. The only Arc report in the PR discussion at both checks covered the earlier c640e80 head (comment 7149736126).

Not tested

Full DXIL or workspace suites, native or split wave64, release builds, other GPUs, retail smoke, and performance.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixture and wrote this report. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1906/arc-5ca498a.log and published.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 01:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7149736126) · edited 2026-11-25 05:42 UTC **Tested** Independent Intel Arc A770 validation of clean detached head `5ca498afcb7dd97accc91427e1e0f5b3a1bcb577` on STOR-WINLAB. Windows 11 Enterprise Evaluation 25H2 (26200.9974), Ryzen 7 3800X, Arc A770 driver 32.0.101.9175, Rust and Cargo 1.100.0 (`x86_64-pc-windows-msvc`), DXC and DXIL 1.9.2609.5 (DXC `01b62ad4`). Prebuilt outside the GPU lock with `cargo test --locked -p xcl --lib --no-run` (exit 0), using the unoptimized test profile, two build jobs, disabled incremental compilation, zero dev/test debuginfo, an exclusive target directory, and private `TEMP`/`TMP`. Ran the prebuilt executable in a fresh Windows PowerShell process with process-scoped `RemoteSigned`, `XCL_ADAPTER=A770`, `XCL_DIRECT_DXIL=0`, and `XCL_DXC_DIR` set to `%LOCALAPPDATA%\XclTooling\dxc-1.9.2609\bin\x64`. The fixture invokes both backends explicitly. ```powershell & 'L:/XclTooling/Invoke-ArcTest.ps1' -Test { & 'L:\XclTooling\verify-pr1523-1362129-t3-cf2e05e7\target\debug\build\xcl\97fdf2b9ff8e1482\out\xcl-97fdf2b9ff8e1482.exe' gpu::dxil::core_tests::opt_folds_i64_bitcast_selects_and_commutative_cse --exact --nocapture --test-threads=1 } ``` **1 passed, 0 failed, 0 ignored, 0 skipped** (1,088 filtered out, 0.84 s). The native test and Arc wrapper each exited 0, and the lock was released. DXIL validation and disassembly checks passed for the synthetic shader and four-window loop, including the absence of the checked 64-bit integer requirement and constant bitcast instructions. On wave32, the synthetic direct-DXIL shader returned alternating `4.0f32` bits and zero across all 32 lanes. The one-window loop's direct DXIL and HLSL/DXC outputs matched in VGPRs 2 and 3 across all 32 lanes. PR #1906 was open at the tested head before and after the run. The only Arc report in the PR discussion at both checks covered the earlier `c640e80` head (comment 7149736126). **Not tested** Full DXIL or workspace suites, native or split wave64, release builds, other GPUs, retail smoke, and performance. **AI use** T3 Code / Codex (`gpt-6.2-sol`) ran the checked-in fixture and wrote this report. Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against `pr1906/arc-5ca498a.log` and published.
Author
Owner

@⁠Decodere on GitHub · 2026-11-25 11:37 UTC · original

Rebased onto 96331383 (clean against main 426a5a74) -> 9f45961d:

  • Resolved the 2-line conflict in crates/xcl/src/gpu/dxil/module/opt.rs with #2194 (simplify_cfg import + XCL_DXIL_NO_OPT=phi,fold,cse,dce,merge); semantic diff is identical to 5ca498af and composes cleanly with #2194's post-merge DCE.
  • Re-verified gpu::dxil (148/0/3 on RTX 4060, including all 5 #2194 simplify_cfg_* tests and opt_folds_i64_bitcast_selects_and_commutative_cse), WARP (opt::tests 6/6, opt_folds_* 1/1), and paired 60 s RTX 4060 smoke (1526 -> 1540 frames, 0 removals/crashes, 14482 -> 14460 MB).

AI use: rebased, tested, and drafted with Google Antigravity (Gemini 4 Neon).

**@⁠Decodere** on GitHub · 2026-11-25 11:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7161293444) Rebased onto `96331383` (clean against `main` `426a5a74`) -> `9f45961d`: - Resolved the 2-line conflict in `crates/xcl/src/gpu/dxil/module/opt.rs` with #2194 (`simplify_cfg` import + `XCL_DXIL_NO_OPT=phi,fold,cse,dce,merge`); semantic diff is identical to `5ca498af` and composes cleanly with `#2194`'s post-merge DCE. - Re-verified `gpu::dxil` (`148/0/3` on RTX 4060, including all 5 `#2194` `simplify_cfg_*` tests and `opt_folds_i64_bitcast_selects_and_commutative_cse`), WARP (`opt::tests` `6/6`, `opt_folds_*` `1/1`), and paired 60 s RTX 4060 smoke (`1526 -> 1540` frames, `0` removals/crashes, `14482 -> 14460 MB`). _AI use: rebased, tested, and drafted with Google Antigravity (Gemini 4 Neon)._
Author
Owner

@⁠Decodere on GitHub · 2026-11-25 12:04 UTC · original

Rebased cleanly onto 1a0bbe3a -> 9dbe28be to resolve the EOF test-append conflict in crates/xcl/src/gpu/dxil/core_tests.rs after #2180 (zero semantic diff vs 9f45961d). Re-verified gpu::dxil (149/0/3), WARP (opt::tests 6/6, opt_folds_* 1/1), full release workspace (1,251 passed, 0 failed, 46 ignored), and paired 60 s RTX 4060 smoke (1540 -> 1574 frames, 0 removals/crashes, 14428 MB).

AI use: rebased, tested, and drafted with Google Antigravity (Gemini 4 Neon).

**@⁠Decodere** on GitHub · 2026-11-25 12:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7161877654) Rebased cleanly onto `1a0bbe3a` -> `9dbe28be` to resolve the EOF test-append conflict in `crates/xcl/src/gpu/dxil/core_tests.rs` after #2180 (zero semantic diff vs `9f45961d`). Re-verified `gpu::dxil` (`149/0/3`), WARP (`opt::tests` `6/6`, `opt_folds_*` `1/1`), full release workspace (`1,251 passed, 0 failed, 46 ignored`), and paired 60 s RTX 4060 smoke (`1540 -> 1574` frames, `0` removals/crashes, `14428 MB`). _AI use: rebased, tested, and drafted with Google Antigravity (Gemini 4 Neon)._
Author
Owner

@⁠anes66 on GitHub · 2026-11-25 00:34 UTC · original · edited 2026-11-25 15:02 UTC

Updated CPU checks on rebased head 9dbe28bec7604679316c7a774cf03b56a95e4778 passed. Companion 5a07741, on anes66/xcl:test/pr1906-current-main-cpu, carries our two earlier CPU test commits onto this head and adds a window-high boundary test. Production code is unchanged.

Tested

  • Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug, SDK DXC/DXIL 1.9.2602.17. No GPU initialization or title execution.
  • Existing independent arithmetic fixtures: 2,824 integer folds, 150 casts, commutative/noncommutative operation direction and reversed signed/unsigned predicate pairs.
  • New window-high test: 18,750 outputs, covering 16/32/64-bit destination words, 1/8/16/32-bit source widths, every defined nonzero shift, both OR operand orders and boundary input pairs. A wider u128 reference checks the optimized live expression, including low bits that have not been cleared and high bits lost to overflow. Valid patterns must still fold to the high input's zero extension.
  • cargo test --locked -p xcl --lib gpu::dxil::module::opt::tests:: -j 2 -- --nocapture --test-threads=1: 10 passed / 0 failed / 0 ignored / 0 skips.
  • cargo test --locked -p xcl --lib cpu_integer_folding_keeps_validator_feature_flags_consistent -j 2 -- --nocapture --test-threads=1: 1 passed / 0 failed / 0 ignored / 0 skips. Four synthetic shaders validate/disassemble; unused/folded/high-zero i64 loses Int64Ops, while live arithmetic retains it.
  • Negative control: temporarily dropping only the high-source overflow precondition fails the new test for i8-to-i16, shift 9, high 0x80 (128 returned instead of 0). Restored before the final passing runs and commit.

Not tested
GPU output, release, full workspace, a title, nonfinite constant-bitcast coverage or integration onto main newer than this PR's base. This refreshes CPU evidence after the rebase; it is not a measured performance result.


Earlier report preserved below; its commit-specific results apply to the earlier head only.

CPU-only integer optimizer checks on exact head d73513ab35dd9b57a8c5c72b52478723988b9597: no mismatch found in the tested cases. Companion tests are at 02a2e7e, directly on that head; additions are confined to module/opt.rs's existing #[cfg(test)] module.

Tested

  • Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug. No GPU, DXC, or retail input used.
  • 2824 integer folds, widths 1/8/16/32/64, including zero, the sign boundary, all-ones and a mixed-bit pattern. Live sink operands after Module::optimize must equal independently calculated 128-bit CPU arithmetic reduced to the target width. Covers add/subtract/multiply, bitwise operations, defined shifts, unsigned divide/remainder with nonzero divisors.
  • 150 truncation/sign-extension/zero-extension cases across those widths, including negative source values.
  • 64 CSE pairs with opaque nonconstant operands: five commutative operations, subtraction's preserved direction, and all ten reversed signed/unsigned integer predicates, widths 8/16/32/64. One-bit subtraction is intentionally excluded from the directional check because it is commutative modulo 2.
  • cargo test --locked -p xcl --lib gpu::dxil::module::opt::tests:: -- --nocapture --test-threads=1: 4 passed / 0 failed / 0 ignored, no skips (three new tests and the existing discard/CSE test).
  • Three temporary negative controls each failed its corresponding new test: logical instead of arithmetic right shift (i8 0x80 >> 1: 64 instead of 192); zero instead of sign extension (i1 1 -> i8: 1 instead of 255); treating subtraction as commutative. All runtime edits were restored before the final passing run and commit; the published patch adds tests only.

Not tested
Full workspace/GPU suite, validator or serialized bitcode equivalence, float/bitcast-select optimizations, performance, release, retail execution or integration onto newer main. This checks optimized integer IR, not complete shader correctness. No competing upstream PR.

AI use
Codex (GPT-6; exact variant unavailable) wrote the tests and temporary controls, ran CPU validation and prepared this report.

CPU validator follow-up

1176dcc is a separate test-only commit on top of the companion above. Four serialized compute shaders cover a predeclared-but-unused i64 feature, constant i64 arithmetic, the high half of a zero-extended i32, and live i64 multiplication/high extraction. All pass SDK validator 1.9.2602.17; disassembly shows Int64Ops only for the live case. The test creates no D3D12 device and performs no dispatch.

  • cargo test --locked -p xcl --lib cpu_integer_folding_keeps_validator_feature_flags_consistent -- --nocapture --test-threads=1: 1/0/0, no skips.
  • The four optimizer CPU tests above were rerun: 4/0/0, no skips.
  • Both temporary controls are rejected by the validator: retaining a stale flag (declared=1048592, actual=16) and removing a required live flag (declared=16, actual=1048592). Both edits were restored before the final run and commit.

This adds validator coverage only for those four serialized feature cases; the other limits above still apply. No GPU, retail execution or performance check. Codex (GPT-6; exact variant unavailable) prepared and ran this follow-up.

**@⁠anes66** on GitHub · 2026-11-25 00:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7148659541) · edited 2026-11-25 15:02 UTC Updated CPU checks on rebased head `9dbe28bec7604679316c7a774cf03b56a95e4778` passed. Companion [5a07741](https://github.com/anes66/xcl/commit/5a07741193ad519abccc3907f716d2261633fc4c), on `anes66/xcl:test/pr1906-current-main-cpu`, carries our two earlier CPU test commits onto this head and adds a window-high boundary test. Production code is unchanged. **Tested** - Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug, SDK DXC/DXIL 1.9.2602.17. No GPU initialization or title execution. - Existing independent arithmetic fixtures: **2,824 integer folds**, **150 casts**, commutative/noncommutative operation direction and reversed signed/unsigned predicate pairs. - New window-high test: **18,750 outputs**, covering 16/32/64-bit destination words, 1/8/16/32-bit source widths, every defined nonzero shift, both OR operand orders and boundary input pairs. A wider u128 reference checks the optimized live expression, including low bits that have not been cleared and high bits lost to overflow. Valid patterns must still fold to the high input's zero extension. - `cargo test --locked -p xcl --lib gpu::dxil::module::opt::tests:: -j 2 -- --nocapture --test-threads=1`: **10 passed / 0 failed / 0 ignored / 0 skips**. - `cargo test --locked -p xcl --lib cpu_integer_folding_keeps_validator_feature_flags_consistent -j 2 -- --nocapture --test-threads=1`: **1 passed / 0 failed / 0 ignored / 0 skips**. Four synthetic shaders validate/disassemble; unused/folded/high-zero i64 loses Int64Ops, while live arithmetic retains it. - Negative control: temporarily dropping only the high-source overflow precondition fails the new test for i8-to-i16, shift 9, high 0x80 (128 returned instead of 0). Restored before the final passing runs and commit. **Not tested** GPU output, release, full workspace, a title, nonfinite constant-bitcast coverage or integration onto main newer than this PR's base. This refreshes CPU evidence after the rebase; it is not a measured performance result. --- Earlier report preserved below; its commit-specific results apply to the earlier head only. CPU-only integer optimizer checks on exact head `d73513ab35dd9b57a8c5c72b52478723988b9597`: no mismatch found in the tested cases. Companion tests are at [02a2e7e](https://github.com/anes66/xcl/commit/02a2e7e1394c12f51c06d8ead924fef522b89453), directly on that head; additions are confined to `module/opt.rs`'s existing `#[cfg(test)]` module. **Tested** - Windows 10 Pro 19045, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, debug. No GPU, DXC, or retail input used. - **2824 integer folds**, widths 1/8/16/32/64, including zero, the sign boundary, all-ones and a mixed-bit pattern. Live sink operands after `Module::optimize` must equal independently calculated 128-bit CPU arithmetic reduced to the target width. Covers add/subtract/multiply, bitwise operations, defined shifts, unsigned divide/remainder with nonzero divisors. - **150 truncation/sign-extension/zero-extension cases** across those widths, including negative source values. - **64 CSE pairs** with opaque nonconstant operands: five commutative operations, subtraction's preserved direction, and all ten reversed signed/unsigned integer predicates, widths 8/16/32/64. One-bit subtraction is intentionally excluded from the directional check because it is commutative modulo 2. - `cargo test --locked -p xcl --lib gpu::dxil::module::opt::tests:: -- --nocapture --test-threads=1`: **4 passed / 0 failed / 0 ignored**, no skips (three new tests and the existing discard/CSE test). - Three temporary negative controls each failed its corresponding new test: logical instead of arithmetic right shift (`i8 0x80 >> 1`: 64 instead of 192); zero instead of sign extension (`i1 1 -> i8`: 1 instead of 255); treating subtraction as commutative. All runtime edits were restored before the final passing run and commit; the published patch adds tests only. **Not tested** Full workspace/GPU suite, validator or serialized bitcode equivalence, float/bitcast-select optimizations, performance, release, retail execution or integration onto newer main. This checks optimized integer IR, not complete shader correctness. No competing upstream PR. **AI use** Codex (GPT-6; exact variant unavailable) wrote the tests and temporary controls, ran CPU validation and prepared this report. ### CPU validator follow-up [1176dcc](https://github.com/anes66/xcl/commit/1176dcc05e6cedffccc34ce4d0e2c261b49b9068) is a separate test-only commit on top of the companion above. Four serialized compute shaders cover a predeclared-but-unused i64 feature, constant i64 arithmetic, the high half of a zero-extended i32, and live i64 multiplication/high extraction. All pass SDK validator 1.9.2602.17; disassembly shows `Int64Ops` only for the live case. The test creates no D3D12 device and performs no dispatch. - `cargo test --locked -p xcl --lib cpu_integer_folding_keeps_validator_feature_flags_consistent -- --nocapture --test-threads=1`: **1/0/0**, no skips. - The four optimizer CPU tests above were rerun: **4/0/0**, no skips. - Both temporary controls are rejected by the validator: retaining a stale flag (`declared=1048592, actual=16`) and removing a required live flag (`declared=16, actual=1048592`). Both edits were restored before the final run and commit. This adds validator coverage only for those four serialized feature cases; the other limits above still apply. No GPU, retail execution or performance check. Codex (GPT-6; exact variant unavailable) prepared and ran this follow-up.
Author
Owner

@⁠Decodere on GitHub · 2026-11-25 19:11 UTC · original

Rebased #1906 cleanly onto 3f277701 (74cf3a7a): integrated the BinOp::LShr window-high fold into #2279's match bop (opt.rs) and preserved #2173 (core_tests.rs).

Re-verified opt::tests (7/0 RTX 4060 & WARP), core_tests (18/0/1 RTX 4060), opt_folds_i64_bitcast_selects_and_commutative_cse (1/0 WARP), gpu::dxil::* (181/181), and paired 60 s RTX 4060 smoke (3f277701 1486 frames / 13989 MB vs 74cf3a7a 1535 frames / 13982 MB, 0 device removals/crashes). (git merge-tree clean against live main 2898511a.)

**@⁠Decodere** on GitHub · 2026-11-25 19:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7171943600) Rebased `#1906` cleanly onto `3f277701` (`74cf3a7a`): integrated the `BinOp::LShr` window-high fold into `#2279`'s `match bop` (`opt.rs`) and preserved `#2173` (`core_tests.rs`). Re-verified `opt::tests` (`7/0` RTX 4060 & WARP), `core_tests` (`18/0/1` RTX 4060), `opt_folds_i64_bitcast_selects_and_commutative_cse` (`1/0` WARP), `gpu::dxil::*` (`181/181`), and paired 60 s RTX 4060 smoke (`3f277701` `1486` frames / `13989 MB` vs `74cf3a7a` `1535` frames / `13982 MB`, `0` device removals/crashes). (`git merge-tree` clean against live `main` `2898511a`.)
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 23:07 UTC · original · edited 2026-11-25 21:44 UTC

A second NVIDIA generation: RTX 3070 8 GB (Ampere, 32-lane waves, split wave64), driver 616.56, Windows 11, debug, 9ea9ad1 merged onto main 689f2db (clean).

  • opt_folds_i64_bitcast_selects_and_commutative_cse: passes.
  • XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu_ --skip gpu_sparse_vram --test-threads=4: 110 passed, 0 failed, 1 ignored, the same as main (110 / 0 / 1) on this machine. The sparse test was skipped because of #1727.

Added 21:44Z: whole workspace at the current head 894e29d (as is, base 6d12f58), same RTX 3070 8 GB, driver 616.56, debug, after cargo build --workspace, cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2: 1415 passed, 0 failed, 46 ignored. The end-to-end title tests pass. hle::xaudio2 is skipped because its tests fail or hang on this machine on main too; the PR doesn't touch it. SKIPPED lines: 26 (21 no wave64, 3 f16/f32 per-lane refusals, 1 no heap windows, 1 PSO measurement that needs Developer Mode).

AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-24 23:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7147049471) · edited 2026-11-25 21:44 UTC A second NVIDIA generation: RTX 3070 8 GB (Ampere, 32-lane waves, split wave64), driver 616.56, Windows 11, debug, `9ea9ad1` merged onto `main` `689f2db` (clean). - `opt_folds_i64_bitcast_selects_and_commutative_cse`: passes. - `XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu_ --skip gpu_sparse_vram --test-threads=4`: 110 passed, 0 failed, 1 ignored, the same as `main` (110 / 0 / 1) on this machine. The sparse test was skipped because of #1727. --- **Added 21:44Z: whole workspace at the current head `894e29d`** (as is, base `6d12f58`), same RTX 3070 8 GB, driver 616.56, debug, after `cargo build --workspace`, `cargo test --workspace --no-fail-fast -- --test-threads=4 --skip hle::xaudio2`: **1415 passed, 0 failed, 46 ignored**. The end-to-end title tests pass. `hle::xaudio2` is skipped because its tests fail or hang on this machine on `main` too; the PR doesn't touch it. SKIPPED lines: 26 (21 `no wave64`, 3 f16/f32 per-lane refusals, 1 no heap windows, 1 PSO measurement that needs Developer Mode). AI-assisted (Claude Code, Claude Opus 5.5). Synthetic tests only.
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-25 23:30 UTC · original

@⁠Decodere, a measurement and an offer for this PR, from work on the size of the DXIL we hand the NVIDIA driver (#1096).

Bound DXIL over 802 compute programs a retail title (title: ea3b5e4d) has in use at its device-memory crash, translated offline with a release xcl.exe (no GPU):

tree MiB instructions
main 6d12f58a 239.44 31,926,579
this PR (894e29d6) 235.61 30,634,434
this PR + the two passes below 210.55 26,710,803

The two passes run in optimize() after your folds:

  1. an EXEC-select fold: a lane-local instruction under the same EXEC that reads select(exec, new, old), and whose own result is selected by that EXEC again, reads new; phis, memory, wave ops, derivatives and integer division keep the select;
  2. a linear pass that folds the bitcast(bitcast(x)) pairs the first one leaves.

On the NVIDIA driver (RTX 5070 Ti, driver blob bytes), the select fold on its own, on main: −5.4 % native code over 4 of the largest of these programs (3.60 → 3.40 MB). The pair fold changes the DXIL only: on a synthetic chain of 512 v_mul_legacy_f32 the driver's code is the same with and without it.

Branch, two commits on this PR's head: https://github.com/Kalmarv/xcl/commits/op-diet/on-1906 (compare: https://github.com/Decodere/xcl/compare/dxil-opt-post-phi...Kalmarv:xcl:op-diet/on-1906). Each commit has a GPU test that translates the same program with and without its pass and compares every VGPR of every lane and the SGPRs. If you want them, I can open that as a PR into your branch, or you can take them over with credit, whichever suits you.

Tested: on an RTX 2060 (NVIDIA 595.91) under Wine 11.21 + vkd3d-proton, at 71b76742, both new GPU tests pass, and gpu::dxil gives 186 passed / 2 failed / 3 ignored against 181 / 2 / 3 on main e1d84b7d. The same two tests fail on both (known gaps of that Wine stack: a memory-window test and an fma-precision test); the module::opt and select_tests unit tests pass on Windows without a GPU.
Not tested yet: the GPU tests on Windows / NVIDIA for this combination, native size of this combination, a title run.

AI use: Claude Code, Claude Opus 5.5 (code, tests, measurements, this comment).

**@⁠Kalmarv** on GitHub · 2026-11-25 23:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7177645082) @⁠Decodere, a measurement and an offer for this PR, from work on the size of the DXIL we hand the NVIDIA driver (#1096). Bound DXIL over 802 compute programs a retail title (title: ea3b5e4d) has in use at its device-memory crash, translated offline with a release `xcl.exe` (no GPU): | tree | MiB | instructions | |---|---|---| | main `6d12f58a` | 239.44 | 31,926,579 | | this PR (`894e29d6`) | 235.61 | 30,634,434 | | this PR + the two passes below | 210.55 | 26,710,803 | The two passes run in `optimize()` after your folds: 1. an EXEC-select fold: a lane-local instruction under the same EXEC that reads `select(exec, new, old)`, and whose own result is selected by that EXEC again, reads `new`; phis, memory, wave ops, derivatives and integer division keep the select; 2. a linear pass that folds the `bitcast(bitcast(x))` pairs the first one leaves. On the NVIDIA driver (RTX 5070 Ti, driver blob bytes), the select fold on its own, on main: −5.4 % native code over 4 of the largest of these programs (3.60 → 3.40 MB). The pair fold changes the DXIL only: on a synthetic chain of 512 `v_mul_legacy_f32` the driver's code is the same with and without it. Branch, two commits on this PR's head: https://github.com/Kalmarv/xcl/commits/op-diet/on-1906 (compare: https://github.com/Decodere/xcl/compare/dxil-opt-post-phi...Kalmarv:xcl:op-diet/on-1906). Each commit has a GPU test that translates the same program with and without its pass and compares every VGPR of every lane and the SGPRs. If you want them, I can open that as a PR into your branch, or you can take them over with credit, whichever suits you. Tested: on an RTX 2060 (NVIDIA 595.91) under Wine 11.21 + vkd3d-proton, at `71b76742`, both new GPU tests pass, and `gpu::dxil` gives 186 passed / 2 failed / 3 ignored against 181 / 2 / 3 on main `e1d84b7d`. The same two tests fail on both (known gaps of that Wine stack: a memory-window test and an fma-precision test); the `module::opt` and `select_tests` unit tests pass on Windows without a GPU. Not tested yet: the GPU tests on Windows / NVIDIA for this combination, native size of this combination, a title run. AI use: Claude Code, Claude Opus 5.5 (code, tests, measurements, this comment).
Author
Owner

@⁠Decodere on GitHub · 2026-11-25 23:31 UTC · original

@⁠Kalmarv Thanks for running the 802-program measurement on 894e29d6 and sharing op-diet — cutting another ~25 MiB of DXIL (30.6M -> 26.7M instructions) and 5.4% of NVIDIA native code is a solid win for #1096!

Since #1906 already has review approval, multi-GPU verification, and green CI as a focused PR, let's keep #1906 as-is so it can land without widening its review scope. Please go ahead and open your two op-diet passes as a separate PR directly against xcl-dev/xcl (stacked on #1906 or right after it merges) so it gets clean per-pass review and direct authorship credit.

AI use: Google Antigravity (Gemini 4 Neon) reviewed this reply; #1906 (894e29d6) is unchanged.

**@⁠Decodere** on GitHub · 2026-11-25 23:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7177689774) @⁠Kalmarv Thanks for running the 802-program measurement on `894e29d6` and sharing `op-diet` — cutting another ~25 MiB of DXIL (30.6M -> 26.7M instructions) and 5.4% of NVIDIA native code is a solid win for `#1096`! Since `#1906` already has review approval, multi-GPU verification, and green CI as a focused PR, let's keep `#1906` as-is so it can land without widening its review scope. Please go ahead and open your two `op-diet` passes as a separate PR directly against `xcl-dev/xcl` (stacked on `#1906` or right after it merges) so it gets clean per-pass review and direct authorship credit. _AI use: Google Antigravity (Gemini 4 Neon) reviewed this reply; `#1906` (`894e29d6`) is unchanged._
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-25 23:38 UTC · original

@⁠Decodere thanks, that makes sense: #1906 stays as it is. The two passes are now their own draft, stacked on this PR: #2576. It rebases onto main once #1906 lands.

AI use: Claude Code, Claude Opus 5.5 (wrote this reply).

**@⁠Kalmarv** on GitHub · 2026-11-25 23:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7177857097) @⁠Decodere thanks, that makes sense: #1906 stays as it is. The two passes are now their own draft, stacked on this PR: #2576. It rebases onto main once #1906 lands. AI use: Claude Code, Claude Opus 5.5 (wrote this reply).
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 05:44 UTC · original

NVIDIA and AMD full-suite run, to go with the reports above by Kalmarv, upipibi, since none of them covers AMD. Tested exact head 894e29d6 (on its base 6d12f58).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1412 passed, 0 failed, 44 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, dispatch_chain_native_wave64_builds_whole, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: opt_folds_i64_bitcast_selects_and_commutative_cse.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1423 passed, 0 failed, 46 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main b49be183 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (#1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu and mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 05:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7183760405) NVIDIA and AMD full-suite run, to go with the reports above by Kalmarv, upipibi, since none of them covers AMD. Tested exact head `894e29d6` (on its base `6d12f58`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests`: **1412 passed, 0 failed, 44 ignored**. SKIPPED (no wave64): `a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu`, `a_per_lane_2d_or_3d_group_runs_on_the_gpu`, `coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu`, `cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu`, `dispatch_chain_native_wave64_builds_whole`, `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`, `the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu`. - The new tests ran and passed: `opt_folds_i64_bitcast_selects_and_commutative_cse`. - Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1`: **1423 passed, 0 failed, 46 ignored**. SKIPPED: `f16_programs_on_the_gpu` (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f16_programs_on_the_gpu` (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `f32_programs_on_the_gpu` (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - `--skip` leaves out tests that fail on main `b49be183` too, not because of this PR. On NVIDIA: `heap_window_out_of_memory_falls_back_to_the_switch_form` (#1651), the four `gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu` tests, `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` and `mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu` ([follow-up on #1651](https://git.gtahub.st/github/xcl-dev--xcl/issues/1651)) fail because `runner::skip_test` turns their skips into failures under `XCL_REQUIRE_GPU=mesh`, and `gpu::dxil::fuzz_tests` seeds 70, 545, 1019 and 1507 fail `CreateComputePipelineState` with `E_OUTOFMEMORY` on this card (drivers 616.64 and 621.40). On AMD: `fuzz_validate_and_gpu_1` fails on seed 540 (`res[833]` 0x7 vs CPU 0x6). The AMD run does not set `XCL_REQUIRE_GPU`. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠Melow-code on GitHub · 2026-11-24 23:11 UTC · original · approved these changes

Fold logic is correct on the edges we checked: masks saturate at w=64 (the old AShr had a wrong shift count, fixed by the precalculated sx), free_bitcast excludes NaN/Inf both ways, bc_only pre-pass properly distinguishes bitcast-uses from other select arms, and the Int64Ops removal is paired with the DCE keep-list change.

Three points for the author to confirm:

  1. The BitCast alias key placed back in the CSE table in-place — a core test would pin this.
  2. Value id ordering as total order for canonicalize — harmless for CSE, worth noting.
  3. The new ReadNone DCE-able intrinsics (threadId, groupId, flattenedThreadIdInGroup) should get a validator run on a shader that uses them only in that context.
**@⁠Melow-code** on GitHub · 2026-11-24 23:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#pullrequestreview-6048878602) · **approved these changes** Fold logic is correct on the edges we checked: masks saturate at w=64 (the old AShr had a wrong shift count, fixed by the precalculated sx), free_bitcast excludes NaN/Inf both ways, bc_only pre-pass properly distinguishes bitcast-uses from other select arms, and the Int64Ops removal is paired with the DCE keep-list change. Three points for the author to confirm: 1. The BitCast alias key placed back in the CSE table in-place — a core test would pin this. 2. Value id ordering as total order for canonicalize — harmless for CSE, worth noting. 3. The new ReadNone DCE-able intrinsics (threadId, groupId, flattenedThreadIdInGroup) should get a validator run on a shader that uses them only in that context.
Author
Owner

@⁠Melow-code on GitHub · 2026-11-25 11:54 UTC · original · reviewed

Review: XCL PR #1906 — fold 64-bit ints, bitcast selects and commutative CSE in direct DXIL

Author: Decodere. opt.rs +277/-37, core_tests.rs +104, kernel.rs version bump, shader.rs flag inference. Fetch: git fetch xcl pull/1906/head:xcl1906 (base 689f2db).

Verdict: mergeable, with two points to confirm

The fold logic is correct everywhere I could find an edge:

  • The width handling is sound: masks saturate at w=64 (u64::MAX instead of 1u64 << 64), signed folding sign-extends by ((x << (64-w)) as i64) >> (64-w) and takes the already-i64 value at w=64, and the old AShr formula with a 64 - w + y shift count (wrong for w=64) is replaced by the precomputed sx >> y.
  • The LShr(ZExt) zero-fold and the window-high pattern LShr(Or(ZExt(lo), Shl(ZExt(hi), sh)), sh) → hi carry their two preconditions: the shift must reach past the low part's width (sh >= sw), and the high part must not overflow the window (sw + sh <= w). Both are checked, and the check is mirrored for both operand orders of the Or. Correct.
  • free_bitcast keeps finite constants only: both directions filter (bits & 0x7FFF_FFFF) < 0x7F80_0000, which excludes NaN and Inf while letting −0.0 through (correct: its bit pattern is exact). Same mask logic for f16↔i16 at 0x7C00. Doubles are excluded entirely, consistent with keeping the Doubles/DoubleExtensions shader flags untouched.
  • The Select(c, t, select(c, _, f)) collapse checks the resolved conditions against each other, and the bc_only pre-pass is careful: a Select condition marks its value as having a non-bitcast use, arms of other same-condition selects are exempt (they die in the collapse), and everything else — including the select's own condition — disqualifies the in-place rewrite. The in-place BitCast(Select) → Select then leaves the original (op, ty) in the CSE table so dominated bitcasts of the same select still hit it. Sound.
  • Removing Int64Ops when no i64 survives is paired with dropping i64 types from the DCE keep-list, so a module that folds its last i64 loses the flag and the dead ops both. The w > 32 guards became w > 64, which is what makes the i64 folding legal at all.
  • TRANSLATOR_VERSION 7 → 8 invalidates every translation cache, which is required since modules re-fold.

The 977-program 0-validator-error claim plus the GPU parity tests on a 4060 is the strongest evidence available for this kind of change; the bisect switch (fold split from cse in XCL_DXIL_NO_OPT) is the right shape for a regression if one shows up.

Points to confirm (non-blocking)

  1. simplify_bitcast_select replaces the instruction in place and keeps (op, ty) as a CSE alias key. If the select's own result is later bitcast again, the alias insert at the end of the loop writes repl[i].unwrap_or(...) into the table under the bitcast key — verify that a dominated BitCast(v, to) of the same select actually matches that key after the replacement (the key is (Op::Cast(BitCast, v, to), to), while the original bitcast key was (Op::Cast(BitCast, select_value, to), to); same v only if the select itself is reused). One core test would pin this.
  2. canonicalize_commutative swaps on Value id order (*b < *a). Values are reused numbers after earlier replacement rounds, so id order is a total order over live values — fine — but a constant operand always sorts against its creation id, so add v10, 5 canonicalizes to add 5, v10 only if 5's id is lower. Harmless for CSE correctness (both directions canonicalize the same way), just worth knowing when reading CSE hits.
  3. The ReadNone DCE list now includes dx.op.threadId, dx.op.groupId.* and dx.op.flattenedThreadIdInGroup.*. Those are cheap and pure, so DCE is legal — but a shader whose only use was dead-code-eliminated still emits them if the entry block references them in metadata; worth one validator run on a shader that uses them and nothing else.
**@⁠Melow-code** on GitHub · 2026-11-25 11:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#pullrequestreview-6057119591) · **reviewed** # Review: XCL PR #1906 — fold 64-bit ints, bitcast selects and commutative CSE in direct DXIL Author: Decodere. opt.rs +277/-37, core_tests.rs +104, kernel.rs version bump, shader.rs flag inference. Fetch: `git fetch xcl pull/1906/head:xcl1906` (base 689f2db). ## Verdict: mergeable, with two points to confirm The fold logic is correct everywhere I could find an edge: - The width handling is sound: masks saturate at w=64 (`u64::MAX` instead of `1u64 << 64`), signed folding sign-extends by `((x << (64-w)) as i64) >> (64-w)` and takes the already-i64 value at w=64, and the old `AShr` formula with a `64 - w + y` shift count (wrong for w=64) is replaced by the precomputed `sx >> y`. - The `LShr(ZExt)` zero-fold and the window-high pattern `LShr(Or(ZExt(lo), Shl(ZExt(hi), sh)), sh) → hi` carry their two preconditions: the shift must reach past the low part's width (`sh >= sw`), and the high part must not overflow the window (`sw + sh <= w`). Both are checked, and the check is mirrored for both operand orders of the `Or`. Correct. - `free_bitcast` keeps finite constants only: both directions filter `(bits & 0x7FFF_FFFF) < 0x7F80_0000`, which excludes NaN and Inf while letting −0.0 through (correct: its bit pattern is exact). Same mask logic for f16↔i16 at 0x7C00. Doubles are excluded entirely, consistent with keeping the `Doubles`/`DoubleExtensions` shader flags untouched. - The `Select(c, t, select(c, _, f))` collapse checks the resolved conditions against each other, and the `bc_only` pre-pass is careful: a `Select` condition marks its value as having a non-bitcast use, arms of other same-condition selects are exempt (they die in the collapse), and everything else — including the select's own condition — disqualifies the in-place rewrite. The in-place `BitCast(Select) → Select` then leaves the original `(op, ty)` in the CSE table so dominated bitcasts of the same select still hit it. Sound. - Removing `Int64Ops` when no i64 survives is paired with dropping i64 types from the DCE keep-list, so a module that folds its last i64 loses the flag and the dead ops both. The `w > 32` guards became `w > 64`, which is what makes the i64 folding legal at all. - `TRANSLATOR_VERSION` 7 → 8 invalidates every translation cache, which is required since modules re-fold. The 977-program 0-validator-error claim plus the GPU parity tests on a 4060 is the strongest evidence available for this kind of change; the bisect switch (`fold` split from `cse` in `XCL_DXIL_NO_OPT`) is the right shape for a regression if one shows up. ## Points to confirm (non-blocking) 1. `simplify_bitcast_select` replaces the instruction in place and keeps `(op, ty)` as a CSE alias key. If the select's *own* result is later bitcast again, the alias insert at the end of the loop writes `repl[i].unwrap_or(...)` into the table under the *bitcast* key — verify that a dominated `BitCast(v, to)` of the same select actually matches that key after the replacement (the key is `(Op::Cast(BitCast, v, to), to)`, while the original bitcast key was `(Op::Cast(BitCast, select_value, to), to)`; same `v` only if the select itself is reused). One core test would pin this. 2. `canonicalize_commutative` swaps on Value id order (`*b < *a`). Values are reused numbers after earlier replacement rounds, so id order is a total order over live values — fine — but a constant operand always sorts against its creation id, so `add v10, 5` canonicalizes to `add 5, v10` only if 5's id is lower. Harmless for CSE correctness (both directions canonicalize the same way), just worth knowing when reading CSE hits. 3. The `ReadNone` DCE list now includes `dx.op.threadId`, `dx.op.groupId.*` and `dx.op.flattenedThreadIdInGroup.*`. Those are cheap and pure, so DCE is legal — but a shader whose only use was dead-code-eliminated still emits them if the entry block references them in metadata; worth one validator run on a shader that uses them and nothing else.
Author
Owner

@⁠bmjask on GitHub · 2026-11-25 21:16 UTC · original · reviewed

No concrete source-level defect found. i64 width/sign handling, finite bitcast folds, select/CSE dominance, and Int64Ops cleanup look correct; current Windows CI and RTX/Intel/AMD validation are strong. Residual gaps are no Direct-DXIL live title smoke and no native-wave64/heap-window run. I found no blocker.

**@⁠bmjask** on GitHub · 2026-11-25 21:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#pullrequestreview-6065102875) · **reviewed** No concrete source-level defect found. i64 width/sign handling, finite bitcast folds, select/CSE dominance, and Int64Ops cleanup look correct; current Windows CI and RTX/Intel/AMD validation are strong. Residual gaps are no Direct-DXIL live title smoke and no native-wave64/heap-window run. I found no blocker.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 06:41 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 06:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/1906#issuecomment-7184680880) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1906/head:github-bot/gh-1906'
git switch 'github-bot/gh-1906'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1906'
git switch 'github-bot/gh-1906'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1906'
git switch 'github-bot/gh-1906'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1906'
git switch 'main'
git merge --squash 'github-bot/gh-1906'
git switch 'main'
git merge --ff-only 'github-bot/gh-1906'
git switch 'main'
git merge 'github-bot/gh-1906'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.