Recompiler: apply v_cmp_class_f32 abs/neg bitwise on raw uint bits (#1281) #1340

Closed
github-bot wants to merge 1 commit from gh-pr/1340/head into gh-pr/1340/base
Owner

@⁠GamingChelsea on GitHub · 2026-11-24 14:59 UTC · original
GamingChelsea:fix/v-cmp-class-f32-bitwise-mods → main · +54 −6 · 2 files · 1 commits · closed without merging

Fixes #1281.

v_cmp_class_f32 previously applied VOP3 abs/neg modifiers through Self::fsrc (float abs(asfloat(u)) / -asfloat(u)) and passed a float into fclass(float). Under D3D12 FTZ, float abs/neg flushes f32 subnormals to ±0 and can quiet signaling NaNs, misclassifying subnormal and sNaN class bits.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: change fclass(float) to fclass(uint) (matching fclass16(uint)) and handle "f32" with op == "class" in vopc() directly on raw uint bits with bitwise abs (& 0x7FFFFFFFu) and neg (^ 0x80000000u).
  • crates/xcl/src/gpu/recomp/tests.rs: add gpu_cmp_class_f32_bitwise_modifiers_preserve_denorm_and_snan verifying VOP3 abs, neg, and -abs on f32 subnormals (0x80000001, 0x00000001) and sNaN (0x7F800001).

Tested

  • Hardware: NVIDIA GeForce RTX 4070 (driver 32.0.16.2124, Wave32), Intel Core i7-14700K, Windows 11 (10.0.26300.0), rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2602.17, debug (tests) and release (smoke).
  • cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored.
  • SKIPPED GPU tests on this adapter (Wave32-only):
    • gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
    • gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
  • cargo test -p xcl --lib cmp_class -- --test-threads=1 --nocapture: 2 passed, 0 failed, 0 skipped.

Regression run
main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 4070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1363 (PresentX 1363)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15782 MB

PR head:

xcl-smoke v1
commit: 3f96fef2410ee7b4233b5f6dddb247963d78062f
gpu: NVIDIA GeForce RTX 4070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1241 (PresentX 1241)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15554 MB

Not tested

  • AMD / Wave64 hardware (the two wave64-hardware GPU tests were skipped on the RTX 4070).
  • Ignored retail shader corpus tests (XCL_SAMPLE_RPF).

AI use

  • Antigravity with Gemini 4 Neon: implemented the fclass(uint) and bitwise abs/neg fix, wrote gpu_cmp_class_f32_bitwise_modifiers_preserve_denorm_and_snan, ran the workspace test suite and smoke regression runs, and drafted this PR description.
**@⁠GamingChelsea** on GitHub · 2026-11-24 14:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1340) `GamingChelsea:fix/v-cmp-class-f32-bitwise-mods` → `main` · +54 −6 · 2 files · 1 commits · closed without merging Fixes #1281. `v_cmp_class_f32` previously applied VOP3 `abs`/`neg` modifiers through `Self::fsrc` (float `abs(asfloat(u))` / `-asfloat(u)`) and passed a `float` into `fclass(float)`. Under D3D12 FTZ, float `abs`/`neg` flushes f32 subnormals to ±0 and can quiet signaling NaNs, misclassifying subnormal and sNaN class bits. **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs`: change `fclass(float)` to `fclass(uint)` (matching `fclass16(uint)`) and handle `"f32"` with `op == "class"` in `vopc()` directly on raw `uint` bits with bitwise `abs` (`& 0x7FFFFFFFu`) and `neg` (`^ 0x80000000u`). - `crates/xcl/src/gpu/recomp/tests.rs`: add `gpu_cmp_class_f32_bitwise_modifiers_preserve_denorm_and_snan` verifying VOP3 `abs`, `neg`, and `-abs` on f32 subnormals (`0x80000001`, `0x00000001`) and sNaN (`0x7F800001`). **Tested** - Hardware: NVIDIA GeForce RTX 4070 (driver 32.0.16.2124, Wave32), Intel Core i7-14700K, Windows 11 (10.0.26300.0), `rustc 1.100.0 (0ef1bc386 2026-11-09)`, DXC 1.9.2602.17, debug (tests) and release (smoke). - `cargo test --workspace -- --test-threads=4`: 752 passed, 0 failed, 41 ignored. - `SKIPPED` GPU tests on this adapter (Wave32-only): - `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64` - `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64` - `cargo test -p xcl --lib cmp_class -- --test-threads=1 --nocapture`: 2 passed, 0 failed, 0 skipped. **Regression run** main: ``` xcl-smoke v1 commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56 gpu: NVIDIA GeForce RTX 4070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1363 (PresentX 1363) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15782 MB ``` PR head: ``` xcl-smoke v1 commit: 3f96fef2410ee7b4233b5f6dddb247963d78062f gpu: NVIDIA GeForce RTX 4070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1241 (PresentX 1241) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 15554 MB ``` **Not tested** - AMD / Wave64 hardware (the two wave64-hardware GPU tests were skipped on the RTX 4070). - Ignored retail shader corpus tests (`XCL_SAMPLE_RPF`). **AI use** - Antigravity with Gemini 4 Neon: implemented the `fclass(uint)` and bitwise `abs`/`neg` fix, wrote `gpu_cmp_class_f32_bitwise_modifiers_preserve_denorm_and_snan`, ran the workspace test suite and smoke regression runs, and drafted this PR description.
v_cmp_class_f32 previously routed SRC0 through Self::fsrc (float abs/neg)
into fclass(float), which under D3D12 FTZ flushes f32 subnormals to +-0
and can quiet signaling NaNs.

Pass raw uint bits directly to fclass(uint) and apply VOP3 abs/neg bitwise
on bit 31 (matching fclass16 and RDNA2 hardware). Add GPU test
gpu_cmp_class_f32_bitwise_modifiers_preserve_denorm_and_snan verifying
abs, neg, and -abs on f32 subnormals and sNaN.

Fixes #1281

Assisted-by: Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:51:15 +00:00
github-bot closed this pull request 2026-11-26 04:51:15 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 15:05 UTC · original

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

  • cargo test -p xcl --lib: 708 passed, 0 failed, 21 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 15:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1340#issuecomment-7135451252) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: 708 passed, 0 failed, 21 ignored. Thanks!
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-24 15:03 UTC · original · edited 2026-11-24 15:06 UTC

Full-suite run, since this PR has no test report yet. Tested exact head 3f96fef (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: gpu_cmp_class_f32_bitwise_modifiers_preserve_denorm_and_snan.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored, no skips.
  • This is the fourth PR for #1281: #1308 and #1309 (both open, both pass the full suite here) and #1318 (two stale test expectations, see its thread) apply the same sign-bit abs / neg to v_cmp_class_f32.

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-24 15:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/1340#issuecomment-7135387347) · edited 2026-11-24 15:06 UTC Full-suite run, since this PR has no test report yet. Tested exact head `3f96fef` (on its base `930e8b4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `gpu_cmp_class_f32_bitwise_modifiers_preserve_denorm_and_snan`. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **752 passed, 0 failed, 41 ignored**, no skips. - This is the fourth PR for #1281: #1308 and #1309 (both open, both pass the full suite here) and #1318 (two stale test expectations, see its thread) apply the same sign-bit abs / neg to `v_cmp_class_f32`. **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

@⁠DarkPanda69 on GitHub · 2026-11-24 15:16 UTC · original

AMD run with 64-lane waves, which this PR lists as not tested (the other reports here are NVIDIA).

Tested: pass, head 3f96fef applied on its base main 930e8b4, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.
cargo test -p xcl --lib -- gpu::recomp --test-threads=4:

  • AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 190 passed, 0 failed, 18 ignored, 0 SKIPPED. gpu_cmp_class_f32_bitwise_modifiers_preserve_denorm_and_snan ok, and the wave64 tests the RTX 4070 skipped run here.
  • NVIDIA RTX 3060, driver 32.0.16.1088: 190 passed, 0 failed, 18 ignored, 2 SKIPPED (no wave64).

Not tested: the whole workspace suite; XCL_SAMPLE_RPF; a title.

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

**@⁠DarkPanda69** on GitHub · 2026-11-24 15:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/1340#issuecomment-7135742643) AMD run with 64-lane waves, which this PR lists as not tested (the other reports here are NVIDIA). **Tested:** pass, head `3f96fef` applied on its base `main` `930e8b4`, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17. `cargo test -p xcl --lib -- gpu::recomp --test-threads=4`: - AMD RX 9070 XT (RDNA4), driver 32.0.32029.2010, native wave64: 190 passed, 0 failed, 18 ignored, 0 SKIPPED. `gpu_cmp_class_f32_bitwise_modifiers_preserve_denorm_and_snan` ok, and the wave64 tests the RTX 4070 skipped run here. - NVIDIA RTX 3060, driver 32.0.16.1088: 190 passed, 0 failed, 18 ignored, 2 SKIPPED (no wave64). **Not tested:** the whole workspace suite; `XCL_SAMPLE_RPF`; a title. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠throny on GitHub · 2026-11-24 20:29 UTC · original

Two contributors checked independently and found that this PR makes the same change as #1306 #1309 #1569 (for #1281): #1607, group D1. They suggest keeping #1306. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps.

This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

**@⁠throny** on GitHub · 2026-11-24 20:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/1340#issuecomment-7143635947) <!-- xcl-1607-hint:D1 --> Two contributors checked independently and found that this PR makes the same change as #1306 #1309 #1569 (for #1281): #1607, group D1. They suggest keeping #1306. If you agree, closing this PR or joining the other one would save the maintainers a review. If the two differ in a way the checks missed, a note in #1607 helps. This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Author
Owner

@⁠ivall on GitHub · 2026-11-24 20:42 UTC · original

Closing this as a duplicate: #1306 makes the same change and was opened first (v_cmp_class_f32 applies abs / neg to the sign bit and fclass takes the bits). It stays open and is the one that will be reviewed and merged.

This says nothing about the quality of the code here. I compared the two diffs; the pair was also found by independent checks in #1607. If this PR covers a case #1306 does not, or #1306 is closed without being merged, say so and I'll reopen it. A test that is only here is welcome on #1306.

Thank you for the work.

AI use: Claude Code (Claude Opus 5.5) compared the diffs and wrote this comment; the decision is the maintainer's.

**@⁠ivall** on GitHub · 2026-11-24 20:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/1340#issuecomment-7143958413) Closing this as a duplicate: #1306 makes the same change and was opened first (v_cmp_class_f32 applies abs / neg to the sign bit and fclass takes the bits). It stays open and is the one that will be reviewed and merged. This says nothing about the quality of the code here. I compared the two diffs; the pair was also found by independent checks in #1607. If this PR covers a case #1306 does not, or #1306 is closed without being merged, say so and I'll reopen it. A test that is only here is welcome on #1306. Thank you for the work. AI use: Claude Code (Claude Opus 5.5) compared the diffs and wrote this comment; the decision is the maintainer's.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.