Shader tests: pin IR reachability and PHI invariants #1618

Open
ArnabSaga wants to merge 1 commit from upstream-pr/1619 into main
ArnabSaga commented 2026-11-24 19:52:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ArnabSaga on 2026-11-24T19:52:02Z.


Summary

Adds seven synthetic regression and characterization tests to verify
CFG reachability, SSA construction, and PHI invariants in the shader IR.

During an independent investigation of VIC-BT-002, I found that the
reported failure mechanism does not reproduce on the current baseline.

The GFX10 decoder follows control-flow reachability and does not decode
instructions skipped by unconditional branches. Consequently, the
reported unreachable predecessors do not enter SSA construction through
the proposed failure path.

This PR preserves the existing behavior through targeted tests rather
than introducing an unnecessary production correction.

Coverage

  • Unconditional branches skipping unreachable instructions.
  • Unreachable instruction reads.
  • Multiple skipped predecessors.
  • Reachability after irreducible loop splitting.
  • PHI argument ordering.
  • Trivial PHI elimination.
  • Rejection of reachable branches targeting the program entry.

The shared invariant helper additionally verifies:

  • Reachability of every IR block.
  • Valid successor indices.
  • Predecessor/successor consistency.
  • PHI operand counts.
  • Absence of invalid NONE values.

Verification

Tested against baseline ffe310e:

  • Targeted IR tests, debug: 13 passed.
  • Targeted IR tests, release: 13 passed.
  • Shader library tests: 127 passed, 1 ignored.
  • Changed-file formatting: passed.
  • git diff --check: passed.

A separate bounded investigation of 937,420 synthetic programs
found no panics, unreachable IR blocks, or surviving NONE values
among successful builds.

Scope

  • Test-only changes.
  • One file changed.
  • 213 insertions, zero deletions.
  • No production code changes.
  • No new dependencies.
  • No proprietary game assets or extracted shaders.

Limitations

Verification used Rust 1.98.1 with GNU/MinGW.
MSVC and full workspace CI parity remain unverified.

AI-assisted investigation and testing using synthetic inputs only.

Refs #1242 (VIC-BT-002).

This PR does not claim to fix VIC-BT-002. It adds characterization
coverage for the existing compiler invariants.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6590131770 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1619). Originally posted by [ArnabSaga](https://github.com/ArnabSaga) on 2026-11-24T19:52:02Z. --- ## Summary Adds seven synthetic regression and characterization tests to verify CFG reachability, SSA construction, and PHI invariants in the shader IR. During an independent investigation of VIC-BT-002, I found that the reported failure mechanism does not reproduce on the current baseline. The GFX10 decoder follows control-flow reachability and does not decode instructions skipped by unconditional branches. Consequently, the reported unreachable predecessors do not enter SSA construction through the proposed failure path. This PR preserves the existing behavior through targeted tests rather than introducing an unnecessary production correction. ## Coverage - Unconditional branches skipping unreachable instructions. - Unreachable instruction reads. - Multiple skipped predecessors. - Reachability after irreducible loop splitting. - PHI argument ordering. - Trivial PHI elimination. - Rejection of reachable branches targeting the program entry. The shared invariant helper additionally verifies: - Reachability of every IR block. - Valid successor indices. - Predecessor/successor consistency. - PHI operand counts. - Absence of invalid NONE values. ## Verification Tested against baseline `ffe310e`: - Targeted IR tests, debug: 13 passed. - Targeted IR tests, release: 13 passed. - Shader library tests: 127 passed, 1 ignored. - Changed-file formatting: passed. - `git diff --check`: passed. A separate bounded investigation of 937,420 synthetic programs found no panics, unreachable IR blocks, or surviving NONE values among successful builds. ## Scope - Test-only changes. - One file changed. - 213 insertions, zero deletions. - No production code changes. - No new dependencies. - No proprietary game assets or extracted shaders. ## Limitations Verification used Rust 1.98.1 with GNU/MinGW. MSVC and full workspace CI parity remain unverified. AI-assisted investigation and testing using synthetic inputs only. Refs #1242 (VIC-BT-002). This PR does not claim to fix VIC-BT-002. It adds characterization coverage for the existing compiler invariants.
DenRakEiw commented 2026-11-24 20:02:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T19:56:44Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-shader --lib ir:: — 13 passed, 0 failed (including all new IR reachability and PHI invariant tests)
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean, thorough regression test suite pinning IR reachability, dead-code pruning, irreducible loop splitting, and PHI predecessor ordering invariants. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6046366051 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1619#pullrequestreview-6046366051). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T19:56:44Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-shader --lib ir::` — 13 passed, 0 failed (including all new IR reachability and PHI invariant tests) - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean, thorough regression test suite pinning IR reachability, dead-code pruning, irreducible loop splitting, and PHI predecessor ordering invariants. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-24 21:02:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T20:05:28Z.

Review: APPROVED


Test-only PR pinning IR invariants: assert_well_formed checks reachability, PHI argument/predecessor order, dead-code skipping before IR construction, irreducible-loop splitting and single-value PHI collapse — seven tests, all running on macOS. cargo test -p victory-shader --locked: 103 passed, 0 failed (+7). These guard the exact invariants the lane-mask and loop PRs rely on.

<!-- greyfinch-sync:Marvisak/VIctory:review:6046495722 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1619#pullrequestreview-6046495722). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T20:05:28Z. **Review:** APPROVED --- Test-only PR pinning IR invariants: `assert_well_formed` checks reachability, PHI argument/predecessor order, dead-code skipping before IR construction, irreducible-loop splitting and single-value PHI collapse — seven tests, all running on macOS. `cargo test -p victory-shader --locked`: **103 passed, 0 failed (+7)**. These guard the exact invariants the lane-mask and loop PRs rely on.
Marvisak commented 2026-11-25 02:06:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:32:28Z.


Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/ir.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149664037 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1619#issuecomment-7149664037). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:32:28Z. --- <!-- victory-triage v1 head=1f47ee79d0a364842f2aa98d0182949f7e386921 verdict=needs-rebase at=2026-11-25T01:32:28Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/ir.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Headache3318 commented 2026-11-25 02:06:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-25T01:42:47Z.


Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 1f47ee7 applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 103 passed, 0 failed, 1 ignored. All tests pass, including the 7 new IR reachability/PHI invariants tests.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 2 pre-existing unused-import errors in test code (fail identically on main ccfb029). The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149868408 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1619#issuecomment-7149868408). Originally posted by [Headache3318](https://github.com/Headache3318) on 2026-11-25T01:42:47Z. --- Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head `1f47ee7` applied cleanly onto current `main` `ccfb029`. - `cargo test -p victory-shader --locked`: 103 passed, 0 failed, 1 ignored. All tests pass, including the 7 new IR reachability/PHI invariants tests. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 2 pre-existing unused-import errors in test code (fail identically on main `ccfb029`). The PR introduces no new clippy warnings. Not tested: Windows MSVC build, the title itself. AI-assisted.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1619:upstream-pr/1619'
git switch 'upstream-pr/1619'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1619'
git switch 'upstream-pr/1619'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1619'
git switch 'upstream-pr/1619'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1619'
git switch 'main'
git merge --squash 'upstream-pr/1619'
git switch 'main'
git merge --ff-only 'upstream-pr/1619'
git switch 'main'
git merge 'upstream-pr/1619'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1618
No description provided.