Recompiler: fix trivial phi collapse, 0-pred phis, and chains in recomp::ssa #2148
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!2148
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2148"
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?
@Decodere on GitHub · 2026-11-25 06:18 UTC · original
Decodere:fix-1269-recomp-ssa-braun-bugs→main· +180 −28 · 1 files · 1 commits · openWhat is in it
Fixes four Braun et al. SSA construction bugs in
crates/xcl/src/gpu/recomp/ssa.rs(used byrecomp/lower.rsandrecomp/lower_dxil.rs, where uncollapsed trivial phis breakresolve_value(v)checks againstnum_marker/bit_marker):userstransfer on trivial phi collapse (remove_trivial/replace_phi): Previously,self.users.remove(&phi)dropped every user of a collapsed phi that remained non-trivial at that moment (for example,phi3 = phi(phi2, a)whenphi2collapsed to an unsealed outerphi1). Whenphi1later collapsed toa(or collapsed later in the sameusersloop whenusers[phi2]ordered[phi3, phi1]),phi3was never revisited and remained live as a trivialphi(a, a). Live users (user != phi && user != replacement && self.operands.contains_key(&user)) are now transferred intoself.users[replacement]before cascadingremove_trivial().remove_trivial(replace_phi): When a mutual phi cycle (phi1 = phi(a, phi2)andphi2 = phi(phi1, phi2)) collapsedphi2 -> phi1and cascadedphi1 -> a,remove_trivialreturned the already-replacedsame(phi1) instead ofself.resolve(same)(a). Now returnsself.resolve(replacement).add_operands): Sealing an unsealed block withpreds[block].is_empty()previously left a 0-operand phi live (same == None) instead of replacing it withsink.undef(var).add_operands()now replaces 0-predecessor incomplete phis withsink.undef(var)viareplace_phi()(transferring and cascading any users), and for non-empty predecessors collects all incoming(pred, value)pairs and resolves each value before populatingoperands/usersso a half-populated phi is never exposed to a recursiveremove_trivial()cascade.read):read()previously recursed unconditionally onpreds[block].len() == 1, overflowing the stack on deep straight-line chains and on unreachable sealed 1-predecessor cycles (preds[b] = [b]ora <-> b). Sealed single-predecessor chains are now walked iteratively withHashSetcycle detection, returning and cachingsink.undef(var)on unreachable 1-predecessor cycles.Adds four deterministic pure-CPU regression tests in
gpu::recomp::ssa::testscovering all four bugs.Part of #1269
Tested
Hardware/toolchain: Windows 11 (26200), NVIDIA GeForce RTX 4060 (32-lane waves, driver 621.14), DXC
1.9.2609.5 (01b62ad4), Rust1.100.0.delayed_trivial_phi_collapse_transfers_users:live phis left: [4];mutual_phi_cycle_collapse_returns_resolved_value: returned stale3instead of1;unsealed_zero_pred_block_replaces_incomplete_phi_with_undef:0-pred phi stayed live: [1, 2];sealed_single_pred_cycle_and_deep_chain_do_not_overflow:STATUS_STACK_OVERFLOW0xc00000fd).cargo test --release -p xcl --lib gpu::recomp::ssa::tests::: 10 passed, 0 failed, 0 ignored (pure CPU, CI WARP-safe).cargo test --release -p xcl --lib gpu::recomp::lower::tests:: -- --test-threads=1: 35 passed, 0 failed, 0 ignored.cargo test --release -p xcl --lib gpu::recomp::lower_dxil::tests:: -- --test-threads=1: 18 passed, 0 failed, 0 ignored.cargo build --release --workspace: exit 0.cargo test --release --workspace -- --test-threads=4: 1158 passed, 0 failed, 46 ignored across 21 test suites, with 25 pre-existing runtimeSKIPPEDlines (23 native wave64 / unsupported per-lane lowering skips on 32-lane RTX 4060, 1 Windows driver-cache skip, 1 heap-window skip; 0 new skips).Regression run
Paired 60-second
scripts/smoke.ps1runs on the same retail title build (29640639) from cleanorigin/main(6ea813a) and this branch (a7f059b):Base (
origin/main):PR (
fix-1269-recomp-ssa-braun-bugs):Not tested
recomp::ssais wave-size-independent SSA construction and all new tests are deterministic CPU unit tests).AI use
Drafted with Google Antigravity (Gemini 4 Neon) and verified locally by reproducing all four failures before the fix (including stack overflow on the 1-predecessor cycle/chain test), running
recomp::ssa,recomp::lower,recomp::lower_dxil, and the full release workspace test suite, and completing the paired 60-second smoke run above.@DavidM1911 on GitHub · 2026-11-25 07:05 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.Thanks!
@futurepro62 on GitHub · 2026-11-25 07:03 UTC · original · edited 2026-11-25 07:08 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
a7f059b(on its base6ea813a).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1146 passed, 0 failed, 44 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.delayed_trivial_phi_collapse_transfers_users,mutual_phi_cycle_collapse_returns_resolved_value,unsealed_zero_pred_block_replaces_incomplete_phi_with_undef,sealed_single_pred_cycle_and_deep_chain_do_not_overflow.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1157 passed, 0 failed, 46 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main568e7dbtoo, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.