Recompiler: ignore VOP3 op_sel on 16-bit VOPC compares (#1293) #1572

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

@⁠hajduzsolt on GitHub · 2026-11-24 17:49 UTC · original
hajduzsolt:recompiler/vopc-16bit-ignore-opsel → main · +67 −7 · 2 files · 1 commits · closed without merging

Updates 16-bit non-class VOPC compares (f16/u16/i16) to always read both sources from the low 16 bits ([15:0]), ignoring VOP3 op_sel bits to match RDNA2 hardware behavior. Fixes #1293.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs: introduce lo16 in vopc and use it for f16 (excluding class), u16, and i16 operands instead of selecting high halves via m.opsel.
  • crates/xcl/src/gpu/recomp/tests.rs: add vopc_16bit_ignores_vop3_opsel_and_reads_low_halves and gpu_vopc_16bit_ignores_vop3_opsel testing V_CMP_LT_F16, V_CMP_LT_U16, V_CMP_GT_I16, and V_CMPX_EQ_U16 against V_ADD_NC_U16 (control) across Wave32 and Wave64.

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::vopc_16bit -- --test-threads=2: 1 passed, 0 failed, 0 ignored.
  • cargo test -p xcl --lib gpu::recomp::tests::gpu_vopc_16bit -- --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: ad6921e1bcc05ff3c486c382c1b13d704ca51eb4
gpu: AMD Radeon RX 9070 XT
title: A newer retail game
seconds: 60
exit: 0x0
frames shown: 1647 (PresentX 1647)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14834 MB

Not tested

  • NVIDIA and Intel Arc GPUs, and v_cmp_class_f16 with op_sel.

AI use

  • Antigravity (Gemini 4 Hydrogen, high): updated vopc in emit.rs to ignore op_sel on 16-bit non-class compares, wrote translation and Wave32/Wave64 GPU tests, ran the workspace test suite, and drafted commit and PR description.
**@⁠hajduzsolt** on GitHub · 2026-11-24 17:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/1572) `hajduzsolt:recompiler/vopc-16bit-ignore-opsel` → `main` · +67 −7 · 2 files · 1 commits · closed without merging Updates 16-bit non-class VOPC compares (f16/u16/i16) to always read both sources from the low 16 bits ([15:0]), ignoring VOP3 op_sel bits to match RDNA2 hardware behavior. Fixes #1293. **What is in it** - crates/xcl/src/gpu/recomp/emit.rs: introduce lo16 in vopc and use it for f16 (excluding class), u16, and i16 operands instead of selecting high halves via m.opsel. - crates/xcl/src/gpu/recomp/tests.rs: add vopc_16bit_ignores_vop3_opsel_and_reads_low_halves and gpu_vopc_16bit_ignores_vop3_opsel testing V_CMP_LT_F16, V_CMP_LT_U16, V_CMP_GT_I16, and V_CMPX_EQ_U16 against V_ADD_NC_U16 (control) across Wave32 and Wave64. **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::vopc_16bit -- --test-threads=2: 1 passed, 0 failed, 0 ignored. - cargo test -p xcl --lib gpu::recomp::tests::gpu_vopc_16bit -- --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: ad6921e1bcc05ff3c486c382c1b13d704ca51eb4 gpu: AMD Radeon RX 9070 XT title: A newer retail game seconds: 60 exit: 0x0 frames shown: 1647 (PresentX 1647) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14834 MB ``` **Not tested** - NVIDIA and Intel Arc GPUs, and v_cmp_class_f16 with op_sel. **AI use** - Antigravity (Gemini 4 Hydrogen, high): updated vopc in emit.rs to ignore op_sel on 16-bit non-class compares, wrote translation and Wave32/Wave64 GPU tests, ran the workspace test suite, and drafted commit and PR description.
RDNA2 hardware ignores VOP3 op_sel bits on 16-bit VOPC compares (v_cmp_*/v_cmpx_* over f16/u16/i16) and always reads both operands from bits [15:0], whereas vopc extracted upper halves when m.opsel bits were set.

Read low 16 bits unconditionally for non-class f16/u16/i16 compares (leaving v_cmp_class_f16 and SDWA behavior unchanged).

Fixes #1293

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

@⁠DavidM1911 on GitHub · 2026-11-24 19:41 UTC · original

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

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

Thanks!

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

@⁠throny on GitHub · 2026-11-24 19:55 UTC · original

Two contributors checked independently and found that this PR makes the same change as #1296 (for #1293): #1607, group D27. They suggest keeping #1296. 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 19:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/1572#issuecomment-7142781809) <!-- xcl-1607-hint:D27 --> Two contributors checked independently and found that this PR makes the same change as #1296 (for #1293): #1607, group D27. They suggest keeping #1296. 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:43 UTC · original

Closing this as a duplicate: #1296 makes the same change and was opened first (16-bit compares read the low halves whatever op_sel says). 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 #1296 does not, or #1296 is closed without being merged, say so and I'll reopen it. A test that is only here is welcome on #1296.

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:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/1572#issuecomment-7143961581) Closing this as a duplicate: #1296 makes the same change and was opened first (16-bit compares read the low halves whatever op_sel says). 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 #1296 does not, or #1296 is closed without being merged, say so and I'll reopen it. A test that is only here is welcome on #1296. 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.