Recompiler: mask bridged V_CMP_* results with EXEC in per-lane lowering #2503

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

@⁠ChalanaGimhanaX on GitHub · 2026-11-25 20:55 UTC · original
ChalanaGimhanaX:recomp/per-lane-bridged-vcmp-exec → main · +94 −2 · 2 files · 1 commits · open

Mask bridged non-CMPX V_CMP_* results with EXEC in per-lane direct DXIL lowering (Lower::bridge), matching RDNA2 hardware, native Lower::valu_op, and the HLSL path.

lane_masks::is_vector excludes all V_CMP* instructions so their PCs are never in self.guarded, and Lower::valu_op only lowers plain U32/I32 compares natively. Every float (F32/F16/F64), 64-bit, 16-bit, V_CMP_CLASS_*, and VOP3-modified/SDWA compare falls through to Lower::bridge, which previously only captured old_exec for V_CMPX* and passed guard = true to Ir::foreign. Inactive lanes outside EXEC therefore left 1 in VCC/SDST instead of 0, corrupting subsequent mask ops and S_CBRANCH_VCCZ/VCCNZ branches.

Part of #2458, #1269, and #1833. (Issue #2458 item 2 — NULL / SDST = 125 writes — is already covered by open PR #2117 and intentionally left out to stay single-purpose and avoid conflicts.)

What is in it

  • crates/xcl/src/gpu/recomp/lower.rs: in Lower::bridge, capture old_exec for all V_CMP* instructions (when !in_guarded_run), not only V_CMPX*, so inactive lanes are ANDed out before write_bit.
  • crates/xcl/src/gpu/recomp/lower_dxil.rs: added a_bridged_v_cmp_clears_inactive_lanes_outside_exec covering bridged VOPC (VCC) and VOP3 (s4) V_CMP_LT_F32 under narrowed EXEC (exact register checks + HLSL GPU parity) and compute S_CBRANCH_VCCZ under both wave32 and split wave64 (with DXIL validation on CPU).

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.1714), Intel Core i5-10400F, Windows 11 Pro Build 26200, rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.8.2502.11, release build.
  • Failing-first check before the lower.rs fix: cargo test --release -p xcl --lib gpu::recomp::lower_dxil::tests::a_bridged_v_cmp_clears_inactive_lanes_outside_exec -- --exact --nocapture failed with assertion left == right failed: vcc must clear inactive lanes 16..31 (left: 4294901760 [0xFFFF_0000], right: 0).
  • Targeted after fix (1051482):
    • RTX 3060: cargo test --release -p xcl --lib gpu::recomp::lower_dxil::tests:: -- --test-threads=4 --nocapture: 22 passed, 0 failed.
    • WARP (XCL_ADAPTER=warp): a_bridged_v_cmp_clears_inactive_lanes_outside_exec passed (all 3 DXIL containers compiled and validated on CPU; GPU execution skipped cleanly with no GPU with 32-lane waves).
  • Full workspace release suite (1051482): cargo build --release --workspace + cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1424 passed, 0 failed, 46 ignored across 37 test binaries.
  • SKIPPED GPU/adapter tests (26): 21 no wave64, 3 refused per-lane f16/f32 forms (#1426), 1 no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode required for driver cache disable).
  • cargo test --release -p xcl --test e2e -- --test-threads=1 (1051482): 4 passed, 0 failed.

Regression run

main (6d051da):

xcl-smoke v1
commit: 6d051da51ba3fe7ba7d4ef542da71f544646e3ba
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1473 (PresentX 1473)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14348 MB

this PR (1051482):

xcl-smoke v1
commit: 10514822001f2302cd102b9431a9d8613e45cf3a
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1474 (PresentX 1474)
presents per 2 s (last 3): 42 60 60
device removals: 0
crashes: 0
peak commit: 10168 MB

Not tested

  • Native wave64 hardware (split = false GPU execution path), AMD / Intel GPUs, Linux / Wine, and retail gameplay beyond the 60-second smoke run.

AI use

  • Antigravity (Gemini 4 Neon) implemented the Lower::bridge EXEC-masking fix and GPU/DXIL-validation regression test, ran the test suite and regression smoke run, and drafted this description.
**@⁠ChalanaGimhanaX** on GitHub · 2026-11-25 20:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/2503) `ChalanaGimhanaX:recomp/per-lane-bridged-vcmp-exec` → `main` · +94 −2 · 2 files · 1 commits · open Mask bridged non-`CMPX` `V_CMP_*` results with `EXEC` in per-lane direct DXIL lowering (`Lower::bridge`), matching RDNA2 hardware, native `Lower::valu_op`, and the HLSL path. `lane_masks::is_vector` excludes all `V_CMP*` instructions so their PCs are never in `self.guarded`, and `Lower::valu_op` only lowers plain `U32`/`I32` compares natively. Every float (`F32`/`F16`/`F64`), 64-bit, 16-bit, `V_CMP_CLASS_*`, and VOP3-modified/SDWA compare falls through to `Lower::bridge`, which previously only captured `old_exec` for `V_CMPX*` and passed `guard = true` to `Ir::foreign`. Inactive lanes outside `EXEC` therefore left `1` in `VCC`/`SDST` instead of `0`, corrupting subsequent mask ops and `S_CBRANCH_VCCZ`/`VCCNZ` branches. Part of #2458, #1269, and #1833. (Issue #2458 item 2 — `NULL` / `SDST = 125` writes — is already covered by open PR #2117 and intentionally left out to stay single-purpose and avoid conflicts.) **What is in it** - `crates/xcl/src/gpu/recomp/lower.rs`: in `Lower::bridge`, capture `old_exec` for all `V_CMP*` instructions (when `!in_guarded_run`), not only `V_CMPX*`, so inactive lanes are ANDed out before `write_bit`. - `crates/xcl/src/gpu/recomp/lower_dxil.rs`: added `a_bridged_v_cmp_clears_inactive_lanes_outside_exec` covering bridged VOPC (`VCC`) and VOP3 (`s4`) `V_CMP_LT_F32` under narrowed `EXEC` (exact register checks + HLSL GPU parity) and compute `S_CBRANCH_VCCZ` under both wave32 and split wave64 (with DXIL validation on CPU). **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.1714), Intel Core i5-10400F, Windows 11 Pro Build 26200, `rustc 1.100.0 (0ef1bc386 2026-11-09)`, DXC `1.8.2502.11`, release build. - Failing-first check before the `lower.rs` fix: `cargo test --release -p xcl --lib gpu::recomp::lower_dxil::tests::a_bridged_v_cmp_clears_inactive_lanes_outside_exec -- --exact --nocapture` failed with `assertion left == right failed: vcc must clear inactive lanes 16..31 (left: 4294901760 [0xFFFF_0000], right: 0)`. - Targeted after fix (`1051482`): - RTX 3060: `cargo test --release -p xcl --lib gpu::recomp::lower_dxil::tests:: -- --test-threads=4 --nocapture`: 22 passed, 0 failed. - WARP (`XCL_ADAPTER=warp`): `a_bridged_v_cmp_clears_inactive_lanes_outside_exec` passed (all 3 DXIL containers compiled and validated on CPU; GPU execution skipped cleanly with `no GPU with 32-lane waves`). - Full workspace release suite (`1051482`): `cargo build --release --workspace` + `cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture`: 1424 passed, 0 failed, 46 ignored across 37 test binaries. - `SKIPPED` GPU/adapter tests (26): 21 `no wave64`, 3 refused per-lane f16/f32 forms (`#1426`), 1 `no heap windows`, 1 `pso_measurement_compiles_an_exact_synthetic_record` (Windows Developer Mode required for driver cache disable). - `cargo test --release -p xcl --test e2e -- --test-threads=1` (`1051482`): 4 passed, 0 failed. **Regression run** main (`6d051da`): ``` xcl-smoke v1 commit: 6d051da51ba3fe7ba7d4ef542da71f544646e3ba gpu: NVIDIA GeForce RTX 3060 title: 37fe04ab seconds: 60 exit: 0x0 frames shown: 1473 (PresentX 1473) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14348 MB ``` this PR (`1051482`): ``` xcl-smoke v1 commit: 10514822001f2302cd102b9431a9d8613e45cf3a gpu: NVIDIA GeForce RTX 3060 title: 37fe04ab seconds: 60 exit: 0x0 frames shown: 1474 (PresentX 1474) presents per 2 s (last 3): 42 60 60 device removals: 0 crashes: 0 peak commit: 10168 MB ``` **Not tested** - Native wave64 hardware (`split = false` GPU execution path), AMD / Intel GPUs, Linux / Wine, and retail gameplay beyond the 60-second smoke run. **AI use** - Antigravity (Gemini 4 Neon) implemented the `Lower::bridge` `EXEC`-masking fix and GPU/DXIL-validation regression test, ran the test suite and regression smoke run, and drafted this description.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:32:18 +00:00
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-25 21:07 UTC · original

Ran on an AMD RX 9070 XT (RDNA4) and an RTX 3060: the new test passes on both cards, and nothing else changes.

Diff applied on main 6d12f58, debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- gpu:: --test-threads=4 on main and with the PR, card chosen with XCL_ADAPTER, run twice: once with XCL_PER_LANE=1 alone, once with XCL_PER_LANE=1 XCL_DIRECT_DXIL=1. Both gave the same results:

  • RX 9070 XT (driver 32.0.32029.2010): a_bridged_v_cmp_clears_inactive_lanes_outside_exec ok. 699 passed, 2 failed; the 2 failures are the AMD fuzz seeds tracked in #2115, the same on main.
  • RTX 3060 (driver 32.0.16.1088): the new test ok; 701 passed, 0 failed.

No other test changes result on either card.

On the "native wave64" gap: the test's wave64 case goes through compute_split, so on the RX 9070 XT it runs the split form too. This run doesn't cover the native (split = false) path either.

Not tested: retail shaders, Intel, Linux / Wine.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-25 21:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/2503#issuecomment-7174651010) Ran on an AMD RX 9070 XT (RDNA4) and an RTX 3060: the new test passes on both cards, and nothing else changes. Diff applied on `main` `6d12f58`, debug, Windows 11 Pro 26200, `cargo test -p xcl --lib -- gpu:: --test-threads=4` on `main` and with the PR, card chosen with `XCL_ADAPTER`, run twice: once with `XCL_PER_LANE=1` alone, once with `XCL_PER_LANE=1 XCL_DIRECT_DXIL=1`. Both gave the same results: - **RX 9070 XT** (driver 32.0.32029.2010): `a_bridged_v_cmp_clears_inactive_lanes_outside_exec` ok. 699 passed, 2 failed; the 2 failures are the AMD fuzz seeds tracked in #2115, the same on `main`. - **RTX 3060** (driver 32.0.16.1088): the new test ok; 701 passed, 0 failed. No other test changes result on either card. On the "native wave64" gap: the test's wave64 case goes through `compute_split`, so on the RX 9070 XT it runs the split form too. This run doesn't cover the native (`split = false`) path either. Not tested: retail shaders, Intel, Linux / Wine. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 21:08 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_clears_inactive_lanes_outside_exec: passed.

**@⁠SlopTart** on GitHub · 2026-11-25 21:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/2503#issuecomment-7174662587) `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_clears_inactive_lanes_outside_exec`: passed.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 21:14 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:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/2503#issuecomment-7174795183) 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!
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-25 21:14 UTC · original

Independent AMD RDNA4 (native wave64) test report on exact head 10514822001f2302cd102b9431a9d8613e45cf3a (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1422 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • The PR's GPU test passed (no skips): gpu::recomp::lower_dxil::tests::a_bridged_v_cmp_clears_inactive_lanes_outside_exec.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 10514822001f2302cd102b9431a9d8613e45cf3a
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1600 (PresentX 1600)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14236 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
**@⁠emirduran707** on GitHub · 2026-11-25 21:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/2503#issuecomment-7174813491) Independent AMD RDNA4 (native wave64) test report on exact head `10514822001f2302cd102b9431a9d8613e45cf3a` (clean detached checkout, no local changes). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2602.17; tests debug, smoke release. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: **1422 passed, 2 failed, 46 ignored; 8 SKIPPED** (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu` refused by per-lane form; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`). All native wave64 GPU tests ran and passed. - The PR's GPU test passed (no skips): `gpu::recomp::lower_dxil::tests::a_bridged_v_cmp_clears_inactive_lanes_outside_exec`. - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` seed 722 and `fuzz_validate_and_gpu_3` seed 1599) are pre-existing on unmodified `main` on this GPU. **Regression run** (60 s retail-title smoke, `XCL_NETWORK=0`, release) ``` xcl-smoke v1 commit: 10514822001f2302cd102b9431a9d8613e45cf3a gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1600 (PresentX 1600) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14236 MB ``` (Matched `main` `68a284a` baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.) **Not tested** - D3D12 debug layer; Intel GPUs. **AI use** - Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
Author
Owner

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

Test run on exact head 1051482 (10514822001f2302cd102b9431a9d8613e45cf3a, on base 6d12f58), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (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: 1424 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 (a_bridged_v_cmp_clears_inactive_lanes_outside_exec and the existing a_bridged_v_cmpx_keeps_the_lanes_outside_exec_out), not skipped
  • I hit the same bug independently (closed duplicate #2507): on main, a program with EXEC = lanes 0–15, a bridged v_cmp_le_f32 true in every lane, EXEC restored and v_cndmask on VCC gives 7 in lane 16 instead of 0; this PR's change gives 0

Regression run (60 s, default settings)

main:

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

this PR:

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

No crash or device removal; frames 102 % of main's, peak commit 100 %.

Not tested

  • AMD / native wave64
  • Whether the title reaches a bridged v_cmp under a narrowed EXEC (not run with XCL_PER_LANE=1): a regression check only

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.
**@⁠xpatfussy69x** on GitHub · 2026-11-25 21:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/2503#issuecomment-7175247848) Test run on exact head `1051482` (`10514822001f2302cd102b9431a9d8613e45cf3a`, on base `6d12f58`), clean tree. **Tested** - NVIDIA GeForce RTX 3060 12 GB (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`: 1424 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 (`a_bridged_v_cmp_clears_inactive_lanes_outside_exec` and the existing `a_bridged_v_cmpx_keeps_the_lanes_outside_exec_out`), not skipped - I hit the same bug independently (closed duplicate #2507): on `main`, a program with EXEC = lanes 0–15, a bridged `v_cmp_le_f32` true in every lane, EXEC restored and `v_cndmask` on VCC gives 7 in lane 16 instead of 0; this PR's change gives 0 **Regression run** (60 s, default settings) main: ``` xcl-smoke v1 commit: 6d12f58a229bc73889878a448c64dc3af25eeba0 gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 1130 (PresentX 1130) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14808 MB ``` this PR: ``` xcl-smoke v1 commit: 10514822001f2302cd102b9431a9d8613e45cf3a gpu: NVIDIA GeForce RTX 3060 title: c3f791f3 seconds: 60 exit: 0x0 frames shown: 1150 (PresentX 1150) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14782 MB ``` No crash or device removal; frames 102 % of `main`'s, peak commit 100 %. **Not tested** - AMD / native wave64 - Whether the title reaches a bridged `v_cmp` under a narrowed EXEC (not run with `XCL_PER_LANE=1`): a regression check only **AI use** - Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.
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/2503/head:github-bot/gh-2503'
git switch 'github-bot/gh-2503'

Merge

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