Recompiler: 16-bit compares read their low halves whatever op_sel says (#1293) #1296

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

@⁠tiagonogueiraa-bit on GitHub · 2026-11-24 14:27 UTC · original
tiagonogueiraa-bit:vopc16-opsel → main · +34 −1 · 2 files · 1 commits · open

On RDNA2, 16-bit compares (v_cmp_* / v_cmpx_* over f16, u16, i16) take both sources from the low halves and ignore op_sel. This was measured on gfx1036 in Marvisak/VIctory#833. vopc honoured op_sel, so op_sel:[1,0] on 0x4000_3C00 < 0x3C00_3E00 compared 2.0 < 1.5 instead of 1.0 < 1.5. v_cmp_class_f16 was not measured and keeps op_sel, as the issue suggests. Fixes #1293.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs (vopc): the 16-bit halves come from the low 16 bits except for class.
  • crates/xcl/src/gpu/recomp/tests.rs: gpu_cmp_16_ignores_op_sel, one f16, u16 and i16 compare each, with op_sel set and high halves that give the opposite answer.

Tested

  • macOS, Rust stable: cargo check -p xcl --lib --tests --target x86_64-pc-windows-msvc passes with no errors (C stubbed, not linked).
  • On the CPU, not a GPU: I translated the test's program with gpu::recomp from main and from this branch and ran the emitted HLSL as C++ on one lane with the test's registers. On main all four compares are false, so the test fails. With this change all four are true.
  • GPU runs by others on this head 8b247b0:
    • @⁠vitor127wt (RTX 5070 Ti, Wine + vkd3d-proton): gpu_cmp_16_ignores_op_sel passes in the workspace suite and run on its own. The suite's failures under Wine are also failures on the base 930e8b4. (report)
    • @⁠DavidM1911 (RTX 3060 Ti, Windows 11, merged with main): cargo test -p xcl --lib recomp, 190 passed, 0 failed, 18 ignored. (report)
      Later, the whole lib with --test-threads=1: all passed, 0 failed, 21 ignored. (report)
  • @⁠ySKELLETONX (AMD RX 7600 XT, RDNA3, native Windows 11): scripts/test.ps1 752 passed, 0 failed, 41 ignored, no SKIPPED. With the emit.rs change reverted, gpu_cmp_16_ignores_op_sel fails at wave64 v_cmp_lt_f16 op_sel:[1,0]. (report)

Regression run
By @⁠IvyNotFound: scripts/smoke.ps1 -Seconds 60, XCL_PRESS_A_AT=15, unedited, from the report.

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 60
exit: 0x0
frames shown: 1331 (PresentX 1332)
presents per 2 s (last 3): 19 43 38
device removals: 0
crashes: 0
peak commit: 26748 MB

PR:

xcl-smoke v1
commit: 8b247b0f1068fcca07b0752a46ffea160f83b46d
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 60
exit: 0x0
frames shown: 1320 (PresentX 1320)
presents per 2 s (last 3): 8 22 47
device removals: 0
crashes: 0
peak commit: 26630 MB

Not tested

  • AMD / native wave64.
  • A retail title. Its shaders have no 16-bit compare with op_sel set (#1293), so this path is not reached there.

AI use

  • Claude Code with Claude Opus 5.5. It wrote the change, the test and this description, and ran the macOS checks above.

🤖 Generated with Claude Code

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-24 14:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/1296) `tiagonogueiraa-bit:vopc16-opsel` → `main` · +34 −1 · 2 files · 1 commits · open On RDNA2, 16-bit compares (`v_cmp_*` / `v_cmpx_*` over f16, u16, i16) take both sources from the low halves and ignore `op_sel`. This was measured on gfx1036 in Marvisak/VIctory#833. `vopc` honoured `op_sel`, so `op_sel:[1,0]` on `0x4000_3C00 < 0x3C00_3E00` compared 2.0 < 1.5 instead of 1.0 < 1.5. `v_cmp_class_f16` was not measured and keeps `op_sel`, as the issue suggests. Fixes #1293. **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs` (`vopc`): the 16-bit halves come from the low 16 bits except for `class`. - `crates/xcl/src/gpu/recomp/tests.rs`: `gpu_cmp_16_ignores_op_sel`, one f16, u16 and i16 compare each, with `op_sel` set and high halves that give the opposite answer. **Tested** - macOS, Rust stable: `cargo check -p xcl --lib --tests --target x86_64-pc-windows-msvc` passes with no errors (C stubbed, not linked). - On the CPU, not a GPU: I translated the test's program with `gpu::recomp` from `main` and from this branch and ran the emitted HLSL as C++ on one lane with the test's registers. On `main` all four compares are false, so the test fails. With this change all four are true. - GPU runs by others on this head `8b247b0`: - @⁠vitor127wt (RTX 5070 Ti, Wine + vkd3d-proton): `gpu_cmp_16_ignores_op_sel` passes in the workspace suite and run on its own. The suite's failures under Wine are also failures on the base `930e8b4`. ([report](https://github.com/ivall/xcl/pull/1296#issuecomment-7135218840)) - @⁠DavidM1911 (RTX 3060 Ti, Windows 11, merged with `main`): `cargo test -p xcl --lib recomp`, 190 passed, 0 failed, 18 ignored. ([report](https://github.com/ivall/xcl/pull/1296#issuecomment-7134571514)) Later, the whole lib with `--test-threads=1`: all passed, 0 failed, 21 ignored. ([report](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1296)) - @⁠ySKELLETONX (AMD RX 7600 XT, RDNA3, native Windows 11): `scripts/test.ps1` **752 passed, 0 failed, 41 ignored**, no `SKIPPED`. With the `emit.rs` change reverted, `gpu_cmp_16_ignores_op_sel` fails at `wave64 v_cmp_lt_f16 op_sel:[1,0]`. ([report](https://github.com/ivall/xcl/pull/1296#issuecomment-7135593421)) **Regression run** By @⁠IvyNotFound: `scripts/smoke.ps1 -Seconds 60`, `XCL_PRESS_A_AT=15`, unedited, from [the report](https://github.com/ivall/xcl/pull/1296#issuecomment-7135932971). main: ``` xcl-smoke v1 commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56 gpu: NVIDIA GeForce RTX 5080 title: game seconds: 60 exit: 0x0 frames shown: 1331 (PresentX 1332) presents per 2 s (last 3): 19 43 38 device removals: 0 crashes: 0 peak commit: 26748 MB ``` PR: ``` xcl-smoke v1 commit: 8b247b0f1068fcca07b0752a46ffea160f83b46d gpu: NVIDIA GeForce RTX 5080 title: game seconds: 60 exit: 0x0 frames shown: 1320 (PresentX 1320) presents per 2 s (last 3): 8 22 47 device removals: 0 crashes: 0 peak commit: 26630 MB ``` **Not tested** - AMD / native wave64. - A retail title. Its shaders have no 16-bit compare with `op_sel` set (#1293), so this path is not reached there. **AI use** - Claude Code with Claude Opus 5.5. It wrote the change, the test and this description, and ran the macOS checks above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On RDNA2, v_cmp_* / v_cmpx_* over f16, u16 and i16 take both sources from
the low 16 bits and ignore op_sel. This was measured on gfx1036 in
Marvisak/VIctory#833, with v_add_nc_u16 under the same bits honouring
them as the control. vopc selected the high half for each set bit, so
op_sel:[1,0] on 0x4000_3C00 < 0x3C00_3E00 compared 2.0 < 1.5 instead of
1.0 < 1.5. v_cmp_class_f16 was not measured and keeps op_sel.

gpu_cmp_16_ignores_op_sel runs one f16, u16 and i16 compare each, with
op_sel bits set, whose high halves give the opposite answer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:49:52 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 14:33 UTC · original

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

  • cargo test -p xcl --lib lib recomp: 190 passed, 18 ignored, 0 failed.

Thanks!

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

@⁠tiagonogueiraa-bit on GitHub · 2026-11-24 14:34 UTC · original

@⁠DavidM1911 thank you! Two details would make this count for the merge:

  • the commit you tested: the head is 8b247b0. Which main commit was it merged with?
  • that gpu::recomp::tests::gpu_cmp_16_ignores_op_sel actually ran on the GPU rather than printing SKIPPED. Running cargo test -p xcl --lib gpu_cmp_16_ignores_op_sel -- --nocapture shows it.

If you get the chance, the whole suite (cargo test --workspace -- --test-threads=4, with its counts) is what CONTRIBUTING asks for.

Written with Claude Code (Claude Opus 5.5).

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-24 14:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/1296#issuecomment-7134591202) @⁠DavidM1911 thank you! Two details would make this count for the merge: - the commit you tested: the head is `8b247b0`. Which `main` commit was it merged with? - that `gpu::recomp::tests::gpu_cmp_16_ignores_op_sel` actually ran on the GPU rather than printing `SKIPPED`. Running `cargo test -p xcl --lib gpu_cmp_16_ignores_op_sel -- --nocapture` shows it. If you get the chance, the whole suite (`cargo test --workspace -- --test-threads=4`, with its counts) is what CONTRIBUTING asks for. Written with Claude Code (Claude Opus 5.5).
Author
Owner

@⁠vitor127wt on GitHub · 2026-11-24 14:57 UTC · original

Test report on RTX 5070 Ti under Wine

Following up on #1243. I tested the exact PR head 8b247b0f1068fcca07b0752a46ffea160f83b46d in a separate checkout and build directory. gpu::recomp::tests::gpu_cmp_16_ignores_op_sel passed in the workspace suite and in an isolated rerun with --exact gpu::recomp::tests::gpu_cmp_16_ignores_op_sel --nocapture --test-threads=1 (1 passed, 0 failed, 0 ignored, 0 skipped). The test log confirmed the RTX 5070 Ti and DXC were in use.

Tested

  • RTX 5070 Ti (16,303 MiB reported), NVIDIA Linux driver 620.73.04, Ryzen 7 9700X, 32 GB DDR5. CachyOS x86-64, kernel 7.3.5-2-cachyos, Wine 11.22, DXVK v2.7.1-498-ga6764047e587178, vkd3d-proton 3.1.0 from Proton-CachyOS (0bb64c56c8f0dcc), DXC 1.9.2609.5. Rust 1.100.0 and cargo-xwin 0.24.1, Windows MSVC debug target.
  • cargo xwin build --offline --locked --target x86_64-pc-windows-msvc --workspace succeeded. cargo xwin test --offline --locked --target x86_64-pc-windows-msvc --workspace --no-fail-fast -- --test-threads=4 ran under Wine and reported 686 passed, 66 failed, 41 ignored (exit 101). Four capability skips are included in the harness's passed count and listed below.
  • The same test command on the common base 930e8b49c1c2ec683d22c724a398b39111cd0e56 reported 683 passed, 68 failed, 41 ignored, with the same four skips. All 66 failure names from the PR also appeared on the base. The two additional base failures were gpu_nonfused_mad_and_mac_prevent_fma_contraction (device removed) and never_picks_xcl_itself (file copy error). The baseline build used an on-disk target directory after a linker error on tmpfs.
SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
SKIPPED gpu::texture::tests::gpu_console_textures_upload_every_mip_and_slice: no GPU
SKIPPED gpu::texture::tests::gpu_upload_batches_reuse_the_queues_upload_buffer: no GPU

Not tested

Native Windows, AMD hardware and retail-title smoke runs. Retail sample environment variables were unset.

AI use

Codex (GPT-6, exact variant unavailable) cross-built and ran the tests, compared the failure lists and drafted this report.

**@⁠vitor127wt** on GitHub · 2026-11-24 14:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/1296#issuecomment-7135218840) **Test report on RTX 5070 Ti under Wine** Following up on #1243. I tested the exact PR head `8b247b0f1068fcca07b0752a46ffea160f83b46d` in a separate checkout and build directory. `gpu::recomp::tests::gpu_cmp_16_ignores_op_sel` passed in the workspace suite and in an isolated rerun with `--exact gpu::recomp::tests::gpu_cmp_16_ignores_op_sel --nocapture --test-threads=1` (1 passed, 0 failed, 0 ignored, 0 skipped). The test log confirmed the RTX 5070 Ti and DXC were in use. **Tested** - RTX 5070 Ti (16,303 MiB reported), NVIDIA Linux driver 620.73.04, Ryzen 7 9700X, 32 GB DDR5. CachyOS x86-64, kernel `7.3.5-2-cachyos`, Wine 11.22, DXVK `v2.7.1-498-ga6764047e587178`, vkd3d-proton 3.1.0 from Proton-CachyOS (`0bb64c56c8f0dcc`), DXC 1.9.2609.5. Rust 1.100.0 and cargo-xwin 0.24.1, Windows MSVC debug target. - `cargo xwin build --offline --locked --target x86_64-pc-windows-msvc --workspace` succeeded. `cargo xwin test --offline --locked --target x86_64-pc-windows-msvc --workspace --no-fail-fast -- --test-threads=4` ran under Wine and reported **686 passed, 66 failed, 41 ignored** (exit 101). Four capability skips are included in the harness's passed count and listed below. - The same test command on the common base `930e8b49c1c2ec683d22c724a398b39111cd0e56` reported **683 passed, 68 failed, 41 ignored**, with the same four skips. All 66 failure names from the PR also appeared on the base. The two additional base failures were `gpu_nonfused_mad_and_mac_prevent_fma_contraction` (device removed) and `never_picks_xcl_itself` (file copy error). The baseline build used an on-disk target directory after a linker error on tmpfs. ```text SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64 SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64 SKIPPED gpu::texture::tests::gpu_console_textures_upload_every_mip_and_slice: no GPU SKIPPED gpu::texture::tests::gpu_upload_batches_reuse_the_queues_upload_buffer: no GPU ``` **Not tested** Native Windows, AMD hardware and retail-title smoke runs. Retail sample environment variables were unset. **AI use** Codex (GPT-6, exact variant unavailable) cross-built and ran the tests, compared the failure lists and drafted this report.
Author
Owner

@⁠tiagonogueiraa-bit on GitHub · 2026-11-24 14:59 UTC · original

Thank you, @⁠vitor127wt! I added your run to Tested and marked the PR ready for review.

Written with Claude Code (Claude Opus 5.5).

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-24 14:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1296#issuecomment-7135270619) Thank you, @⁠vitor127wt! I added your run to **Tested** and marked the PR ready for review. Written with Claude Code (Claude Opus 5.5).
Author
Owner

@⁠ySKELLETONX on GitHub · 2026-11-24 15:10 UTC · original

Test report on head 8b247b0 (asked for in #1243). AI-written (Claude Code, Claude Opus 5.5) from real runs; checked by me.

Tested

  • AMD Radeon RX 7600 XT (RDNA3, driver 32.0.32015.2008), Ryzen 7 5700X3D, Windows 11 Pro 10.0.26300, rustc 1.100.0, debug build, DXC from Windows SDK 10.0.26100
  • scripts/test.ps1 (cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored; no SKIPPED lines
  • gpu::recomp::tests::gpu_cmp_16_ignores_op_sel: ok
  • With this PR's emit.rs change reverted (test kept, base 930e8b4): gpu_cmp_16_ignores_op_sel fails at tests.rs:7195 (wave64 v_cmp_lt_f16 op_sel:[1,0]), so the test catches the change.

Not tested

  • The hardware behaviour itself: the runner checks the translation on the host GPU, so this run does not confirm the gfx1036 measurement.
  • NVIDIA, WARP, any retail title (no smoke runs).
**@⁠ySKELLETONX** on GitHub · 2026-11-24 15:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/1296#issuecomment-7135593421) Test report on head `8b247b0` (asked for in #1243). AI-written (Claude Code, Claude Opus 5.5) from real runs; checked by me. **Tested** - AMD Radeon RX 7600 XT (RDNA3, driver 32.0.32015.2008), Ryzen 7 5700X3D, Windows 11 Pro 10.0.26300, rustc 1.100.0, debug build, DXC from Windows SDK 10.0.26100 - `scripts/test.ps1` (`cargo test --workspace -- --test-threads=4`): 752 passed, 0 failed, 41 ignored; no `SKIPPED` lines - `gpu::recomp::tests::gpu_cmp_16_ignores_op_sel`: ok - With this PR's `emit.rs` change reverted (test kept, base 930e8b4): `gpu_cmp_16_ignores_op_sel` fails at tests.rs:7195 (`wave64 v_cmp_lt_f16 op_sel:[1,0]`), so the test catches the change. **Not tested** - The hardware behaviour itself: the runner checks the translation on the host GPU, so this run does not confirm the gfx1036 measurement. - NVIDIA, WARP, any retail title (no smoke runs).
Author
Owner

@⁠tiagonogueiraa-bit on GitHub · 2026-11-24 15:13 UTC · original

Thank you, @⁠ySKELLETONX: the native Windows suite plus the revert check is what this PR was missing. It's in Tested now. The only thing left is an xcl-smoke pair (main and 8b247b0, same title and time) from anyone who has a title.

Written with Claude Code (Claude Opus 5.5).

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-24 15:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1296#issuecomment-7135659916) Thank you, @⁠ySKELLETONX: the native Windows suite plus the revert check is what this PR was missing. It's in **Tested** now. The only thing left is an `xcl-smoke` pair (`main` and `8b247b0`, same title and time) from anyone who has a title. Written with Claude Code (Claude Opus 5.5).
Author
Owner

@⁠IvyNotFound on GitHub · 2026-11-24 15:23 UTC · original

Regression runs for 8b247b0 on Windows, the xcl-smoke pair this PR still needs. Same retail title, same 60 s, unedited, made with scripts/smoke.ps1 -Seconds 60 and XCL_PRESS_A_AT=15. The PR head as is (base 930e8b4) and main 930e8b4, clean trees, one after the other.

  • NVIDIA GeForce RTX 5080 16 GB (32-lane waves), driver 621.24; Ryzen 7 7800X3D; Windows 11 25H2 (26200.9974); rustc 1.100.0 MSVC; DXC 1.9.2602.17; release.

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 60
exit: 0x0
frames shown: 1331 (PresentX 1332)
presents per 2 s (last 3): 19 43 38
device removals: 0
crashes: 0
peak commit: 26748 MB

this PR:

xcl-smoke v1
commit: 8b247b0f1068fcca07b0752a46ffea160f83b46d
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 60
exit: 0x0
frames shown: 1320 (PresentX 1320)
presents per 2 s (last 3): 8 22 47
device removals: 0
crashes: 0
peak commit: 26630 MB

Not tested: the suite at this head (see the other reports here); AMD.

AI use: Claude Code, Claude Opus 5.5 ran the runs and wrote this comment.

**@⁠IvyNotFound** on GitHub · 2026-11-24 15:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/1296#issuecomment-7135932971) **Regression runs for `8b247b0` on Windows**, the `xcl-smoke` pair this PR still needs. Same retail title, same 60 s, unedited, made with `scripts/smoke.ps1 -Seconds 60` and `XCL_PRESS_A_AT=15`. The PR head as is (base `930e8b4`) and `main` `930e8b4`, clean trees, one after the other. - NVIDIA GeForce RTX 5080 16 GB (32-lane waves), driver 621.24; Ryzen 7 7800X3D; Windows 11 25H2 (26200.9974); rustc 1.100.0 MSVC; DXC 1.9.2602.17; release. main: ``` xcl-smoke v1 commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56 gpu: NVIDIA GeForce RTX 5080 title: game seconds: 60 exit: 0x0 frames shown: 1331 (PresentX 1332) presents per 2 s (last 3): 19 43 38 device removals: 0 crashes: 0 peak commit: 26748 MB ``` this PR: ``` xcl-smoke v1 commit: 8b247b0f1068fcca07b0752a46ffea160f83b46d gpu: NVIDIA GeForce RTX 5080 title: game seconds: 60 exit: 0x0 frames shown: 1320 (PresentX 1320) presents per 2 s (last 3): 8 22 47 device removals: 0 crashes: 0 peak commit: 26630 MB ``` Not tested: the suite at this head (see the other reports here); AMD. AI use: Claude Code, Claude Opus 5.5 ran the runs and wrote this comment.
Author
Owner

@⁠tiagonogueiraa-bit on GitHub · 2026-11-24 15:25 UTC · original

Thank you, @⁠IvyNotFound! Both blocks are under Regression run exactly as posted, with credit. With them the PR has everything CONTRIBUTING asks for.

Written with Claude Code (Claude Opus 5.5).

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-24 15:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/1296#issuecomment-7135992365) Thank you, @⁠IvyNotFound! Both blocks are under **Regression run** exactly as posted, with credit. With them the PR has everything CONTRIBUTING asks for. Written with Claude Code (Claude Opus 5.5).
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 16:02 UTC · original

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

  • cargo test -p xcl --lib -- --test-threads=1: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified main.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 16:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/1296#issuecomment-7137012475) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib -- --test-threads=1`: all passed, 0 failed, 21 ignored. (Parallel runs intermittently abort with 0xc0000005 — same harness flake seen on unmodified `main`.) Thanks!
Author
Owner

@⁠tiagonogueiraa-bit on GitHub · 2026-11-24 20:14 UTC · original

Thank you @⁠DavidM1911, the whole-lib run is in Tested, next to your earlier recomp one.

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-24 20:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/1296#issuecomment-7143245184) Thank you @⁠DavidM1911, the whole-lib run is in **Tested**, next to your earlier `recomp` one.
Author
Owner

@⁠milesah3ad on GitHub · 2026-11-25 01:01 UTC · original

The direct DXIL backend counterpart of this fix, from @⁠regiumlepidi's parity sweep on #1269: gpu_cmp_16_ignores_op_sel pass with XCL_DIRECT_DXIL=1 with the patch below. Without it they fail on the direct path.

vopc in gpu/dxil/lower_valu.rs took each 16-bit source from the half op_sel named, so v_cmp_lt_f16 op_sel:[1,0] compared the high half (your test: (0, 0) against (0xFFFFFFFF, 0)). The patch applies op_sel to class only, as your HLSL change does. (#1214 / #1980 change class's src1 handling in the same function, so whichever lands second may need a small rebase.)

How to take it: this PR predates the direct backend on main, so rebase it onto main first (your commit rebases cleanly onto 7994cd1), then git am the patch below. Feel free to fold it into your PR with a Co-Authored-By: milesah3ad <[email protected]> line. I didn't open a separate PR, so this doesn't add another review.

patch (1 commit, for git am)
From 1646dfef4a84f8dab7d15ac5efa2be50ebd7f579 Mon Sep 17 00:00:00 2001
From: milesah3ad <[email protected]>
Date: Tue, 24 Nov 2026 18:54:27 -0600
Subject: [PATCH] Direct DXIL: 16-bit compares read their low halves whatever
 op_sel says

vopc took each 16-bit compare source from the half op_sel named, but
RDNA2's 16-bit compares read both sources from the low halves (measured
on gfx1036, #1293), so v_cmp_lt_f16 with op_sel:[1,0] compared the
wrong half. As #1296 does on the HLSL path, op_sel now applies to
v_cmp_class_f16 only, which was not measured and keeps it.

gpu_cmp_16_ignores_op_sel now passes with XCL_DIRECT_DXIL=1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YPhfiWsdJcDBLYSS8edLyS
---
 crates/xcl/src/gpu/dxil/lower_valu.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/crates/xcl/src/gpu/dxil/lower_valu.rs b/crates/xcl/src/gpu/dxil/lower_valu.rs
index beafdcd..eb8596e 100644
--- a/crates/xcl/src/gpu/dxil/lower_valu.rs
+++ b/crates/xcl/src/gpu/dxil/lower_valu.rs
@@ -1187,7 +1187,9 @@ impl Lw {
             return err(d, "VOPC");
         }
         let (mut ua, mut ub) = (u[0].w(), u[1].w());
-        let half = |s: &mut Self, i: u64, v: Value| if m.opsel >> i & 1 == 1 { s.lshrc(v, 16) } else { s.andc(v, 0xFFFF) };
+        // RDNA2's 16-bit compares read both sources from the low halves whatever op_sel says
+        // (measured on gfx1036, #1293); class was not measured and keeps op_sel (as #1296)
+        let half = |s: &mut Self, i: u64, v: Value| if opn == "class" && m.opsel >> i & 1 == 1 { s.lshrc(v, 16) } else { s.andc(v, 0xFFFF) };
         let ty = match ty {
             "f16" => {
                 if opn == "class" {
-- 
2.48.1.windows.1

Tested

  • RTX 5080 (wave32), driver 621.24, Windows 11 Pro 26300, rustc 1.100.0, DXC 1.9.2609.5, debug. Your commit rebased onto main 7994cd1 plus this patch: gpu_cmp_16_ignores_op_sel pass with and without XCL_DIRECT_DXIL=1.
  • cargo test -p xcl --lib --no-fail-fast -- --test-threads=4 on main 7994cd1 with #587, #686, #1159 and #1296 all merged and the four direct patches applied: 948 passed, 4 failed, 25 ignored, the same in both settings. The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3, which fail the same way on plain main here (944 passed, 4 failed). The +4 are the PRs' own tests.

Not tested: wave64 hardware (the wave64 cases SKIP here), AMD, any title, the full workspace suite (lib only).

AI use: Claude Code (Claude Opus 5.5) wrote the fix and ran the tests on the machine above. I checked the results.

**@⁠milesah3ad** on GitHub · 2026-11-25 01:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/1296#issuecomment-7149131313) **The direct DXIL backend counterpart of this fix**, from @⁠regiumlepidi's parity sweep on #1269: `gpu_cmp_16_ignores_op_sel` pass with `XCL_DIRECT_DXIL=1` with the patch below. Without it they fail on the direct path. `vopc` in `gpu/dxil/lower_valu.rs` took each 16-bit source from the half `op_sel` named, so `v_cmp_lt_f16 op_sel:[1,0]` compared the high half (your test: `(0, 0)` against `(0xFFFFFFFF, 0)`). The patch applies `op_sel` to `class` only, as your HLSL change does. (#1214 / #1980 change `class`'s src1 handling in the same function, so whichever lands second may need a small rebase.) **How to take it:** this PR predates the direct backend on `main`, so rebase it onto `main` first (your commit rebases cleanly onto `7994cd1`), then `git am` the patch below. Feel free to fold it into your PR with a `Co-Authored-By: milesah3ad <360542007+[email protected]>` line. I didn't open a separate PR, so this doesn't add another review. <details><summary>patch (1 commit, for <code>git am</code>)</summary> ```diff From 1646dfef4a84f8dab7d15ac5efa2be50ebd7f579 Mon Sep 17 00:00:00 2001 From: milesah3ad <360542007+[email protected]> Date: Tue, 24 Nov 2026 18:54:27 -0600 Subject: [PATCH] Direct DXIL: 16-bit compares read their low halves whatever op_sel says vopc took each 16-bit compare source from the half op_sel named, but RDNA2's 16-bit compares read both sources from the low halves (measured on gfx1036, #1293), so v_cmp_lt_f16 with op_sel:[1,0] compared the wrong half. As #1296 does on the HLSL path, op_sel now applies to v_cmp_class_f16 only, which was not measured and keeps it. gpu_cmp_16_ignores_op_sel now passes with XCL_DIRECT_DXIL=1. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01YPhfiWsdJcDBLYSS8edLyS --- crates/xcl/src/gpu/dxil/lower_valu.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/xcl/src/gpu/dxil/lower_valu.rs b/crates/xcl/src/gpu/dxil/lower_valu.rs index beafdcd..eb8596e 100644 --- a/crates/xcl/src/gpu/dxil/lower_valu.rs +++ b/crates/xcl/src/gpu/dxil/lower_valu.rs @@ -1187,7 +1187,9 @@ impl Lw { return err(d, "VOPC"); } let (mut ua, mut ub) = (u[0].w(), u[1].w()); - let half = |s: &mut Self, i: u64, v: Value| if m.opsel >> i & 1 == 1 { s.lshrc(v, 16) } else { s.andc(v, 0xFFFF) }; + // RDNA2's 16-bit compares read both sources from the low halves whatever op_sel says + // (measured on gfx1036, #1293); class was not measured and keeps op_sel (as #1296) + let half = |s: &mut Self, i: u64, v: Value| if opn == "class" && m.opsel >> i & 1 == 1 { s.lshrc(v, 16) } else { s.andc(v, 0xFFFF) }; let ty = match ty { "f16" => { if opn == "class" { -- 2.48.1.windows.1 ``` </details> **Tested** - RTX 5080 (wave32), driver 621.24, Windows 11 Pro 26300, rustc 1.100.0, DXC 1.9.2609.5, debug. Your commit rebased onto `main` `7994cd1` plus this patch: `gpu_cmp_16_ignores_op_sel` pass with and without `XCL_DIRECT_DXIL=1`. - `cargo test -p xcl --lib --no-fail-fast -- --test-threads=4` on `main` `7994cd1` with #587, #686, #1159 and #1296 all merged and the four direct patches applied: 948 passed, 4 failed, 25 ignored, **the same in both settings**. The 4 failures are `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3`, which fail the same way on plain `main` here (944 passed, 4 failed). The +4 are the PRs' own tests. **Not tested:** wave64 hardware (the wave64 cases SKIP here), AMD, any title, the full workspace suite (lib only). AI use: Claude Code (Claude Opus 5.5) wrote the fix and ran the tests on the machine above. I checked the results.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/1296/head:github-bot/gh-1296'
git switch 'github-bot/gh-1296'

Merge

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