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

Merged
alexballvideos-netizen merged 1 commit from upstream-pr/373 into main 2026-11-27 16:04:48 +00:00
alexballvideos-netizen commented 2026-11-27 14:31:09 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by alexballvideos-netizen on 2026-11-27T14:31:09Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5528323479 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/373). Originally posted by [alexballvideos-netizen](https://github.com/alexballvideos-netizen) on 2026-11-27T14:31:09Z. --- 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.
LakshanSivakumar commented 2026-11-27 16:05:19 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:05:19Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7222841107 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/373#issuecomment-7222841107). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T16:05:19Z. --- 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.
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
LakshanSivakumar/Native-Victory-macOS!373
No description provided.