Skip to content

Recompiler: a float v_cmpx through #1426's lowering keeps lanes outside EXEC out - #1876

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
gefydev:per-lane-cmpx-exec
Nov 24, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
gefydev:per-lane-cmpx-exec

Conversation

@gefydev

@gefydev gefydev commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

A float v_cmpx lowered through #1426's semantics in the per-lane form (XCL_PER_LANE=1, #1745) left EXEC as the compare alone, so lanes that were outside EXEC came back in. Point 3 of Pipodi's review of #1745; thehollowedone reproduced it on the GPU (#1269). Part of #1269.

His program: EXEC = lanes 0–15 (s_and_saveexec), then v_cmpx_le_f32 0, v1 (true in every lane), then v_mov v2, 7. The console, the HLSL path and #1426's per-instruction form write lanes 0–15; the per-lane form wrote all 32. The bridge runs #1426's lowering with the guard true, so the lane's bit it reads back is the compare alone. The new EXEC is now that bit and the lane's EXEC before the instruction, as the per-lane form's own integer v_cmpx already did. Only XCL_PER_LANE=1 reaches this code.

What is in it

  • crates/xcl/src/gpu/recomp/lower.rs (bridge): for v_cmpx, the lane's bit of the result is combined with its EXEC bit before the instruction.
  • crates/xcl/src/gpu/recomp/lower_dxil.rs: a_bridged_v_cmpx_keeps_the_lanes_outside_exec_out, his program on the GPU. It fails without the fix (lane 16 gets 7).

Tested

  • NVIDIA GTX 1650 (32-lane waves only), driver 621.24, Windows 11 Pro 26300, Rust 1.100.0, debug.
  • cargo test --workspace -- --test-threads=4 on fe78c81 (on main 689f2db): 976 passed, 0 failed, 45 ignored; 22 SKIPPED (18 "no wave64" on this GPU, 1 "no heap windows", 3 per-lane halves refused on purpose for gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426's f16 rounding).

Regression run
main:

xcl-smoke v1
commit: c4d37bec1bb4286eb373aea963404a23f13401fa
gpu: NVIDIA GeForce GTX 1650
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 944 (PresentX 944)
presents per 2 s (last 3): 1 1 6
device removals: 0
crashes: 0
peak commit: 11808 MB

This PR's head:

xcl-smoke v1
commit: fe78c81b7b26ac2d0aa08b9d74503dd0d0c2a8a1
gpu: NVIDIA GeForce GTX 1650
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 1030 (PresentX 1030)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 11534 MB

Both with XCL_PER_LANE off (the default), which this change does not reach.

Not tested

  • Native wave64 GPUs (AMD); the new test runs wave32.
  • A title run with XCL_PER_LANE=1; the regression runs are with it off, the default.

AI use

  • Claude Code (Claude Opus 5.5): wrote the fix, the test and this description, ran the checks.

…s outside EXEC out

thehollowedone's program on xcl-dev#1269 (Pipodi's review point 3 on xcl-dev#1745):
EXEC = lanes 0-15 (`s_and_saveexec`), then `v_cmpx_le_f32 0, v1`, true in
every lane, then `v_mov v2, 7`. The console, the HLSL path and xcl-dev#1426's
per-instruction form write lanes 0-15; the per-lane form wrote all 32.
The bridge runs xcl-dev#1426's lowering of a float `v_cmpx` with the guard
`true`, so the lane's bit it reads back is the compare alone. The new
EXEC is now that bit and the lane's EXEC before the instruction, as the
per-lane form's own integer `v_cmpx` already did.

Test: his program on the GPU (fails without the fix in lane 16).
@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

On Ampere: RTX 3070 8 GB (32-lane waves), driver 616.56, Windows 11, debug, fe78c81 on main 689f2db.

  • a_bridged_v_cmpx_keeps_the_lanes_outside_exec_out: passes, 2 of 2 runs.
  • gpu::recomp::l* (lower, lower_dxil, lane_masks): 57 passed, 0 failed.

AI-assisted (Claude Code). Synthetic tests only.

@thehollowedone

Copy link
Copy Markdown

Split-wave64 check of fe78c81 on an RTX 3080 Ti (621.35), Windows 11 build 26300, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11.

I extended the wave32 regression with a wave64 program that uses different EXEC masks in the two hardware waves, a mix of ordered float comparisons including NaN and signed zero, and unique destination sentinels. HLSL, per-instruction DXIL and per-lane DXIL all matched the CPU expectation in every lane: 13 writes in the lower half, 11 in the upper half, and all other destinations unchanged. Both EXEC dwords restored correctly. Replacing only the lowering with the pinned main version caused 14 out-of-mask writes in per-lane DXIL. Both reference paths still matched.

cargo test --offline --locked -p xcl --lib <filter> -- --nocapture --test-threads=1 passed 1/1 for each filter, a_bridged_v_cmpx_keeps_the_lanes_outside_exec_out and scratch_bridged_cmpx_intersects_split_exec. Zero skips. Synthetic compute shaders only.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended and ran the test and drafted this report.

@eizispark

Copy link
Copy Markdown

Hardware test report — commit fe78c81

Verified fe78c81b7b26ac2d0aa08b9d74503dd0d0c2a8a1 (based on main 689f2db477c3c062cf162649781640ef8a977c18, clean merge): pass (0 new failures vs main 689f2db).

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 x64 (stable-x86_64-pc-windows-msvc, rustc 1.100.0 (0ef1bc386 2026-11-09)), debug tests + release smoke
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads: 973 passed, 2 failed, 45 ignored (8 skipped), vs main 689f2db 972 passed, 2 failed, 45 ignored (8 skipped) on this adapter:
    • Skipped filter (--skip gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads) and the 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3) are pre-existing on main 689f2db (#1679) on RDNA4; 0 new failures
    • 8 skipped: 6 gpu::recomp::lower_dxil::tests f16/f32 direct-DXIL per-lane cases refused where #1426 semantics differ from the console's; shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode required, 0x887A002D); heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
  • gpu::recomp::lower_dxil::tests::a_bridged_v_cmpx_keeps_the_lanes_outside_exec_out executed on the GPU (0 skips, both wave32 and native wave64) and passed
  • All wave64 GPU tests skipped on wave32-only GPUs (lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu, the_split_form_agrees_with_the_wave64_lowering_on_the_gpu, lower_dxil::tests::*, gpu_geometry_direct_records, gpu_direct_f32_round_modes_*, mesh_dispatch::tests::*, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, console_wave64_compute_through_the_pso_hook_dispatch_and_read_back) ran natively and passed on RDNA4

Regression run (scripts/smoke.ps1, 60 s, warm shader/driver cache)
main (689f2db477c3c062cf162649781640ef8a977c18):

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

PR (fe78c81b7b26ac2d0aa08b9d74503dd0d0c2a8a1):

xcl-smoke v1
commit: fe78c81b7b26ac2d0aa08b9d74503dd0d0c2a8a1
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

Not tested

  • retail run with XCL_SHADER_BACKEND=dxil, Intel GPUs, Wine/vkd3d-proton, gameplay past the menus

AI use

  • Verified and formatted with Antigravity (Google DeepMind, Gemini 4 Carbon).

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
@raylitebull
raylitebull merged commit 95ae589 into xcl-dev:main Nov 24, 2026
2 checks passed
@tylerstraub

Copy link
Copy Markdown

RDNA2 hardware check of the behaviour this PR assumes: confirmed at 64 and 32 lanes. Your "Not tested" lists native wave64 GPUs. I ran the test's instruction sequence as machine code on an RDNA2 GPU, without XCL or any shader compiler in the path, so this is the hardware's own answer rather than a translation's.

Setup: Ryzen 9 9950X3D integrated Radeon (RDNA2, PCI 1002:13c0), Linux 7.0, amdgpu. A small runner uploads the instruction words and dispatches them through the kernel's amdgpu interface (compute, 64 threads in one group, v0 = thread index). The words were assembled with XCL's own encoder and checked with LLVM's gfx1030 disassembler. Differences from the test: the saved EXEC goes to s4 instead of s0 (the runner passes buffer addresses in s0–s3), v2 starts at 0, and a global_store_dword of v2 is appended.

v_mov_b32 v2, 0
v_mov_b32 v1, 1.0                 ; -1.0 in the second row
v_cmp_gt_u32 vcc, 16, v0
s_and_saveexec_b32 s4, vcc_lo     ; b64 forms in the 64-lane dispatch
v_cmpx_le_f32 0, v1               ; left out in the third row
v_mov_b32 v2, 7
s_mov_b32 exec_lo, s4
program 32-lane dispatch 64-lane dispatch
as above, compare true in every lane threads 0–15 hold 7 threads 0–15 hold 7
v1 = −1.0, compare false in every lane no thread holds 7 no thread holds 7
without the v_cmpx threads 0–15 hold 7 threads 0–15 hold 7

So on RDNA2 a float v_cmpx leaves EXEC as the compare in the lanes that were in EXEC, as the fix assumes.

Not tested: the console itself (same instruction set, different chip and driver state), other compares, VOP3 encodings, partial waves.

AI use: Claude Code (Claude Fable 5.2) wrote the runner, ran the programs on the machine above, and wrote and posted this comment at my request.

anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 25, 2026
, xcl-dev#1876, xcl-dev#1866)

Brings main to full parity with upstream/main (62265d3):
- xcl-dev#1005: skip VirtualQuery on committed coherent UMA windows in cpu_writes and kernelx
- xcl-dev#1053: opt-in fast-boot env vars (Bink intro skip, frame interval override, device type, TTS mute)
- xcl-dev#1876: float v_cmpx through xcl-dev#1426 lowering keeps lanes outside EXEC out
- xcl-dev#1866: track SCC of mixed mask and number operations

Conflict in crates/xcl/src/hle/xgameruntime/api.rs resolved by keeping both the
in-process Wine XAsync path and upstream's XCL_MUTE_TTS XAccessibility path.

Assisted-by: Antigravity (Gemini 4)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
Pulls in xcl-dev#1836 (graphics and two-pass PSO disk cache + lazy MS/GS + shader build coalescing), xcl-dev#1930 (DXIL CSE across discard), xcl-dev#1900, xcl-dev#1005, xcl-dev#1053, xcl-dev#1864, xcl-dev#1866, xcl-dev#1869, xcl-dev#1876, and xcl-dev#1898 while keeping our RDNA4 MSAA clamp (xcl-dev#1908), wave64 graphics Direct DXIL guard (xcl-dev#1913), atomic writable-range tracking, static-sampler cache keys, and 4M-group indirect dispatch clamp.
@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.

7 participants