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

Closed
GamingChelsea wants to merge 1 commit from upstream-pr/1340 into main
GamingChelsea commented 2026-11-24 14:59:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by GamingChelsea on 2026-11-24T14:59:27Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:6584711458 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1340). Originally posted by [GamingChelsea](https://github.com/GamingChelsea) on 2026-11-24T14:59:27Z. --- 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.
futurepro62 commented 2026-11-24 15:06:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:03:28Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7135387347 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1340#issuecomment-7135387347). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T15:03:28Z. --- 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.
DavidM1911 commented 2026-11-24 15:06:14 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T15:05:48Z.


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

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

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7135451252 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1340#issuecomment-7135451252). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T15:05:48Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: 708 passed, 0 failed, 21 ignored. Thanks!
DarkPanda69 commented 2026-11-24 16:06:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-24T15:16:14Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7135742643 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1340#issuecomment-7135742643). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-24T15:16:14Z. --- 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.
upstream-sync closed this pull request 2026-11-24 21:05:39 +00:00
throny commented 2026-11-24 21:09:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-24T20:29:51Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7143635947 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1340#issuecomment-7143635947). Originally posted by [throny](https://github.com/throny) on 2026-11-24T20:29:51Z. --- <!-- 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.
ivall commented 2026-11-24 21:09:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-24T20:42:55Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7143958413 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1340#issuecomment-7143958413). Originally posted by [ivall](https://github.com/ivall) on 2026-11-24T20:42:55Z. --- 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

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