Shaders: scope DXIL bitcode liveness to reachable blocks and live phi edges #2657

Open
github-bot wants to merge 3 commits from github-bot/gh-2657 into main AGit
Owner

@⁠Moon0755 on GitHub · 2026-11-25 17:39 UTC · original
Moon0755:fix/bitcode-live-reachable-only → main · +267 −31 · 1 files · 3 commits · open

Follow-up to 286a00e ("Shaders: the DXIL writer leaves out what no edge or reader reaches").

Problem

In Module::plan (crates/victory-shader/src/emit/bitcode.rs), Module::live() ran before reachability (seen / post) was computed:

  1. It seeded rooted instructions (Op::Store, Op::AtomicRmw, Op::CmpXchg, side-effecting Op::Call) and b.term branch conditions from every block in self.blocks, including unreachable blocks pruned by constant branches (Module::term).
  2. In the liveness worklist, for_each_operand followed all incoming operands of Op::Phi, including edges from unreachable predecessors (!seen[pred]) that Module::write drops via Plan::edge.

As a result, any pure instruction defined in a reachable block (such as dx.op.createHandleFromHeap, 64-bit integer ops, wave/quad calls, or loads from constant globals) whose only user lived behind an untaken constant branch or on an unreachable phi edge remained marked live = true. That kept dead instructions in emitted reachable blocks, kept stale shader feature flags set in Module::uses (RESOURCE_HEAP, SAMPLER_HEAP, WAVE_OPS, INT64), kept unreferenced constant globals/declarations in Module::kept, and prevented blocks emptied by dead-branch pruning from folding in Module::plan.

Fix

  • Compute reachability (seen, post) in Module::plan before liveness (it depends only on Module::term).
  • Scope Module::live(&self, post: &[usize], seen: &[bool]) to:
    • seed rooted instructions and non-constant self.term(b) branch conditions only from reachable blocks (post), and
    • follow Op::Phi incoming values only from reachable predecessors (seen[pred], matching Plan::edge's self.seen[b] guard so Module::write can never reference an unemitted value).
  • Added 3 unit tests in emit::bitcode::tests:
    • dead_branch_users_do_not_keep_reachable_values_or_flags_alive
    • unreachable_phi_edge_does_not_keep_reachable_value_alive
    • block_emptied_by_dropping_dead_branch_uses_folds

Verification

Verified on windows-latest via GitHub Actions (run 45666234935):

  • cargo clippy -p victory-shader -p xtask --all-targets --locked -- -D warnings — passed
  • cargo clippy -p victory-shader -p xtask --all-targets --all-features --locked -- -D warnings — passed
  • cargo test -p victory-shader -p xtask --locked -- --nocapture — 273 passed; 0 failed; 3 ignored (including all 3 new tests and written_bytes_unchanged), plus xtask 6 passed; 0 failed (repository_passes_policy passed)

— Neon


Update after review (e7de43c)

The text above describes the first commit (973a6ab). DrDarkDK's review showed that seen[pred] is not enough: a predecessor can be reachable while its direct edge to the phi's block is the untaken side of a constant branch. The second commit changes the rule:

  • Module::has_edge(seen, from, to): from is reachable and its simplified terminator names to directly.
  • Module::live follows a phi entry only where has_edge holds for the phi's own block, so a value read only through such a removed edge is no longer kept.
  • Plan::edge is the same predicate, so liveness and the writer cannot disagree about which phi entries exist. This also covers the shape of #2621 and touches the same line as #2622; whichever lands second needs a rebase.
  • Module::kept reads a phi's global operands only through entries that Plan::edge keeps.
  • A fourth test, dropped_direct_phi_edge_from_reachable_pred_does_not_keep_value_alive, runs that shape both with the middle block folded away and with it kept.

Verification of e7de43c: Windows CI on the fork (run 45670122800, clippy in both profiles, victory-shader and xtask tests), this repository's check on the PR, and fuzeofficlal's independent run above (RTX 5090 and WARP with dxil.dll: the four new tests pass; the three failures there are reported as that machine's baseline).

Test helper (d52b05f, after rezioliver-collab's report): live_by_passes, the pass-by-pass liveness the worklist is compared with, still rooted every block and read every phi entry, so the two agreed only on modules with no constant branch. It now follows the same rule by whole passes (blocks reached through the simplified terminators, a phi entry only along an edge that is still there), and the four tests of dropped blocks and edges compare the worklist with it. Windows CI on the fork: run 45684848058, victory-shader 274 passed; 0 failed; 3 ignored.

— Fable

**@⁠Moon0755** on GitHub · 2026-11-25 17:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2657) `Moon0755:fix/bitcode-live-reachable-only` → `main` · +267 −31 · 1 files · 3 commits · open Follow-up to `286a00e` (*"Shaders: the DXIL writer leaves out what no edge or reader reaches"*). ### Problem In `Module::plan` (`crates/victory-shader/src/emit/bitcode.rs`), `Module::live()` ran before reachability (`seen` / `post`) was computed: 1. It seeded rooted instructions (`Op::Store`, `Op::AtomicRmw`, `Op::CmpXchg`, side-effecting `Op::Call`) and `b.term` branch conditions from **every** block in `self.blocks`, including unreachable blocks pruned by constant branches (`Module::term`). 2. In the liveness worklist, `for_each_operand` followed **all** incoming operands of `Op::Phi`, including edges from unreachable predecessors (`!seen[pred]`) that `Module::write` drops via `Plan::edge`. As a result, any pure instruction defined in a **reachable** block (such as `dx.op.createHandleFromHeap`, 64-bit integer ops, wave/quad calls, or loads from constant globals) whose only user lived behind an untaken constant branch or on an unreachable phi edge remained marked `live = true`. That kept dead instructions in emitted reachable blocks, kept stale shader feature flags set in `Module::uses` (`RESOURCE_HEAP`, `SAMPLER_HEAP`, `WAVE_OPS`, `INT64`), kept unreferenced constant globals/declarations in `Module::kept`, and prevented blocks emptied by dead-branch pruning from folding in `Module::plan`. ### Fix - Compute reachability (`seen`, `post`) in `Module::plan` before liveness (it depends only on `Module::term`). - Scope `Module::live(&self, post: &[usize], seen: &[bool])` to: - seed rooted instructions and non-constant `self.term(b)` branch conditions only from reachable blocks (`post`), and - follow `Op::Phi` incoming values only from reachable predecessors (`seen[pred]`, matching `Plan::edge`'s `self.seen[b]` guard so `Module::write` can never reference an unemitted value). - Added 3 unit tests in `emit::bitcode::tests`: - `dead_branch_users_do_not_keep_reachable_values_or_flags_alive` - `unreachable_phi_edge_does_not_keep_reachable_value_alive` - `block_emptied_by_dropping_dead_branch_uses_folds` ### Verification Verified on `windows-latest` via GitHub Actions ([run 45666234935](https://github.com/Moon0755/VIctory/actions/runs/45666234935)): - `cargo clippy -p victory-shader -p xtask --all-targets --locked -- -D warnings` — passed - `cargo clippy -p victory-shader -p xtask --all-targets --all-features --locked -- -D warnings` — passed - `cargo test -p victory-shader -p xtask --locked -- --nocapture` — `273 passed; 0 failed; 3 ignored` (including all 3 new tests and `written_bytes_unchanged`), plus `xtask` `6 passed; 0 failed` (`repository_passes_policy` passed) — Neon --- ### Update after review (`e7de43c`) The text above describes the first commit (`973a6ab`). DrDarkDK's review showed that `seen[pred]` is not enough: a predecessor can be reachable while its direct edge to the phi's block is the untaken side of a constant branch. The second commit changes the rule: - `Module::has_edge(seen, from, to)`: `from` is reachable and its simplified terminator names `to` directly. - `Module::live` follows a phi entry only where `has_edge` holds for the phi's own block, so a value read only through such a removed edge is no longer kept. - `Plan::edge` is the same predicate, so liveness and the writer cannot disagree about which phi entries exist. This also covers the shape of #2621 and touches the same line as #2622; whichever lands second needs a rebase. - `Module::kept` reads a phi's global operands only through entries that `Plan::edge` keeps. - A fourth test, `dropped_direct_phi_edge_from_reachable_pred_does_not_keep_value_alive`, runs that shape both with the middle block folded away and with it kept. Verification of `e7de43c`: Windows CI on the fork ([run 45670122800](https://github.com/Moon0755/VIctory/actions/runs/45670122800), clippy in both profiles, `victory-shader` and `xtask` tests), this repository's `check` on the PR, and fuzeofficlal's independent run above (RTX 5090 and WARP with `dxil.dll`: the four new tests pass; the three failures there are reported as that machine's baseline). Test helper (`d52b05f`, after rezioliver-collab's report): `live_by_passes`, the pass-by-pass liveness the worklist is compared with, still rooted every block and read every phi entry, so the two agreed only on modules with no constant branch. It now follows the same rule by whole passes (blocks reached through the simplified terminators, a phi entry only along an edge that is still there), and the four tests of dropped blocks and edges compare the worklist with it. Windows CI on the fork: [run 45684848058](https://github.com/Moon0755/VIctory/actions/runs/45684848058), `victory-shader` `274 passed; 0 failed; 3 ignored`. — Fable
`live_by_passes` still rooted every block and read every phi entry, so
it agreed with the worklist only on modules with no constant branch.
It now reaches blocks by the simplified terminators and reads a phi
entry only along an edge that is still there, and the four tests of
dropped blocks and edges compare the worklist with it.

Reported by rezioliver-collab on the pull request.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:11:22 +00:00
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-25 17:50 UTC · original

seen[pred] can still keep a phi operand when the predecessor is reachable and its edge to the phi’s block was removed. The shape from #2622 gives a concrete case:

  • entry: CondBr(true, empty, join)
  • empty: Br(join)
  • join: phi [(one, empty), (only_for_dead_edge, entry)]

If only_for_dead_edge is a pure instruction defined in entry, liveness keeps it because seen[entry] is true. With #2622’s edge check, the writer drops that phi input while still emitting its unused producer.

Could liveness check whether the predecessor’s simplified terminator targets the phi’s block? Adding this case would complement the unreachable-predecessor test.

Static review only.

AI-assisted with Codex.

**@⁠DrDarkDK** on GitHub · 2026-11-25 17:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2657#issuecomment-7170067202) `seen[pred]` can still keep a phi operand when the predecessor is reachable and its edge to the phi’s block was removed. The shape from #2622 gives a concrete case: - `entry: CondBr(true, empty, join)` - `empty: Br(join)` - `join: phi [(one, empty), (only_for_dead_edge, entry)]` If `only_for_dead_edge` is a pure instruction defined in `entry`, liveness keeps it because `seen[entry]` is true. With #2622’s edge check, the writer drops that phi input while still emitting its unused producer. Could liveness check whether the predecessor’s simplified terminator targets the phi’s block? Adding this case would complement the unreachable-predecessor test. Static review only. *AI-assisted with Codex.*
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 17:54 UTC · original

Reviewed: scoping live() to post-order-reachable blocks and marking phi operands only along seen[pred] edges is correct — a value feeding a dead phi edge no longer survives, which is exactly what drops the unread descriptor-word queries. The worklist-per-instruction property is preserved. Pairs naturally with #2622's dead-edge phi cleanup. CI green.

**@⁠kotekompotek** on GitHub · 2026-11-25 17:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2657#issuecomment-7170174719) Reviewed: scoping `live()` to post-order-reachable blocks and marking phi operands only along `seen[pred]` edges is correct — a value feeding a dead phi edge no longer survives, which is exactly what drops the unread descriptor-word queries. The worklist-per-instruction property is preserved. Pairs naturally with #2622's dead-edge phi cleanup. CI green.
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-25 17:58 UTC · original

Independent Windows verification of PR #2657 (head 973a6ab), Rust/Cargo 1.100.0 MSVC, synthetic tests only, no game data, no source edits. This complements the existing static review on the PR.

  • cargo test --locked -p victory-shader --lib emit::bitcode::tests -- --test-threads=1 on the PR head: 15 passed, 0 failed, 1 ignored (benchmark), 260 filtered. The three new tests pass: dead_branch_users_do_not_keep_reachable_values_or_flags_alive, unreachable_phi_edge_does_not_keep_reachable_value_alive, block_emptied_by_dropping_dead_branch_uses_folds.
  • Negative control on merge base 13f91ca with the same filter: 12 passed, 1 ignored; the three new tests are absent.

No competing implementation or PR. AI-assisted (Hy4 flash).

**@⁠cloph-dsp** on GitHub · 2026-11-25 17:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2657#issuecomment-7170264454) Independent Windows verification of PR #2657 (head `973a6ab`), Rust/Cargo 1.100.0 MSVC, synthetic tests only, no game data, no source edits. This complements the existing static review on the PR. - `cargo test --locked -p victory-shader --lib emit::bitcode::tests -- --test-threads=1` on the PR head: **15 passed**, 0 failed, 1 ignored (benchmark), 260 filtered. The three new tests pass: `dead_branch_users_do_not_keep_reachable_values_or_flags_alive`, `unreachable_phi_edge_does_not_keep_reachable_value_alive`, `block_emptied_by_dropping_dead_branch_uses_folds`. - Negative control on merge base `13f91ca` with the same filter: **12 passed**, 1 ignored; the three new tests are absent. No competing implementation or PR. AI-assisted (Hy4 flash).
Author
Owner

@⁠Moon0755 on GitHub · 2026-11-25 18:00 UTC · original

Thank you @DrDarkDK — that is exactly the gap: seen[pred] only says the predecessor is reachable, not that its edge to the phi's block survived the constant branch.

Fixed in e7de43c:

  • New Module::has_edge(seen, from, to): from is reachable and its simplified terminator directly targets to.
  • Module::live now follows a phi entry only through has_edge (it records each phi's owning block while walking the reachable blocks).
  • Plan::edge (what Module::write uses) goes through the same check, so liveness and the writer can no longer disagree about which entries exist. That is the same edge fix as in #2622 (successors(..).contains(&x) instead of resolving through folded blocks), which is what makes the entry: CondBr(true, empty, join) / empty: Br(join) shape correct.
  • Module::kept reads a phi's global operands only through kept entries.
  • New test dropped_direct_phi_edge_from_reachable_pred_does_not_keep_value_alive covers both your shape (the middle block folds away: plan.fold[mid] == Some((entry, join))) and the non-folded one; the producers in entry are not live, uses() is empty and write() succeeds.

Windows CI (Clippy both profiles, victory-shader, xtask): https://github.com/Moon0755/VIctory/actions/runs/45670122800

— Neon

**@⁠Moon0755** on GitHub · 2026-11-25 18:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2657#issuecomment-7170297046) Thank you `@DrDarkDK` — that is exactly the gap: `seen[pred]` only says the predecessor is reachable, not that its edge to the phi's block survived the constant branch. Fixed in e7de43c: - New `Module::has_edge(seen, from, to)`: `from` is reachable **and** its simplified terminator directly targets `to`. - `Module::live` now follows a phi entry only through `has_edge` (it records each phi's owning block while walking the reachable blocks). - `Plan::edge` (what `Module::write` uses) goes through the same check, so liveness and the writer can no longer disagree about which entries exist. That is the same edge fix as in #2622 (`successors(..).contains(&x)` instead of resolving through folded blocks), which is what makes the `entry: CondBr(true, empty, join)` / `empty: Br(join)` shape correct. - `Module::kept` reads a phi's global operands only through kept entries. - New test `dropped_direct_phi_edge_from_reachable_pred_does_not_keep_value_alive` covers both your shape (the middle block folds away: `plan.fold[mid] == Some((entry, join))`) and the non-folded one; the producers in `entry` are not live, `uses()` is empty and `write()` succeeds. Windows CI (Clippy both profiles, `victory-shader`, `xtask`): https://github.com/Moon0755/VIctory/actions/runs/45670122800 — Neon
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 18:23 UTC · original

Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP + dxil.dll verification and code review of e7de43cb (on 13f91ca):

Verification (rustc 1.98.1 MSVC, Windows SDK 10.0.26100.0 dxil.dll)

  • cargo test --locked -p victory-shader --lib emit::bitcode::tests -- --nocapture: 16 passed, 0 failed, 1 ignored (bench_write); all 4 new bitcode tests pass (including dropped_direct_phi_edge_from_reachable_pred_does_not_keep_value_alive).
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings: 0 warnings.
  • cargo clippy --locked -p victory-shader --all-targets --features host -- -D warnings: 0 warnings.
  • cargo test --locked -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index (runs both hardware RTX 5090 and WARP with dxil.dll validation active, zero skipped validations): 270 passed, 3 failed, 3 ignored. The 3 failures are the pre-existing RTX 5090 baseline mismatches (a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, gathers_at_a_level_match_the_hardware), and heap_direct_texture_reads_mark_their_heap_index is the pre-existing RTX 5090 0xc0000005 baseline crash (#2571); WARP and dxil.dll validation had 0 failures.

Code review notes

  • Module::has_edge cleanly addresses the dropped-direct-edge case from a reachable predecessor across Module::live, Plan::edge, and Module::kept, so values and constant V::Global arrays only reachable via folded-out CondBr phi edges are pruned without breaking SSA IDs or dxil.dll usage-flag checks.
  • Empty-block folding and multi-hop empty chains (entry -> empty1 -> empty2 -> join) keep has_edge(empty2, join) true and rewrite phi sources via plan.src(...) consistently.
  • Note for merge ordering: e7de43cb touches the same Plan::edge line as #2622 and is a strict superset of #2622 for #2621 (since it also scopes Module::live and Module::kept with the same has_edge predicate).
**@⁠fuzeofficlal** on GitHub · 2026-11-25 18:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2657#issuecomment-7170841460) Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP + `dxil.dll` verification and code review of `e7de43cb` (on `13f91ca`): ### Verification (`rustc 1.98.1` MSVC, Windows SDK `10.0.26100.0` `dxil.dll`) - `cargo test --locked -p victory-shader --lib emit::bitcode::tests -- --nocapture`: **16 passed, 0 failed, 1 ignored** (`bench_write`); all 4 new bitcode tests pass (including `dropped_direct_phi_edge_from_reachable_pred_does_not_keep_value_alive`). - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings`: **0 warnings**. - `cargo clippy --locked -p victory-shader --all-targets --features host -- -D warnings`: **0 warnings**. - `cargo test --locked -p victory-shader --lib -- --skip heap_direct_texture_reads_mark_their_heap_index` (runs both hardware RTX 5090 and WARP with `dxil.dll` validation active, zero skipped validations): **270 passed, 3 failed, 3 ignored**. The 3 failures are the pre-existing RTX 5090 baseline mismatches (`a_heap_buffer_read_by_element_takes_the_views_stride`, `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `gathers_at_a_level_match_the_hardware`), and `heap_direct_texture_reads_mark_their_heap_index` is the pre-existing RTX 5090 `0xc0000005` baseline crash (#2571); WARP and `dxil.dll` validation had 0 failures. ### Code review notes - `Module::has_edge` cleanly addresses the dropped-direct-edge case from a reachable predecessor across `Module::live`, `Plan::edge`, and `Module::kept`, so values and constant `V::Global` arrays only reachable via folded-out `CondBr` phi edges are pruned without breaking SSA IDs or `dxil.dll` usage-flag checks. - Empty-block folding and multi-hop empty chains (`entry -> empty1 -> empty2 -> join`) keep `has_edge(empty2, join)` true and rewrite phi sources via `plan.src(...)` consistently. - Note for merge ordering: `e7de43cb` touches the same `Plan::edge` line as #2622 and is a strict superset of #2622 for #2621 (since it also scopes `Module::live` and `Module::kept` with the same `has_edge` predicate).
Author
Owner

@⁠rezioliver-collab on GitHub · 2026-11-25 19:20 UTC · original

On e7de43cb, we reproduced the difference between m.plan().live and the test helper live_by_passes on an M1 Mac with Rust 1.98.1. The PR's worklist gives the correct result in both runs.

We built the same three-block module twice, changing only the boolean literal TAKE_DIRECT.

entry: sum = add i32 1, 2
       branch TAKE_DIRECT ? join : via
via:   branch join
join:  value = phi [sum, entry], [1, via]
       sink(value)
       return
TAKE_DIRECT Value selected by phi Worklist marks sum live live_by_passes marks sum live
true 3 yes yes
false 1 no yes

With false, all three blocks are reachable, but the direct entry → join edge is gone. The phi takes 1 from via, so nothing reads sum. The old helper follows both phi inputs and keeps the add alive. Both algorithms keep the phi and the sink call. This is a concrete case the existing worklist_liveness_matches_passes test misses.

We ran bitcode.rs directly with rustc --test because three unrelated tests reference the Windows-only DXIL validator. All 16 existing module tests passed (one benchmark ignored). Only the added equality check failed, on the false case.

**@⁠rezioliver-collab** on GitHub · 2026-11-25 19:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2657#issuecomment-7172166145) On `e7de43cb`, we reproduced the difference between `m.plan().live` and the test helper `live_by_passes` on an M1 Mac with Rust 1.98.1. The PR's worklist gives the correct result in both runs. We built the same three-block module twice, changing only the boolean literal `TAKE_DIRECT`. ```text entry: sum = add i32 1, 2 branch TAKE_DIRECT ? join : via via: branch join join: value = phi [sum, entry], [1, via] sink(value) return ``` | TAKE_DIRECT | Value selected by phi | Worklist marks sum live | live_by_passes marks sum live | |---|---:|---|---| | true | 3 | yes | yes | | false | 1 | no | yes | With `false`, all three blocks are reachable, but the direct `entry → join` edge is gone. The phi takes `1` from `via`, so nothing reads `sum`. The old helper follows both phi inputs and keeps the add alive. Both algorithms keep the phi and the sink call. This is a concrete case the existing `worklist_liveness_matches_passes` test misses. We ran `bitcode.rs` directly with `rustc --test` because three unrelated tests reference the Windows-only DXIL validator. All 16 existing module tests passed (one benchmark ignored). Only the added equality check failed, on the `false` case.
Author
Owner

@⁠Moon0755 on GitHub · 2026-11-25 19:28 UTC · original

Thank you, that is a real gap in the tests. live_by_passes still rooted every block and read every phi entry, so it agreed with the worklist only on modules with no constant branch. d52b05f makes it follow the same rule by whole passes (blocks reached through the simplified terminators, a phi entry only along an edge that is still there), and the four tests of dropped blocks and edges now compare the worklist with it, your shape among them.

Verification: Windows CI on the fork, run 45684848058: clippy in both profiles, victory-shader 274 passed; 0 failed; 3 ignored, xtask 6 passed. Tests only; the liveness code is as it was at e7de43c.

— Fable

**@⁠Moon0755** on GitHub · 2026-11-25 19:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2657#issuecomment-7172340283) Thank you, that is a real gap in the tests. `live_by_passes` still rooted every block and read every phi entry, so it agreed with the worklist only on modules with no constant branch. `d52b05f` makes it follow the same rule by whole passes (blocks reached through the simplified terminators, a phi entry only along an edge that is still there), and the four tests of dropped blocks and edges now compare the worklist with it, your shape among them. Verification: Windows CI on the fork, [run 45684848058](https://github.com/Moon0755/VIctory/actions/runs/45684848058): clippy in both profiles, `victory-shader` `274 passed; 0 failed; 3 ignored`, `xtask` `6 passed`. Tests only; the liveness code is as it was at `e7de43c`. — Fable
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:20 UTC · original

Automated triage for the maintainers.

Merge candidate. In crates/victory-shader/src/emit/bitcode.rs, Module::plan now computes reachability before Module::live. Liveness then roots only reachable blocks, uses the simplified terminator for branch conditions, and follows a phi entry only along an edge that still exists (Module::has_edge). Plan::edge and Module::kept use the same predicate, so liveness and the writer cannot disagree. Pure values used only behind untaken constant branches (and the INT64/WAVE/heap flags and globals they pull in) are no longer emitted. I checked that dropping the to() mapping from Plan::edge is equivalent for phis whose entries name real predecessors (a fold that would create a second edge is already refused in plan), and that the pass-based reference in the tests now follows the same rule. It merges cleanly; CI check: passing.

Overlap: #2622 changes the same Plan::edge line for a subset of this fix. Whichever lands second needs a rebase, and #2622 may then be unnecessary.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2657#issuecomment-7176246698) <!-- victory-triage v1 head=d52b05f70f2fa02f5b48bd86082b6d7aa6ad2b79 verdict=merge-candidate at=2026-11-25T22:20:40Z --> Automated triage for the maintainers. **Merge candidate.** In `crates/victory-shader/src/emit/bitcode.rs`, `Module::plan` now computes reachability before `Module::live`. Liveness then roots only reachable blocks, uses the simplified terminator for branch conditions, and follows a phi entry only along an edge that still exists (`Module::has_edge`). `Plan::edge` and `Module::kept` use the same predicate, so liveness and the writer cannot disagree. Pure values used only behind untaken constant branches (and the INT64/WAVE/heap flags and globals they pull in) are no longer emitted. I checked that dropping the `to()` mapping from `Plan::edge` is equivalent for phis whose entries name real predecessors (a fold that would create a second edge is already refused in `plan`), and that the pass-based reference in the tests now follows the same rule. It merges cleanly; CI `check`: passing. Overlap: #2622 changes the same `Plan::edge` line for a subset of this fix. Whichever lands second needs a rebase, and #2622 may then be unnecessary. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠KainanP on GitHub · 2026-11-25 22:53 UTC · original

Measured against #2622 with an end-to-end repro (validator plus draws on RTX 4060, Intel UHD and WARP). The repro and #2622's test pass, with no regressions, also on f3578e38. The comparison suggests landing #2622 first, then this one as the liveness change: #2621 (AI-assisted)

**@⁠KainanP** on GitHub · 2026-11-25 22:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/2657#issuecomment-7176915422) Measured against #2622 with an end-to-end repro (validator plus draws on RTX 4060, Intel UHD and WARP). The repro and #2622's test pass, with no regressions, also on `f3578e38`. The comparison suggests landing #2622 first, then this one as the liveness change: https://git.gtahub.st/github/Marvisak--VIctory/issues/2621 (AI-assisted)
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2657/head:github-bot/gh-2657'
git switch 'github-bot/gh-2657'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2657'
git switch 'github-bot/gh-2657'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2657'
git switch 'github-bot/gh-2657'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2657'
git switch 'main'
git merge --squash 'github-bot/gh-2657'
git switch 'main'
git merge --ff-only 'github-bot/gh-2657'
git switch 'main'
git merge 'github-bot/gh-2657'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2657
No description provided.