Repository navigation
Conversation
…mp::ssa Fix four Braun et al. SSA construction bugs in crates/xcl/src/gpu/recomp/ssa.rs: - User transfer on trivial phi collapse: transfer still-live users of a collapsed phi into users[replacement] before cascading remove_trivial(), so phis that stay live temporarily (or sit earlier in users[phi] when replacement collapses during the same cascade) are revisited when replacement later collapses. - Resolved return value: return self.resolve(replacement) from replace_phi() / remove_trivial() so mutual phi-cycle collapses never return an already replaced phi handle. - Unsealed 0-predecessor blocks and complete operand registration: in add_operands(), replace an incomplete phi at a 0-predecessor block with sink.undef(var) (and cascade its users) instead of leaving a malformed 0-operand phi; otherwise collect all incoming (pred, value) pairs before populating operands/users (resolving each value) so a half-populated phi is never exposed to a recursive remove_trivial() cascade. - Iterative single-predecessor chains: walk sealed 1-predecessor chains iteratively with cycle detection in read(), terminating unreachable 1-pred cycles with sink.undef(var) and avoiding stack overflow on deep chains. Part of xcl-dev#1269 Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
Contributor
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
rootw0rm
pushed a commit
to rootw0rm/xcl
that referenced
this pull request
Nov 25, 2026
… in ssa Braun-SSA soundness fixes in recomp/ssa.rs, verbatim from upstream head a7f059b: transfer live users into users[replacement] in replace_phi before cascading; return resolve(replacement) instead of the stale phi; 0-predecessor incomplete phis become sink.undef via replace_phi and incoming values are collected/resolved before operands/users register; sealed 1-predecessor chains walked iteratively with cycle detection (unreachable cycles get undef). Adds the four upstream regression tests verbatim (all fail pre-fix; cycle/chain case overflows pre-fix).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What 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.