Skip to content

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

Closed
xpatfussy69x wants to merge 1 commit into
xcl-dev:mainfrom
xpatfussy69x:recompiler/bridged-v-cmp-exec
Closed

xpatfussy69x wants to merge 1 commit into
xcl-dev:mainfrom
xpatfussy69x:recompiler/bridged-v-cmp-exec

Conversation

@xpatfussy69x

Copy link
Copy Markdown

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; Recompiler: the per-lane form takes f16 converts and products from #1426 #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

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

…dev#2458)

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 xcl-dev#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 xcl-dev#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 <noreply@anthropic.com>
@SlopTart

Copy link
Copy Markdown

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.

@xpatfussy69x

Copy link
Copy Markdown
Author

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants