Recompiler: apply bitwise sign ops in v_cmp_class_f32 (#1281) #1559

Closed
hajduzsolt wants to merge 1 commit from upstream-pr/1569 into main
hajduzsolt commented 2026-11-24 17:45:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T17:45:56Z.


Applies bitwise sign-bit ^Gbs/
eg modifiers and raw-bit fclass(uint) classification for v_cmp_class_f32, avoiding float32 FTZ flushing of denormals and sNaN quieting. Fixes #1281.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: handle op == class for f32 in vopc with bitwise & 0x7FFFFFFFu (^Gbs) and ^ 0x80000000u (
  • eg) before fclass(...), and update fclass(uint u) to inspect raw IEEE-754 bits directly without an ^Gsfloat/^Gsuint round-trip.
  • crates/xcl/src/gpu/recomp/tests.rs: add cmp_class_f32_uses_bitwise_modifiers_without_float_roundtrip and gpu_cmp_class_f32_preserves_denormals_and_snan verifying Wave32/Wave64 execution on negative/positive subnormals and sNaN with ABS and NEG modifiers.

Tested

  • Hardware & toolchain: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), AMD Ryzen 7 9800X3D, Windows 11 10.0.26300.9974, rustc 1.98.1 (48a229cea 2026-09-01), debug (cargo test).
  • cargo test -p xcl --lib gpu::recomp::tests::cmp_class_f32 -- --test-threads=2: 1 passed, 0 failed, 0 ignored.
  • cargo test -p xcl --lib gpu::recomp::tests::gpu_cmp_class_f32 -- --test-threads=2: 1 passed, 0 failed, 0 ignored.
  • cargo test --workspace -- --test-threads=2: 778 passed, 0 failed, 41 ignored (xcl --lib: 729 passed, 0 failed, 21 ignored; integration/e2e suites: 49 passed, 0 failed, 20 ignored).
  • SKIPPED runtime tests: SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows.

Regression run

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1594 (PresentX 1594)
presents per 2 s (last 3): 49 48 14
device removals: 0
crashes: 0
peak commit: 20195 MB

PR:

xcl-smoke v1
commit: 59ddd2c1feadea681e12ecf3178f83136a0629f3
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14843 MB

Not tested

  • NVIDIA, Intel Arc, and WARP adapters.

AI use

  • Antigravity (Gemini 4 Hydrogen, high): updated vopc class/f32 and fclass(uint u) in emit.rs, wrote translation and Wave32/Wave64 GPU tests, ran the workspace test suite, and drafted commit and PR description.
<!-- greyfinch-sync:ivall/xcl:issue:6587918972 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1569). Originally posted by [hajduzsolt](https://github.com/hajduzsolt) on 2026-11-24T17:45:56Z. --- Applies bitwise sign-bit ^Gbs/ eg modifiers and raw-bit fclass(uint) classification for v_cmp_class_f32, avoiding float32 FTZ flushing of denormals and sNaN quieting. Fixes #1281. **What is in it** - crates/xcl/src/gpu/recomp/emit.rs: handle op == class for f32 in vopc with bitwise & 0x7FFFFFFFu (^Gbs) and ^ 0x80000000u ( - eg) before fclass(...), and update fclass(uint u) to inspect raw IEEE-754 bits directly without an ^Gsfloat/^Gsuint round-trip. - crates/xcl/src/gpu/recomp/tests.rs: add cmp_class_f32_uses_bitwise_modifiers_without_float_roundtrip and gpu_cmp_class_f32_preserves_denormals_and_snan verifying Wave32/Wave64 execution on negative/positive subnormals and sNaN with ABS and NEG modifiers. **Tested** - Hardware & toolchain: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), AMD Ryzen 7 9800X3D, Windows 11 10.0.26300.9974, rustc 1.98.1 (48a229cea 2026-09-01), debug (cargo test). - cargo test -p xcl --lib gpu::recomp::tests::cmp_class_f32 -- --test-threads=2: 1 passed, 0 failed, 0 ignored. - cargo test -p xcl --lib gpu::recomp::tests::gpu_cmp_class_f32 -- --test-threads=2: 1 passed, 0 failed, 0 ignored. - cargo test --workspace -- --test-threads=2: 778 passed, 0 failed, 41 ignored (xcl --lib: 729 passed, 0 failed, 21 ignored; integration/e2e suites: 49 passed, 0 failed, 20 ignored). - SKIPPED runtime tests: SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows. **Regression run** main: ``` xcl-smoke v1 commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1594 (PresentX 1594) presents per 2 s (last 3): 49 48 14 device removals: 0 crashes: 0 peak commit: 20195 MB ``` PR: ``` xcl-smoke v1 commit: 59ddd2c1feadea681e12ecf3178f83136a0629f3 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1674 (PresentX 1674) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14843 MB ``` **Not tested** - NVIDIA, Intel Arc, and WARP adapters. **AI use** - Antigravity (Gemini 4 Hydrogen, high): updated vopc class/f32 and fclass(uint u) in emit.rs, wrote translation and Wave32/Wave64 GPU tests, ran the workspace test suite, and drafted commit and PR description.
upstream-sync closed this pull request 2026-11-24 21:06:43 +00:00
DavidM1911 commented 2026-11-24 21:09:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T19:41:28Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7142453204 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1569#issuecomment-7142453204). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T19:41:28Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. Thanks!
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:52Z.


Two contributors checked independently and found that this PR makes the same change as #1306 #1309 #1340 (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:7143636447 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1569#issuecomment-7143636447). Originally posted by [throny](https://github.com/throny) on 2026-11-24T20:29:52Z. --- <!-- xcl-1607-hint:D1 --> Two contributors checked independently and found that this PR makes the same change as #1306 #1309 #1340 (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:59Z.


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:7143959970 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1569#issuecomment-7143959970). Originally posted by [ivall](https://github.com/ivall) on 2026-11-24T20:42:59Z. --- 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!1559
No description provided.