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

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

@⁠Decodere on GitHub · 2026-11-26 04:35 UTC · original
Decodere:fix-dxil-prelude-alignbit-frexp → main · +173 −42 · 1 files · 1 commits · open

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.

**@⁠Decodere** on GitHub · 2026-11-26 04:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/2641) `Decodere:fix-dxil-prelude-alignbit-frexp` → `main` · +173 −42 · 1 files · 1 commits · open **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.
Remove private frexp_dxc and lower frexp_mant / frexp_exp directly from
bit-extracted exponent bits (`e_raw = i & 0x7F80_0000`), checking
`e_raw == 0` for zero / FTZ subnormals and `e_raw == 0x7F80_0000` for
Inf / NaN instead of emitting `@dx.op.isSpecialFloat`, `sitofp`/`fptosi`,
or driver-FTZ-dependent `fcmp oeq float x, 0.0` (which did not flush
subnormal inputs on NVIDIA Ampere).

Simplify alignbit with a constant-shift fast path (returning `s1` for
`sh == 0` and 3 bit ops otherwise) and a select-free dynamic shift
`((s0 << 1) << (sh ^ 31)) | (s1 >> sh)` keeping all shift counts in
`0..=31`.

Add direct-DXIL validation/disassembly and wave32 GPU tests for F32
frexp, F16 frexp (`V_FREXP_MANT_F16` / `V_FREXP_EXP_I16_F16`), and
`V_ALIGNBIT_B32` / `V_ALIGNBYTE_B32` (using `wrapping_mul` for debug
build safety).

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

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

@⁠luckyteagirl on GitHub · 2026-11-26 04:48 UTC · original

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.

**@⁠luckyteagirl** on GitHub · 2026-11-26 04:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7182921156) 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.
Author
Owner

@⁠Decodere on GitHub · 2026-11-26 05:29 UTC · original

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!

**@⁠Decodere** on GitHub · 2026-11-26 05:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7183525891) 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!
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-26 05:07 UTC · original · edited 2026-11-26 05:54 UTC

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.

**@⁠DarkPanda69** on GitHub · 2026-11-26 05:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7183196563) · edited 2026-11-26 05:54 UTC **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.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-26 04:41 UTC · original · reviewed

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** on GitHub · 2026-11-26 04:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/2641#pullrequestreview-6068643569) · **reviewed** 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.
Author
Owner

@⁠zhouzhidong3-hash on GitHub · 2026-11-26 06:24 UTC · original

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.

**@⁠zhouzhidong3-hash** on GitHub · 2026-11-26 06:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7184396491) 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.
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-26 08:16 UTC · original

@⁠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.

**@⁠DarkPanda69** on GitHub · 2026-11-26 08:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/2641#issuecomment-7186391112) @⁠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.
This pull request can be merged automatically.
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/2641/head:github-bot/gh-2641'
git switch 'github-bot/gh-2641'

Merge

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