Recompiler: invalidate block-local DXIL CSE wave/quad cache across dx.op.discard #1930
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1930
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1930/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@AlpPesen on GitHub · 2026-11-24 23:40 UTC · original
AlpPesen:fix/dxil-cse-invalidate-across-discard→main· +66 −0 · 1 files · 1 commits · merged 2026-11-24 23:54 UTCFixes block-local CSE in
dxil::module::optsodx.op.wave*anddx.op.quad*intrinsics cached in the per-blocklocalmap are invalidated when visitingdx.op.discard.In DXIL pixel shaders,
dx.op.discard(cond)demotes lanes mid-block without terminating the block, changing the wave's active lane set for all subsequent wave/quad intrinsics in the same basic block. Previouslylocalwas never cleared atdx.op.discard, allowing post-discard wave/quad calls with identical operands to reuse pre-discard results.Fixes #1891.
What is in it
crates/xcl/src/gpu/dxil/module/opt.rs:localwhen visitingOp::Call(f, _)whereself.funcs[*f as usize].name == "dx.op.discard".block_cse_invalidates_wave_and_quad_calls_across_discardverifying that identicaldx.op.waveActiveBallotanddx.op.quadReadLaneAtcalls on opposite sides ofdx.op.discardare preserved (2 calls remain), while identical calls withoutdx.op.discardin the same block still CSE to 1 call. Verified to fail on unmodifiedmain(20cf130) before the fix (left: 1, right: 2) and pass with the fix.Regression run
Baseline (immediate parent
main20cf130, warm shader/PSO cache):This PR (
fix/dxil-cse-invalidate-across-discard, warm shader/PSO cache):Tested
Hardware: Windows 11 Pro for Workstations (Build 26300), Intel Core i9-9900K, 32 GB RAM, AMD Radeon RX 6800 (16337 MiB VRAM, Driver
32.0.21045.29003),rustc 1.100.0 (0ef1bc386 2026-11-09).cargo test -p xcl --lib block_cse_invalidates_wave_and_quad_calls_across_discard:1 passed; 0 failed; 0 ignored; 0 skipped.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4:973 passed; 4 failed; 45 ignored; 8 skipped(3 pre-existing RDNA2placed_title_textures_share_vram_and_preserve_pixels+VRAM_TEST_LOCKcascades tracked in #470, plusgpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1— unrelated pre-existing fuzz failure tracked in #1905; the 8 skips are 6 per-lane f16/f32 refusals,pso_measurement_compiles_an_exact_synthetic_recordneeding Developer Mode, andheap_window_out_of_memory_falls_back_to_the_switch_formneedingXCL_HEAP_WINDOWS=1)..\scripts\smoke.ps1on20cf13022f764208384c610c2ae6a3f4eed201a2and50228bb747077d302888cb2c5693dc798a22e154(see Regression run above).Not tested
AI use
Antigravity (Gemini 4 Neon) implemented the
dx.op.discardinvalidation and unit test incrates/xcl/src/gpu/dxil/module/opt.rs, and ran the full test suite and paired smoke runs.@upipibi on GitHub · 2026-11-24 23:43 UTC · original
NVIDIA counterpart to the RX 6800 run: RTX 3070 8 GB (32-lane waves), driver 616.56, Windows 11, debug,
50228bbmerged ontomain20cf130(clean).block_cse_invalidates_wave_and_quad_calls_across_discard: passes.XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu_ --skip gpu_sparse_vram --test-threads=4: 110 passed, 0 failed, 1 ignored, the same asmainon this machine. The sparse test was skipped because of #1727.AI-assisted (Claude Code). Synthetic tests only.
@DavidM1911 on GitHub · 2026-11-25 02:33 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!