shader: an execz skip's edge needs nothing from a join relayed by a jump to an AND with EXEC #376

Manually merged
github merged 1 commit from github-bot/gh-373 into main 2026-11-27 16:13:16 +00:00 AGit
Owner

@⁠alexballvideos-netizen on GitHub · 2026-11-27 14:31 UTC · original
alexballvideos-netizen:shader-execz-relay → main · +193 −28 · 4 files · 1 commits · merged 2026-11-27 16:04 UTC

Refs #258

Makes compute d3ff71633430b06d translate. It was refused as "a lane-mask join of an untracked mask: a value the translation could not make"; the maintainer listed it as open next to the tile classifier on #258.

Cause. #304 (78cd3fed, 4cdcbad7) taught Lower::unneeded_edges that an execz-taken edge brings an empty EXEC. So a join read only by AND, NAND or ORN2 with EXEC needs nothing from that edge.

In d3ff the join isn't read in its own block:

  • Its value goes through an unconditional jump into the next block, which the outer if's execz also targets.
  • It is ANDed with EXEC there.
  • The fixpoint kept the edge, because the next block's phi is needed from its other predecessor.
  • On the skip edge, the value is a dword of a constant-buffer descriptor (Val::Missing).

Change (lower.rs, unneeded_edges). A use at the relayed phi is satisfied when all of these hold:

  • The join block ends in Jump to the phi's block.
  • The register isn't EXEC.
  • The relayed value feeds no further phi.
  • Every read of it is in that block and keeps EXEC (AND, NAND, ORN2 with EXEC; never ANDN2).
  • The EXEC each read uses, resolved back through both phis, is the value the execz skip compared with 0.

The execz pattern and the keeps-EXEC classification are now shared closures, with unchanged semantics. It is sound for the same reason as #304: AND, NAND or ORN2 with an empty EXEC doesn't depend on the other operand. It is one hop only.

Tests (synthetic words only):

  • gfx_refusal_tests:
    • a_join_relayed_by_a_jump_and_read_only_with_exec_needs_nothing_from_an_exec_skip: refused without the fix ("GFX10 code at 0x44: … data whose high dword is not known"); translates with it.
    • Negatives that stay refused: a_relay_block_that_rewrites_exec_still_needs_the_data and a_wave64_relay_skip_on_exec_lo_alone_does_not_make_an_edge_unneeded.
  • split_wave_tests::a_mask_relayed_by_a_jump_and_read_only_with_exec_is_its_lanes_in_lockstep: values on Metal for flag 40, 4 and 0.
    • It fails without the fix (refusal) and passes with it.
    • I checked locally that run() returns data and doesn't take the empty early return.

Corpus by output (my own dump, 21,579 shaders, tools/corpus/compare.sh, origin/main 728845d1 vs this branch):

  • newly translated: 1 (compute d3ff71633430b06d)
  • REGRESSIONS: 0; other reason now: 0
  • output changed: 4 compute (0b1eea61bf55c5da, 1c98cf7eea2518d1, 8476c76e7329d51e, 995d5275c8bbdf04).
    • In each, the relay rule applies one jump before an s_and_b64 s, s, exec behind an execz.
    • Through the fixpoint, that makes one earlier join edge unneeded.
    • That edge's value used to be lowered as a lane bit of an I32 that only the empty-EXEC AND reads. It is now the constant false: same behaviour, different DXIL.

Checks.

  • cargo test -p victory-shader: 375 passed.
  • -p victory-hle -p victory -p victory-gpu -p xtask all passed, except native_probe, which needs the Windows cross tools I don't have installed (same on main).
  • Windows clippy gate: clean. cargo xtask policy: ok.

Game run. M3 Max, 36 GB, macOS 27.2.1, Series X, headless, 240 s.

  • d3ff is bound at world entry (frame 2384) with no refusal and no Metal compile error.
  • It was dropped once in its first present, while its pipeline compiled off the frame thread, and not after that.
  • No crash, ran to the timer.
  • I haven't measured its effect on the tile classes or the picture.

Docs: one sentence added to the 78cd3fed paragraph in docs/native-host.md.

**@⁠alexballvideos-netizen** on GitHub · 2026-11-27 14:31 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/373) `alexballvideos-netizen:shader-execz-relay` → `main` · +193 −28 · 4 files · 1 commits · merged 2026-11-27 16:04 UTC Refs #258 Makes `compute d3ff71633430b06d` translate. It was refused as "a lane-mask join of an untracked mask: a value the translation could not make"; the maintainer listed it as open next to the tile classifier on #258. **Cause.** #304 (78cd3fed, 4cdcbad7) taught `Lower::unneeded_edges` that an execz-taken edge brings an empty EXEC. So a join read only by AND, NAND or ORN2 with EXEC needs nothing from that edge. In d3ff the join isn't read in its own block: - Its value goes through an unconditional jump into the next block, which the outer if's execz also targets. - It is ANDed with EXEC there. - The fixpoint kept the edge, because the next block's phi is needed from its other predecessor. - On the skip edge, the value is a dword of a constant-buffer descriptor (`Val::Missing`). **Change** (lower.rs, `unneeded_edges`). A use at the relayed phi is satisfied when all of these hold: - The join block ends in `Jump` to the phi's block. - The register isn't EXEC. - The relayed value feeds no further phi. - Every read of it is in that block and keeps EXEC (AND, NAND, ORN2 with EXEC; never ANDN2). - The EXEC each read uses, resolved back through both phis, is the value the execz skip compared with 0. The execz pattern and the keeps-EXEC classification are now shared closures, with unchanged semantics. It is sound for the same reason as #304: AND, NAND or ORN2 with an empty EXEC doesn't depend on the other operand. It is one hop only. **Tests** (synthetic words only): - `gfx_refusal_tests`: - `a_join_relayed_by_a_jump_and_read_only_with_exec_needs_nothing_from_an_exec_skip`: refused without the fix ("GFX10 code at 0x44: … data whose high dword is not known"); translates with it. - Negatives that stay refused: `a_relay_block_that_rewrites_exec_still_needs_the_data` and `a_wave64_relay_skip_on_exec_lo_alone_does_not_make_an_edge_unneeded`. - `split_wave_tests::a_mask_relayed_by_a_jump_and_read_only_with_exec_is_its_lanes_in_lockstep`: values on Metal for flag 40, 4 and 0. - It fails without the fix (refusal) and passes with it. - I checked locally that `run()` returns data and doesn't take the empty early return. **Corpus by output** (my own dump, 21,579 shaders, `tools/corpus/compare.sh`, origin/main 728845d1 vs this branch): - newly translated: 1 (compute `d3ff71633430b06d`) - REGRESSIONS: 0; other reason now: 0 - output changed: 4 compute (`0b1eea61bf55c5da`, `1c98cf7eea2518d1`, `8476c76e7329d51e`, `995d5275c8bbdf04`). - In each, the relay rule applies one jump before an `s_and_b64 s, s, exec` behind an execz. - Through the fixpoint, that makes one earlier join edge unneeded. - That edge's value used to be lowered as a lane bit of an I32 that only the empty-EXEC AND reads. It is now the constant false: same behaviour, different DXIL. **Checks.** - `cargo test -p victory-shader`: 375 passed. - `-p victory-hle -p victory -p victory-gpu -p xtask` all passed, except `native_probe`, which needs the Windows cross tools I don't have installed (same on main). - Windows clippy gate: clean. `cargo xtask policy`: ok. **Game run.** M3 Max, 36 GB, macOS 27.2.1, Series X, headless, 240 s. - d3ff is bound at world entry (frame 2384) with no refusal and no Metal compile error. - It was dropped once in its first present, while its pipeline compiled off the frame thread, and not after that. - No crash, ran to the timer. - I haven't measured its effect on the tile classes or the picture. Docs: one sentence added to the 78cd3fed paragraph in docs/native-host.md.
Lower::unneeded_edges already treats an execz-taken edge as bringing an empty
EXEC when the join value is read only by AND, NAND or ORN2 with EXEC (#304).
It now follows the value through one unconditional jump into the next block's
phi when every read there keeps EXEC and that EXEC, resolved back through both
phis, is the one the skip found empty. The register must not be EXEC, the
relayed value must feed no further join, and a relay block that rewrites EXEC
or a wave64 skip on exec_lo alone stays refused.

Makes compute d3ff71633430b06d translate (#258).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 14:34:11 +00:00
github manually merged commit 98fcc52cee into main 2026-11-27 16:13:16 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-27 16:05 UTC · original

Merged in be7dc1b5 with the other shader PRs from tonight. Ran the tests (native arm64), Windows clippy, the policy check and a release build on the merged tree, and swept my full corpus of 21,600 shaders before and after: 0 lost, 352 newly translated, every changed output accounted for. I have not run the game on it yet. It was still a draft; I merged it because the change is complete and the corpus shows no losses. Thanks.

**@⁠LakshanSivakumar** on GitHub · 2026-11-27 16:05 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/373#issuecomment-7222841107) Merged in be7dc1b5 with the other shader PRs from tonight. Ran the tests (native arm64), Windows clippy, the policy check and a release build on the merged tree, and swept my full corpus of 21,600 shaders before and after: 0 lost, 352 newly translated, every changed output accounted for. I have not run the game on it yet. It was still a draft; I merged it because the change is complete and the corpus shows no losses. Thanks.
This discussion has been locked. Commenting is limited to contributors.
No description provided.