Recompiler: a bridged v_cmp writes 0 for the lanes outside EXEC (#2458) #2507

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

@⁠xpatfussy69x on GitHub · 2026-11-25 21:07 UTC · original
xpatfussy69x:recompiler/bridged-v-cmp-exec → main · +34 −3 · 2 files · 1 commits · closed without merging

Part of #2458 (bug 1 only). In the per-lane form, a V_CMP_* that goes through #1426's lowering (float, 16- and 64-bit, V_CMP_CLASS, VOP3-modified) kept its raw result in the lanes outside EXEC, where the console writes 0. lane_masks never guards a V_CMP, so the bridge ran it with the guard true, and fe78c81 masked the result with EXEC only for v_cmpx. Under a narrowed EXEC, a later branch or v_cndmask on VCC then saw those lanes as set. Every bridged V_CMP* now ANDs its lane bit with EXEC, as the per-lane form's own U32/I32 compares already do.

What is in it

  • crates/xcl/src/gpu/recomp/lower.rs: the bridge takes the lane's EXEC bit into the result of every V_CMP*, not only V_CMPX*
  • crates/xcl/src/gpu/recomp/lower_dxil.rs: a_bridged_v_cmp_writes_0_for_the_lanes_outside_exec: EXEC = lanes 0–15, v_cmp_le_f32 true in every lane, EXEC restored, v_cndmask on VCC. Fails without the fix (7 in lane 16), passes with it

Tested

  • NVIDIA GeForce RTX 3060 (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0, debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1422 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too; #2182 removes them)
  • cargo test -p xcl --lib a_bridged_v_cmp: 2 passed (the new test and the existing v_cmpx one)

Regression run

main:

xcl-smoke v1
commit: e0d93c84ad8253f6e17738d14741c1bab7061127
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 768 (PresentX 769)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14869 MB

PR:

xcl-smoke v1
commit: fe72311c1f837fedf974e1a9a0a07779ca53fe58
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1132 (PresentX 1133)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14801 MB

Not tested

  • AMD / native wave64: the new test runs wave32 only, and the wave64 variants of the GPU tests were skipped on this card
  • Whether the title reaches a bridged v_cmp under a narrowed EXEC (smoke run with default settings, not XCL_PER_LANE=1): it is a regression check only. The frame difference is most likely run-to-run variance in loading
  • Bug 2 of #2458 (writes to NULL); #2136 touches NULL destinations in upper_lanes

AI use

  • Claude Code, Claude Opus 5.5: wrote the fix, the test and this description, ran the tests and both smoke runs on the hardware above
**@⁠xpatfussy69x** on GitHub · 2026-11-25 21:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2507) `xpatfussy69x:recompiler/bridged-v-cmp-exec` → `main` · +34 −3 · 2 files · 1 commits · closed without merging Part of #2458 (bug 1 only). In the per-lane form, a `V_CMP_*` that goes through #1426's lowering (float, 16- and 64-bit, `V_CMP_CLASS`, VOP3-modified) kept its raw result in the lanes outside EXEC, where the console writes 0. `lane_masks` never guards a `V_CMP`, so the bridge ran it with the guard `true`, and fe78c81 masked the result with EXEC only for `v_cmpx`. Under a narrowed EXEC, a later branch or `v_cndmask` on VCC then saw those lanes as set. Every bridged `V_CMP*` now ANDs its lane bit with EXEC, as the per-lane form's own U32/I32 compares already do. **What is in it** - `crates/xcl/src/gpu/recomp/lower.rs`: the bridge takes the lane's EXEC bit into the result of every `V_CMP*`, not only `V_CMPX*` - `crates/xcl/src/gpu/recomp/lower_dxil.rs`: `a_bridged_v_cmp_writes_0_for_the_lanes_outside_exec`: EXEC = lanes 0–15, `v_cmp_le_f32` true in every lane, EXEC restored, `v_cndmask` on VCC. Fails without the fix (7 in lane 16), passes with it **Tested** - NVIDIA GeForce RTX 3060 (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0, debug build for the tests, release for the smoke runs - `cargo test --workspace -- --test-threads=4`: 1422 passed, 0 failed, 46 ignored - SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused `V_MUL_F16` / `V_PK_MUL_F16` / `V_CVT_F16_F32` (on `main` too; #2182 removes them) - `cargo test -p xcl --lib a_bridged_v_cmp`: 2 passed (the new test and the existing `v_cmpx` one) **Regression run** main: ``` xcl-smoke v1 commit: e0d93c84ad8253f6e17738d14741c1bab7061127 gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 768 (PresentX 769) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14869 MB ``` PR: ``` xcl-smoke v1 commit: fe72311c1f837fedf974e1a9a0a07779ca53fe58 gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 1132 (PresentX 1133) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14801 MB ``` **Not tested** - AMD / native wave64: the new test runs wave32 only, and the wave64 variants of the GPU tests were skipped on this card - Whether the title reaches a bridged `v_cmp` under a narrowed EXEC (smoke run with default settings, not `XCL_PER_LANE=1`): it is a regression check only. The frame difference is most likely run-to-run variance in loading - Bug 2 of #2458 (writes to `NULL`); #2136 touches `NULL` destinations in `upper_lanes` **AI use** - Claude Code, Claude Opus 5.5: wrote the fix, the test and this description, ran the tests and both smoke runs on the hardware above
The per-lane form ANDs a compare's lane bit with EXEC only for the
compares it lowers itself (U32/I32). The rest (float, 16- and 64-bit,
V_CMP_CLASS, VOP3-modified) go through #1426's lowering with the guard
`true`, since lane_masks never guards a V_CMP, and fe78c81 masked the
result with EXEC only for v_cmpx. A non-cmpx compare under a narrowed
EXEC so kept its raw result in inactive lanes, where the console writes
0, and a later branch or v_cndmask on VCC saw those lanes as set.

Every bridged V_CMP* now takes the lane's EXEC bit into its result, as
the issue suggests. Bug 2 of #2458 (writes to NULL) is not in this change.

Test: EXEC = lanes 0-15, v_cmp_le_f32 true in every lane, EXEC restored,
v_cndmask on VCC: 7 in lanes 16-31 without the fix, 0 with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:32:26 +00:00
github-bot closed this pull request 2026-11-26 05:32:26 +00:00
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 21:15 UTC · original

gpu_ suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of a_bridged_v_cmp_writes_0_for_the_lanes_outside_exec: passed. Pairs with #2503's test (a_bridged_v_cmp_clears_inactive_lanes_outside_exec), also green here.

**@⁠SlopTart** on GitHub · 2026-11-25 21:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/2507#issuecomment-7174829906) `gpu_` suite (cold cache): 164 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR. Targeted run of `a_bridged_v_cmp_writes_0_for_the_lanes_outside_exec`: passed. Pairs with #2503's test (`a_bridged_v_cmp_clears_inactive_lanes_outside_exec`), also green here.
Author
Owner

@⁠xpatfussy69x on GitHub · 2026-11-25 21:23 UTC · original

Closing as a duplicate of #2503, which makes the same change to Lower::bridge and was opened first. I'll post this branch's test and smoke results there instead.

**@⁠xpatfussy69x** on GitHub · 2026-11-25 21:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/2507#issuecomment-7175021483) Closing as a duplicate of #2503, which makes the same change to `Lower::bridge` and was opened first. I'll post this branch's test and smoke results there instead.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 21:24 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 21:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2507#issuecomment-7175024678) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!

Pull request closed

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