Recompiler: simplify direct DXIL frexp_mant, frexp_exp, and alignbit helpers #2631

Closed
Decodere wants to merge 1 commit from upstream-pr/2641 into main
Decodere commented 2026-11-26 04:35:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T04:35:05Z.


What is in it

Part of #2508
Part of #2403
Part of #1833

Direct-DXIL frexp_mant, frexp_exp, and alignbit (crates/xcl/src/gpu/dxil/prelude.rs) previously emitted redundant intrinsics, int/float round-trips, and compare/select workarounds on every V_FREXP_MANT_F32, V_FREXP_EXP_I32_F32, V_FREXP_MANT_F16, V_FREXP_EXP_I16_F16, V_ALIGNBIT_B32, and V_ALIGNBYTE_B32 instruction:

  • frexp_exp routed through private frexp_dxc, converting integer e to float (sitofp) and back to i32 (fptosi), while both frexp_mant and frexp_exp emitted two @dx.op.isSpecialFloat calls (IsInf + IsNaN) even though e_raw = bits(x) & 0x7F80_0000 is already extracted.
  • alignbit emitted and 31, lshr, sub 32, s, and 31, shl, or, icmp eq s, 0, and select for both dynamic and constant shift counts.

Scoped solely to crates/xcl/src/gpu/dxil/prelude.rs (+173/-42 lines; net -7 production lines + 144 test lines):

  • Removed private frexp_dxc and lowered frexp_mant and frexp_exp directly from i = bits(x) and e_raw = i & 0x7F80_0000:
    • Uses pure integer zero = (e_raw == 0) and special = (e_raw == 0x7F80_0000) instead of @dx.op.isSpecialFloat, sitofp/fptosi, or fcmp oeq float x, 0.0. Checking e_raw == 0 in integer bits eliminates driver-dependent FTZ vs denorm-preserve divergence on fcmp (fixing @DarkPanda69's RTX 3060 Ampere report where fcmp oeq 0x0000_0001, 0.0 did not flush subnormals and produced 0x3F00_0001 instead of 0), while keeping exact behavior for F32 (±0.0, FTZ subnormals, normals, ±Inf, ±sNaN/±qNaN preserving sign and payload) and F16 (whose subnormals widen to normal F32 values in f16_to_f32).
  • Simplified alignbit(s0, s1, s):
    • Constant s: masks sh = (k as u32) & 31, returning s1 directly when sh == 0 (0 ops) or (s1 >> sh) | (s0 << (32 - sh)) (3 ops).
    • Dynamic s: sh = s & 31, ((s0 << 1) << (sh ^ 31)) | (s1 >> sh) (6 ops, zero sub 32, zero icmp, zero select, every shift count strictly in 0..=31).
  • Added direct-DXIL validation/disassembly and wave32 GPU tests in prelude.rs:
    • gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip (F32 V_FREXP_MANT_F32 + V_FREXP_EXP_I32_F32: asserts zero @dx.op.isSpecialFloat, sitofp, fptosi, and fcmp oeq; checks all 12 IEEE-754 edge cases on GPU).
    • gpu_direct_frexp_f16_avoids_special_float_and_matches_isa (addressing @luckyteagirl's F16 coverage review: translates V_FREXP_MANT_F16 + V_FREXP_EXP_I16_F16, asserts zero @dx.op.isSpecialFloat, sitofp, fptosi, and fcmp oeq, and verifies 11 F16 cases including ±0.0, F16 subnormals, negative normals, ±Inf, and ±qNaN on GPU).
    • gpu_direct_alignbit_is_select_free_and_matches_isa (uses wrapping_mul in lane setup to fix the debug-build u32 overflow panic reported by @luckyteagirl and @DarkPanda69).

Tested

  • Hardware & toolchain: Windows 11 Home (build 26200), Intel Core i5-11400F (6C/12T), 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (driver 621.14), rustc 1.100.0, DXC 1.9.2609.5 (01b62ad4).
  • Failing-first reproduction on unmodified b49be183: F32 frexp disassembly contained @dx.op.isSpecialFloat, sitofp, and fptosi; alignbit disassembly contained sub i32 32,, 3 icmp eq, and 9 select i1. On previous PR head 84ae02e8, debug builds panicked on prelude.rs:998 overflow and Ampere did not FTZ fcmp oeq.
  • WARP (XCL_ADAPTER=warp, XCL_WARP=1, release): cargo test --release -p xcl --lib -- gpu::dxil::prelude:: --nocapture -> 10 passed; 0 failed; 0 ignored (0.03 s; DXC 1.9 validate & disassembly assertions ran and passed on F32 frexp, F16 frexp, and alignbit; wave32 GPU sections skipped cleanly on WARP).
  • RTX 4060 targeted (release):
    • cargo test --release -p xcl --lib -- gpu::dxil::prelude:: --nocapture -> 10 passed; 0 failed; 0 ignored (0 skipped, 0.42 s).
    • cargo test --release -p xcl --lib -- gpu_frexp --nocapture -> 8 passed; 0 failed; 0 ignored (0 skipped, 0.44 s).
  • RTX 4060 targeted (debug): cargo test -p xcl --lib -- gpu::dxil::prelude:: --nocapture -> 10 passed; 0 failed; 0 ignored (0 skipped, 0.39 s — directly verifying the debug wrapping_mul fix and F16 direct-DXIL GPU execution).
  • Full release workspace on RTX 4060: cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 37 binaries, 1438 passed, 0 failed, 47 ignored (0 new warnings), 29 pre-existing host-gated SKIPPED lines (none in prelude::):
    • 21 wave64-only GPU tests (no wave64 on RTX 4060 32-lane waves)
    • 3 per-lane wave32 shader tests (refused)
    • 3 D3D12 debug layer tests (no d3d12SDKLayers.dll / debug layer unavailable)
    • 1 heap-window OOM fallback test (no heap windows)
    • 1 PSO driver-cache measurement test (cannot disable the driver cache)

Regression run

Paired 60 s retail smoke (scripts/smoke.ps1, RTX 4060): both base (889ef3e8, ancestor of b49be183 and c9751948) and HEAD sustained 60 60 60 presents per 2 s with 0 device removals and 0 crashes (1549 vs 1550 total frames, 14018 MB vs 13981 MB peak commit).

Base (origin/main ancestor):

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

HEAD (fix-dxil-prelude-alignbit-frexp):

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

Not tested

  • Re-running on NVIDIA Ampere (RTX 3060) or AMD RDNA2/RDNA4 hardware directly (only RTX 4060 Ada and WARP are available locally; replacing fcmp oeq with integer e_raw == 0 removes the driver FTZ dependency that caused the Ampere mismatch).
  • The 29 host/environment-skipped workspace tests listed above (native wave64 GPUs, D3D12 debug layer SDK, heap windows, driver-cache-disabled PSO measurement) and non-Windows hosts.

AI use

Google Antigravity (Gemini 4 Neon) authored the direct-DXIL frexp_mant, frexp_exp, and alignbit simplifications, integer e_raw == 0 Ampere FTZ fix, direct F16 frexp test, debug wrapping_mul fix, and verification runs; verified via DXC 1.9 validation/disassembly, RTX 4060 release & debug tests, full RTX 4060 release workspace tests, and paired 60 s retail smoke runs.

<!-- greyfinch-sync:ivall/xcl:issue:5504057096 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-26T04:35:05Z. --- **What is in it** Part of #2508 Part of #2403 Part of #1833 Direct-DXIL `frexp_mant`, `frexp_exp`, and `alignbit` (`crates/xcl/src/gpu/dxil/prelude.rs`) previously emitted redundant intrinsics, int/float round-trips, and compare/select workarounds on every `V_FREXP_MANT_F32`, `V_FREXP_EXP_I32_F32`, `V_FREXP_MANT_F16`, `V_FREXP_EXP_I16_F16`, `V_ALIGNBIT_B32`, and `V_ALIGNBYTE_B32` instruction: - `frexp_exp` routed through private `frexp_dxc`, converting integer `e` to `float` (`sitofp`) and back to `i32` (`fptosi`), while both `frexp_mant` and `frexp_exp` emitted two `@dx.op.isSpecialFloat` calls (`IsInf` + `IsNaN`) even though `e_raw = bits(x) & 0x7F80_0000` is already extracted. - `alignbit` emitted `and 31`, `lshr`, `sub 32, s`, `and 31`, `shl`, `or`, `icmp eq s, 0`, and `select` for both dynamic and constant shift counts. Scoped solely to `crates/xcl/src/gpu/dxil/prelude.rs` (`+173/-42` lines; net `-7` production lines + `144` test lines): - Removed private `frexp_dxc` and lowered `frexp_mant` and `frexp_exp` directly from `i = bits(x)` and `e_raw = i & 0x7F80_0000`: - Uses pure integer `zero = (e_raw == 0)` and `special = (e_raw == 0x7F80_0000)` instead of `@dx.op.isSpecialFloat`, `sitofp`/`fptosi`, or `fcmp oeq float x, 0.0`. Checking `e_raw == 0` in integer bits eliminates driver-dependent FTZ vs denorm-preserve divergence on `fcmp` (fixing `@DarkPanda69`'s RTX 3060 Ampere report where `fcmp oeq 0x0000_0001, 0.0` did not flush subnormals and produced `0x3F00_0001` instead of `0`), while keeping exact behavior for F32 (`±0.0`, FTZ subnormals, normals, `±Inf`, `±sNaN`/`±qNaN` preserving sign and payload) and F16 (whose subnormals widen to normal F32 values in `f16_to_f32`). - Simplified `alignbit(s0, s1, s)`: - Constant `s`: masks `sh = (k as u32) & 31`, returning `s1` directly when `sh == 0` (`0` ops) or `(s1 >> sh) | (s0 << (32 - sh))` (`3` ops). - Dynamic `s`: `sh = s & 31`, `((s0 << 1) << (sh ^ 31)) | (s1 >> sh)` (`6` ops, zero `sub 32`, zero `icmp`, zero `select`, every shift count strictly in `0..=31`). - Added direct-DXIL validation/disassembly and wave32 GPU tests in `prelude.rs`: - `gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip` (F32 `V_FREXP_MANT_F32` + `V_FREXP_EXP_I32_F32`: asserts zero `@dx.op.isSpecialFloat`, `sitofp`, `fptosi`, and `fcmp oeq`; checks all 12 IEEE-754 edge cases on GPU). - `gpu_direct_frexp_f16_avoids_special_float_and_matches_isa` (addressing `@luckyteagirl`'s F16 coverage review: translates `V_FREXP_MANT_F16` + `V_FREXP_EXP_I16_F16`, asserts zero `@dx.op.isSpecialFloat`, `sitofp`, `fptosi`, and `fcmp oeq`, and verifies 11 F16 cases including `±0.0`, F16 subnormals, negative normals, `±Inf`, and `±qNaN` on GPU). - `gpu_direct_alignbit_is_select_free_and_matches_isa` (uses `wrapping_mul` in lane setup to fix the debug-build `u32` overflow panic reported by `@luckyteagirl` and `@DarkPanda69`). **Tested** - Hardware & toolchain: Windows 11 Home (build 26200), Intel Core i5-11400F (6C/12T), 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (driver 621.14), `rustc 1.100.0`, DXC `1.9.2609.5 (01b62ad4)`. - Failing-first reproduction on unmodified `b49be183`: F32 frexp disassembly contained `@dx.op.isSpecialFloat`, `sitofp`, and `fptosi`; alignbit disassembly contained `sub i32 32,`, `3` `icmp eq`, and `9` `select i1`. On previous PR head `84ae02e8`, debug builds panicked on `prelude.rs:998` overflow and Ampere did not FTZ `fcmp oeq`. - WARP (`XCL_ADAPTER=warp`, `XCL_WARP=1`, release): `cargo test --release -p xcl --lib -- gpu::dxil::prelude:: --nocapture` -> `10 passed; 0 failed; 0 ignored` (`0.03 s`; DXC 1.9 validate & disassembly assertions ran and passed on F32 frexp, F16 frexp, and alignbit; wave32 GPU sections skipped cleanly on WARP). - RTX 4060 targeted (release): - `cargo test --release -p xcl --lib -- gpu::dxil::prelude:: --nocapture` -> `10 passed; 0 failed; 0 ignored` (`0` skipped, `0.42 s`). - `cargo test --release -p xcl --lib -- gpu_frexp --nocapture` -> `8 passed; 0 failed; 0 ignored` (`0` skipped, `0.44 s`). - RTX 4060 targeted (**debug**): `cargo test -p xcl --lib -- gpu::dxil::prelude:: --nocapture` -> `10 passed; 0 failed; 0 ignored` (`0` skipped, `0.39 s` — directly verifying the debug `wrapping_mul` fix and F16 direct-DXIL GPU execution). - Full release workspace on RTX 4060: `cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture`: `37` binaries, `1438` passed, `0` failed, `47` ignored (`0` new warnings), `29` pre-existing host-gated `SKIPPED` lines (none in `prelude::`): - `21` wave64-only GPU tests (`no wave64` on RTX 4060 32-lane waves) - `3` per-lane wave32 shader tests (`refused`) - `3` D3D12 debug layer tests (`no d3d12SDKLayers.dll` / debug layer unavailable) - `1` heap-window OOM fallback test (`no heap windows`) - `1` PSO driver-cache measurement test (`cannot disable the driver cache`) **Regression run** Paired 60 s retail smoke (`scripts/smoke.ps1`, RTX 4060): both base (`889ef3e8`, ancestor of `b49be183` and `c9751948`) and HEAD sustained `60 60 60` presents per 2 s with `0` device removals and `0` crashes (`1549` vs `1550` total frames, `14018 MB` vs `13981 MB` peak commit). Base (`origin/main` ancestor): ``` 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 ``` HEAD (`fix-dxil-prelude-alignbit-frexp`): ``` xcl-smoke v1 commit: c9751948934e884624212c4edbf5d774af149bc7 gpu: NVIDIA GeForce RTX 4060 title: 29640639 seconds: 60 exit: 0x0 frames shown: 1549 (PresentX 1549) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14018 MB ``` **Not tested** - Re-running on NVIDIA Ampere (RTX 3060) or AMD RDNA2/RDNA4 hardware directly (only RTX 4060 Ada and WARP are available locally; replacing `fcmp oeq` with integer `e_raw == 0` removes the driver FTZ dependency that caused the Ampere mismatch). - The 29 host/environment-skipped workspace tests listed above (native wave64 GPUs, D3D12 debug layer SDK, heap windows, driver-cache-disabled PSO measurement) and non-Windows hosts. **AI use** Google Antigravity (Gemini 4 Neon) authored the direct-DXIL `frexp_mant`, `frexp_exp`, and `alignbit` simplifications, integer `e_raw == 0` Ampere FTZ fix, direct F16 frexp test, debug `wrapping_mul` fix, and verification runs; verified via DXC 1.9 validation/disassembly, RTX 4060 release & debug tests, full RTX 4060 release workspace tests, and paired 60 s retail smoke runs.
luckyteagirl commented 2026-11-26 04:41:55 +00:00 (Migrated from github.com)

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

Review: COMMENTED


The new gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip fixture encodes only V_FREXP_MANT_F32 and V_FREXP_EXP_I32_F32, but lower_wide.rs also routes V_FREXP_MANT_F16 and V_FREXP_EXP_I16_F16 through the changed Lw::frexp_mant / frexp_exp helpers. The existing gpu_frexp_mant_f32_f16_keep_the_sign fixture uses the legacy HLSL runner, so it does not check the direct F16 lowering. Could this PR add a focused direct F16 translation/validation and wave32 GPU result check (for signed zero, a negative normal, and special values), or state that path as untested? This is a coverage suggestion from source review; I have not run a new F16 direct test.

<!-- greyfinch-sync:ivall/xcl:review:6068643569 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641#pullrequestreview-6068643569). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T04:41:55Z. **Review:** COMMENTED --- The new `gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip` fixture encodes only `V_FREXP_MANT_F32` and `V_FREXP_EXP_I32_F32`, but `lower_wide.rs` also routes `V_FREXP_MANT_F16` and `V_FREXP_EXP_I16_F16` through the changed `Lw::frexp_mant` / `frexp_exp` helpers. The existing `gpu_frexp_mant_f32_f16_keep_the_sign` fixture uses the legacy HLSL runner, so it does not check the direct F16 lowering. Could this PR add a focused direct F16 translation/validation and wave32 GPU result check (for signed zero, a negative normal, and special values), or state that path as untested? This is a coverage suggestion from source review; I have not run a new F16 direct test.
luckyteagirl commented 2026-11-26 05:05:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-26T04:48:33Z.


RX 6800M focused debug run on exact PR head 84ae02e80496d01d01bdf28b1544f4e9890f312e (Windows 11 Home build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC, DXC 1.9.2609.5):

With XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=wave32, XCL_DIRECT_DXIL=1, pinned XCL_DXC_DIR, and --exact --test-threads=1 --show-output:

  • cargo test --locked -p xcl --lib gpu::dxil::prelude::fclass_const_tests::gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip -- --exact --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, 0 SKIPPED (1337 filtered out).
  • cargo test --locked -p xcl --lib gpu::dxil::prelude::fclass_const_tests::gpu_direct_alignbit_is_select_free_and_matches_isa -- --exact --test-threads=1 --show-output: 0 passed, 1 failed, 0 ignored, 0 SKIPPED (1337 filtered out). It panicked at prelude.rs:998:64 with attempt to multiply with overflow while setting up lane inputs. The lane as u32 * 0x1020_3040 expression overflows starting at lane 16 in debug; the test never reached its GPU runner::run calls. wrapping_mul would let the intended wrapping input pattern run in debug.

Both isolated guarded runs completed without a memory-guard stop. The fixture output does not print adapter identity, so this report identifies the requested selector and required-GPU mode, not an independent GPU name from the test. The passing frexp fixture does reach GPU execution; alignbit GPU behavior remains untested here. No full suite or retail-title comparison was run on this head.

AI use: OpenAI Codex (GPT-6; exact serving variant unavailable) with a Luna subagent prepared and ran these tests. I checked the exact head and logs before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7182921156 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7182921156). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-26T04:48:33Z. --- RX 6800M focused debug run on exact PR head `84ae02e80496d01d01bdf28b1544f4e9890f312e` (Windows 11 Home build 26200, Ryzen 9 5980HX, Radeon RX 6800M driver `30.0.13002.13003`, Rust 1.99.0 MSVC, DXC 1.9.2609.5): With `XCL_ADAPTER=6800M`, `XCL_REQUIRE_GPU=wave32`, `XCL_DIRECT_DXIL=1`, pinned `XCL_DXC_DIR`, and `--exact --test-threads=1 --show-output`: - `cargo test --locked -p xcl --lib gpu::dxil::prelude::fclass_const_tests::gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip -- --exact --test-threads=1 --show-output`: **1 passed, 0 failed, 0 ignored, 0 SKIPPED** (1337 filtered out). - `cargo test --locked -p xcl --lib gpu::dxil::prelude::fclass_const_tests::gpu_direct_alignbit_is_select_free_and_matches_isa -- --exact --test-threads=1 --show-output`: **0 passed, 1 failed, 0 ignored, 0 SKIPPED** (1337 filtered out). It panicked at `prelude.rs:998:64` with `attempt to multiply with overflow` while setting up lane inputs. The `lane as u32 * 0x1020_3040` expression overflows starting at lane 16 in debug; the test never reached its GPU `runner::run` calls. `wrapping_mul` would let the intended wrapping input pattern run in debug. Both isolated guarded runs completed without a memory-guard stop. The fixture output does not print adapter identity, so this report identifies the requested selector and required-GPU mode, not an independent GPU name from the test. The passing frexp fixture does reach GPU execution; alignbit GPU behavior remains untested here. No full suite or retail-title comparison was run on this head. AI use: OpenAI Codex (GPT-6; exact serving variant unavailable) with a Luna subagent prepared and ran these tests. I checked the exact head and logs before posting.
Decodere commented 2026-11-26 06:06:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Decodere on 2026-11-26T05:29:04Z.


Thanks @DarkPanda69 and @luckyteagirl for the thorough testing and review! Pushed c9751948 fixing all three findings:

  1. Ampere subnormal mismatch (0x3F00_0001 vs 0): frexp_mant and frexp_exp were using fcmp oeq float x, 0.0, which did not flush subnormals to zero on RTX 3060 (Ampere). Switched both to pure integer e_raw == 0 ((bits(x) & 0x7F80_0000) == 0), removing fcmp oeq completely (now asserted in the disassembly tests) so ±0.0 and F32 FTZ subnormals deterministically return (±0.0, 0) across all GPUs/drivers while F16 subnormals (which widen to normal F32 via f16_to_f32) keep their exact normalized mantissas and exponents.
  2. Debug overflow panic in gpu_direct_alignbit_is_select_free_and_matches_isa: Fixed both lane setup multipliers to use .wrapping_mul(...) and verified cargo test -p xcl --lib -- gpu::dxil::prelude:: in debug builds on RTX 4060 (10/10 passed, 0 skipped).
  3. Direct-DXIL F16 coverage: Added gpu_direct_frexp_f16_avoids_special_float_and_matches_isa covering V_FREXP_MANT_F16 and V_FREXP_EXP_I16_F16 (DXC validate/disassembly + wave32 GPU checks on ±0.0, F16 subnormals, negative normals, ±Inf, and ±qNaN).

If you have a chance to re-check on RTX 3060 / RX 6800M / RX 9070 XT, would really appreciate confirmation!

<!-- greyfinch-sync:ivall/xcl:comment:7183525891 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7183525891). Originally posted by [Decodere](https://github.com/Decodere) on 2026-11-26T05:29:04Z. --- Thanks `@DarkPanda69` and `@luckyteagirl` for the thorough testing and review! Pushed `c9751948` fixing all three findings: 1. **Ampere subnormal mismatch (`0x3F00_0001` vs `0`):** `frexp_mant` and `frexp_exp` were using `fcmp oeq float x, 0.0`, which did not flush subnormals to zero on RTX 3060 (Ampere). Switched both to pure integer `e_raw == 0` (`(bits(x) & 0x7F80_0000) == 0`), removing `fcmp oeq` completely (now asserted in the disassembly tests) so `±0.0` and F32 FTZ subnormals deterministically return `(±0.0, 0)` across all GPUs/drivers while F16 subnormals (which widen to normal F32 via `f16_to_f32`) keep their exact normalized mantissas and exponents. 2. **Debug overflow panic in `gpu_direct_alignbit_is_select_free_and_matches_isa`:** Fixed both lane setup multipliers to use `.wrapping_mul(...)` and verified `cargo test -p xcl --lib -- gpu::dxil::prelude::` in debug builds on RTX 4060 (`10/10` passed, `0` skipped). 3. **Direct-DXIL F16 coverage:** Added `gpu_direct_frexp_f16_avoids_special_float_and_matches_isa` covering `V_FREXP_MANT_F16` and `V_FREXP_EXP_I16_F16` (DXC validate/disassembly + wave32 GPU checks on `±0.0`, F16 subnormals, negative normals, `±Inf`, and `±qNaN`). If you have a chance to re-check on RTX 3060 / RX 6800M / RX 9070 XT, would really appreciate confirmation!
DarkPanda69 commented 2026-11-26 06:06:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-26T05:07:09Z.


Update for head c975194: both findings are fixed on our cards. On main b49be18, same cards:

  • cargo test -p xcl --lib -- gpu::dxil::prelude:: --nocapture: 10 passed, 0 failed, no SKIPPED, in debug and in release, on both the RX 9070 XT and the RTX 3060. That includes gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip on the RTX 3060 (Ampere), the new gpu_direct_frexp_f16_avoids_special_float_and_matches_isa, and gpu_direct_alignbit_is_select_free_and_matches_isa in debug.
  • XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4, paired against main: the only result changes are those 3 tests, all ok, with no new skips. RX 9070 XT 708 → 711 passed, 2 failed (#2115, the same on main). RTX 3060 710 → 713 passed, 0 failed.

The original report follows.

Two failures of the new tests on our cards, one in the test code and one on Ampere:

1. gpu_direct_alignbit_is_select_free_and_matches_isa panics in debug builds, on any GPU. prelude.rs:998, 0x1234_5678u32.wrapping_add(lane as u32 * 0x1020_3040): the multiplication overflows u32 from lane 16 on, and debug builds check overflow. On both cards, in debug:

panicked at crates\xcl\src\gpu\dxil\prelude.rs:998:64:
attempt to multiply with overflow

In release it passes on both. (lane as u32).wrapping_mul(0x1020_3040) would keep the same values. The description's runs are release; the whole-suite runs CONTRIBUTING.md asks for are debug.

2. gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip fails on an RTX 3060 (Ampere), in debug and in release:

panicked at crates\xcl\src\gpu\dxil\prelude.rs:966:13:
assertion `left == right` failed: frexp_mant lane 2 bits=0x00000001
  left: 1056964609
 right: 0

That is 0x3F000001 for the smallest positive denormal where the test expects 0. The same test passes on the RX 9070 XT, and per the description on the RTX 4060. main's existing frexp tests all pass on this RTX 3060, so it looks like the new frexp_mant lowering behaves differently on Ampere. I did not look into why.

Head 84ae02e applied on main b49be18, Windows 11 Pro 26200, card chosen with XCL_ADAPTER; RX 9070 XT (RDNA4, 32.0.32029.2010), RTX 3060 (32.0.16.1088):

  • cargo test --release -p xcl --lib -- gpu::dxil::prelude::: RX 9070 XT 9 passed, 0 failed; RTX 3060 8 passed, 1 failed (frexp).
  • debug, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4 on main and with the PR: no other result changes on either card. RX 9070 XT 708 → 709 passed, 2 → 3 failed (alignbit, plus the #2115 fuzz seeds, the same on main). RTX 3060 710 → 710 passed, 0 → 2 failed (alignbit, frexp). The two new-test failures are the same with XCL_DIRECT_DXIL unset.

Not tested: Turing / Ada beyond your RTX 4060, Intel, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine, found the overflow line and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7183196563 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7183196563). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-26T05:07:09Z. --- **Update for head `c975194`: both findings are fixed on our cards.** On `main` `b49be18`, same cards: - `cargo test -p xcl --lib -- gpu::dxil::prelude:: --nocapture`: 10 passed, 0 failed, no SKIPPED, in debug and in release, on both the RX 9070 XT and the RTX 3060. That includes `gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip` on the RTX 3060 (Ampere), the new `gpu_direct_frexp_f16_avoids_special_float_and_matches_isa`, and `gpu_direct_alignbit_is_select_free_and_matches_isa` in debug. - `XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4`, paired against `main`: the only result changes are those 3 tests, all ok, with no new skips. RX 9070 XT 708 → 711 passed, 2 failed (#2115, the same on `main`). RTX 3060 710 → 713 passed, 0 failed. The original report follows. Two failures of the new tests on our cards, one in the test code and one on Ampere: **1. `gpu_direct_alignbit_is_select_free_and_matches_isa` panics in debug builds, on any GPU.** `prelude.rs:998`, `0x1234_5678u32.wrapping_add(lane as u32 * 0x1020_3040)`: the multiplication overflows `u32` from lane 16 on, and debug builds check overflow. On both cards, in debug: ``` panicked at crates\xcl\src\gpu\dxil\prelude.rs:998:64: attempt to multiply with overflow ``` In release it passes on both. `(lane as u32).wrapping_mul(0x1020_3040)` would keep the same values. The description's runs are release; the whole-suite runs CONTRIBUTING.md asks for are debug. **2. `gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip` fails on an RTX 3060 (Ampere), in debug and in release:** ``` panicked at crates\xcl\src\gpu\dxil\prelude.rs:966:13: assertion `left == right` failed: frexp_mant lane 2 bits=0x00000001 left: 1056964609 right: 0 ``` That is `0x3F000001` for the smallest positive denormal where the test expects `0`. The same test passes on the RX 9070 XT, and per the description on the RTX 4060. `main`'s existing frexp tests all pass on this RTX 3060, so it looks like the new `frexp_mant` lowering behaves differently on Ampere. I did not look into why. Head `84ae02e` applied on `main` `b49be18`, Windows 11 Pro 26200, card chosen with `XCL_ADAPTER`; RX 9070 XT (RDNA4, 32.0.32029.2010), RTX 3060 (32.0.16.1088): - `cargo test --release -p xcl --lib -- gpu::dxil::prelude::`: RX 9070 XT 9 passed, 0 failed; RTX 3060 8 passed, 1 failed (frexp). - debug, `XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4` on `main` and with the PR: no other result changes on either card. RX 9070 XT 708 → 709 passed, 2 → 3 failed (alignbit, plus the #2115 fuzz seeds, the same on `main`). RTX 3060 710 → 710 passed, 0 → 2 failed (alignbit, frexp). The two new-test failures are the same with `XCL_DIRECT_DXIL` unset. Not tested: Turing / Ada beyond your RTX 4060, Intel, a title. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine, found the overflow line and wrote this report.
zhouzhidong3-hash commented 2026-11-26 07:03:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by zhouzhidong3-hash on 2026-11-26T06:24:19Z.


RTX 5070 (Blackwell) focused confirmation on exact head c9751948934e884624212c4edbf5d774af149bc7, from the official GitHub commit archive, with no source edits.

Tested

Windows 10 Pro 19045, i7-12700KF, NVIDIA GeForce RTX 5070 / driver 591.86, Rust 1.100.0 MSVC debug test build. Explicit XCL_ADAPTER=5070, XCL_DIRECT_DXIL=all; local D3D12 Agility SDK and DXC/DXIL 1.8.2502.11.

cargo test --locked -p xcl --lib gpu::dxil::prelude:: -- --test-threads=1 --nocapture
10 passed, 0 failed, 0 ignored; 1329 filtered out; no SKIPPED messages (6.57 s)

cargo test --locked -p xcl --lib gpu_frexp -- --test-threads=1 --nocapture
8 passed, 0 failed, 0 ignored; 1331 filtered out; no SKIPPED messages (0.42 s)

The first group includes successful DXC validation/disassembly and wave32 GPU assertions for all three new fixtures: gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip, gpu_direct_frexp_f16_avoids_special_float_and_matches_isa, and gpu_direct_alignbit_is_select_free_and_matches_isa. The prelude group also contains CPU/translation-only tests; 10 passes should not be read as 10 GPU dispatch tests. The frexp group includes the existing sign and directed-rounding/denormal-mode checks. These results confirm the fixtures' expected outputs on this Blackwell configuration, not an independent native-RDNA ISA reference.

The changed prelude.rs Git blob matches the GitHub files API (33369da2d25577ec0b685e3933bdb30be081a3e4). All 210 Rust source files retained their original SHA256 hashes. Archive SHA256: 4d54b6406e75188bb83b5f5ec84e3e522c5192a40109bd841e88d5921b7a3a8a.

Not tested

Parent control, full workspace, release-host build, native wave64, other adapters/drivers, retail/gameplay or performance. No FPS claim or approval of unrelated behavior.

AI use

OpenAI Codex (GPT-6; exact serving variant unavailable) fetched and checked the archive/API blob, ran the existing focused fixtures, inspected output/skip markers and source integrity, and prepared this test report. No implementation changes.

<!-- greyfinch-sync:ivall/xcl:comment:7184396491 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7184396491). Originally posted by [zhouzhidong3-hash](https://github.com/zhouzhidong3-hash) on 2026-11-26T06:24:19Z. --- RTX 5070 (Blackwell) focused confirmation on exact head `c9751948934e884624212c4edbf5d774af149bc7`, from the official GitHub commit archive, with no source edits. **Tested** Windows 10 Pro 19045, i7-12700KF, NVIDIA GeForce RTX 5070 / driver 591.86, Rust 1.100.0 MSVC debug test build. Explicit `XCL_ADAPTER=5070`, `XCL_DIRECT_DXIL=all`; local D3D12 Agility SDK and DXC/DXIL 1.8.2502.11. ```text cargo test --locked -p xcl --lib gpu::dxil::prelude:: -- --test-threads=1 --nocapture 10 passed, 0 failed, 0 ignored; 1329 filtered out; no SKIPPED messages (6.57 s) cargo test --locked -p xcl --lib gpu_frexp -- --test-threads=1 --nocapture 8 passed, 0 failed, 0 ignored; 1331 filtered out; no SKIPPED messages (0.42 s) ``` The first group includes successful DXC validation/disassembly and wave32 GPU assertions for all three new fixtures: `gpu_direct_frexp_avoids_special_float_and_int_float_roundtrip`, `gpu_direct_frexp_f16_avoids_special_float_and_matches_isa`, and `gpu_direct_alignbit_is_select_free_and_matches_isa`. The prelude group also contains CPU/translation-only tests; 10 passes should not be read as 10 GPU dispatch tests. The frexp group includes the existing sign and directed-rounding/denormal-mode checks. These results confirm the fixtures' expected outputs on this Blackwell configuration, not an independent native-RDNA ISA reference. The changed `prelude.rs` Git blob matches the GitHub files API (`33369da2d25577ec0b685e3933bdb30be081a3e4`). All 210 Rust source files retained their original SHA256 hashes. Archive SHA256: `4d54b6406e75188bb83b5f5ec84e3e522c5192a40109bd841e88d5921b7a3a8a`. **Not tested** Parent control, full workspace, release-host build, native wave64, other adapters/drivers, retail/gameplay or performance. No FPS claim or approval of unrelated behavior. **AI use** OpenAI Codex (GPT-6; exact serving variant unavailable) fetched and checked the archive/API blob, ran the existing focused fixtures, inspected output/skip markers and source integrity, and prepared this test report. No implementation changes.
DarkPanda69 commented 2026-11-26 09:07:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-26T08:16:12Z.


@Decodere re-checked c975194 on the RTX 3060 (Ampere) and the RX 9070 XT, as you asked: all three are fixed. gpu::dxil::prelude:: gives 10 passed, 0 failed, no SKIPPED on both cards, in debug and in release. That includes the frexp subnormal case on the RTX 3060, the alignbit test in debug, and the new f16 test. The paired direct-DXIL gpu:: run shows no other changes. Details are in the update at the top of my comment above.

AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7186391112 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7186391112). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-26T08:16:12Z. --- @Decodere re-checked `c975194` on the RTX 3060 (Ampere) and the RX 9070 XT, as you asked: all three are fixed. `gpu::dxil::prelude::` gives 10 passed, 0 failed, no SKIPPED on both cards, in debug and in release. That includes the frexp subnormal case on the RTX 3060, the alignbit test in debug, and the new f16 test. The paired direct-DXIL `gpu::` run shows no other changes. Details are in the update at the top of my comment above. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this comment.
throny commented 2026-11-28 07:07:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T07:07:21Z.


merge-check claim
head: c975194893

<!-- greyfinch-sync:ivall/xcl:comment:7235730004 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7235730004). Originally posted by [throny](https://github.com/throny) on 2026-11-28T07:07:21Z. --- merge-check claim head: c9751948934e884624212c4edbf5d774af149bc7
throny commented 2026-11-28 07:18:14 +00:00 (Migrated from github.com)

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


merge-check
base: e429936c
head: c975194893
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2126 passed, 9 failed, 48 ignored: exactly the base's result, because the merge changes nothing (26 SKIPPED lines). The 9 failures are main's own at e429936c on this GPU (reported on #3041: they arrive with the merge of #2959); base alone: 2126 passed, 9 failed, 48 ignored.
review: the whole change is already on main: commit bacee763 (an ancestor of e429936c) contains it, with the three tests, and this PR's diff reverses cleanly on main's prelude.rs. For the record, the numerics read right: signed zero gives (signed zero, 0); a float denormal is treated as zero; infinity and NaN pass through the mantissa with exponent 0; half denormals widen to normal floats and come out normalised.
performance: nothing to add on main.
verdict: not yet: nothing to merge; already in main through bacee763, so this PR can be closed.
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:7235847352 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7235847352). Originally posted by [throny](https://github.com/throny) on 2026-11-28T07:18:14Z. --- merge-check base: e429936c head: c9751948934e884624212c4edbf5d774af149bc7 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2126 passed, 9 failed, 48 ignored: exactly the base's result, because the merge changes nothing (26 SKIPPED lines). The 9 failures are main's own at e429936c on this GPU (reported on #3041: they arrive with the merge of #2959); base alone: 2126 passed, 9 failed, 48 ignored. review: the whole change is already on main: commit bacee763 (an ancestor of e429936c) contains it, with the three tests, and this PR's diff reverses cleanly on main's prelude.rs. For the record, the numerics read right: signed zero gives (signed zero, 0); a float denormal is treated as zero; infinity and NaN pass through the mantissa with exponent 0; half denormals widen to normal floats and come out normalised. performance: nothing to add on main. verdict: not yet: nothing to merge; already in main through bacee763, so this PR can be closed. 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).
saintwolf commented 2026-11-30 01:22:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T01:22:58Z.


merge-check
base: 53e85fb124
head: c975194893
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2792 passed, 1 failed, 49 ignored; SKIPPED: 30 (22 no wave64, 3 per-lane #1426 refused, 2 no heap windows, 2 no xgameruntime.dll, 1 cannot disable the driver cache 0x887A002D); failing: hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline (also fails on base 53e85fb1 alone)
review: the full change (+173/-42 in crates/xcl/src/gpu/dxil/prelude.rs) is already on main in commit bacee763 (merged via #2959), so merging #2641 onto 53e85fb1 produces an empty diff. Diff logic and the three new tests (F32 frexp, F16 frexp, select-free alignbit) read clean. Native wave64 GPU paths and retail smoke were not run.
performance: nothing added on main (already landed).
verdict: not yet: already landed on main in bacee763 (via #2959), so this PR can be closed
hardware / tool and model: NVIDIA GeForce RTX 4070 SUPER (32.0.16.2140), AMD Ryzen 7 7800X3D, Windows 11 Pro 26300, rustc 1.100.0, debug / Antigravity (Gemini 4 Hydrogen)

<!-- greyfinch-sync:ivall/xcl:comment:7266089079 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7266089079). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-11-30T01:22:58Z. --- merge-check base: 53e85fb124eae624641e9884517e4f3c4a7d8794 head: c9751948934e884624212c4edbf5d774af149bc7 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2792 passed, 1 failed, 49 ignored; SKIPPED: 30 (22 no wave64, 3 per-lane #1426 refused, 2 no heap windows, 2 no xgameruntime.dll, 1 cannot disable the driver cache 0x887A002D); failing: hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline (also fails on base 53e85fb1 alone) review: the full change (+173/-42 in crates/xcl/src/gpu/dxil/prelude.rs) is already on main in commit bacee763 (merged via #2959), so merging #2641 onto 53e85fb1 produces an empty diff. Diff logic and the three new tests (F32 frexp, F16 frexp, select-free alignbit) read clean. Native wave64 GPU paths and retail smoke were not run. performance: nothing added on main (already landed). verdict: not yet: already landed on main in bacee763 (via #2959), so this PR can be closed hardware / tool and model: NVIDIA GeForce RTX 4070 SUPER (32.0.16.2140), AMD Ryzen 7 7800X3D, Windows 11 Pro 26300, rustc 1.100.0, debug / Antigravity (Gemini 4 Hydrogen)
Foniass commented 2026-12-01 08:32:14 +00:00 (Migrated from github.com)

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


Triage (#1607) – head c975194

The same change is already on main: commit bacee763 ("Recompiler: simplify direct DXIL frexp and alignbit helpers", which says it was adapted from this PR) has a diff of gpu/dxil/prelude.rs identical to this PR's commit c975194 (frexp_mant / frexp_exp from exponent bits, alignbit constant fast path).
Nothing in this PR is left to merge.
Recommendation: close (superseded by main commit bacee763).

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:7305448468 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7305448468). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:32:14Z. --- **Triage (#1607)** – head c975194 The same change is already on main: commit bacee763 ("Recompiler: simplify direct DXIL frexp and alignbit helpers", which says it was adapted from this PR) has a diff of `gpu/dxil/prelude.rs` identical to this PR's commit c975194 (frexp_mant / frexp_exp from exponent bits, alignbit constant fast path). Nothing in this PR is left to merge. Recommendation: close (superseded by main commit bacee763). 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:56:22 +00:00 (Migrated from github.com)

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


Closing as superseded: this change is already on main (bacee763). PR's prelude.rs diff compared with bacee763's prelude.rs diff: identical changed-line sets (215 lines each, diff of sorted +/- lines empty)

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:7311868089 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7311868089). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:56:22Z. --- Closing as superseded: this change is already on `main` (bacee763). PR's prelude.rs diff compared with bacee763's prelude.rs diff: identical changed-line sets (215 lines each, diff of sorted +/- lines empty) 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!2631
No description provided.