shader: track kept lanes and partial bits across guarded writes #293

Open
gagarinyury wants to merge 5 commits from upstream-pr/293 into main
gagarinyury commented 2026-11-27 09:06:42 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by gagarinyury on 2026-11-27T09:06:42Z.


What this changes

Refs #256

Implements lane-aware tracking for guarded and partial VGPR writes (write_placed, place_bits, write_half, v_fma_mix*, and guarded ds_*) so inactive/unwritten bits of a missing value or phi are not silently turned into 0 when a reader can still observe them:

  • kept_old_of / get_val(..., genuine) separate kept old-value preservation from genuine source reads
  • resolve_kept_and_live_edges replaces live_edges, propagating (reach, !guard_write) constraints backward from genuine kept_reads (widened for quad/wave cross-lane and implicit-LOD texture reads) into phi_at or direct Val::Missing refusals
  • Partial 16-bit writes preserving high bits keep low16_src reads working while refusing reads of the full dword or kept bits
  • Pixel WQM helper-lane reads (safe_wqm_helper_read) are kept accepted only when forward SSA uses cannot reach quad/wave/implicit-LOD ops, discards/branches, or unmasked exports/stores

Win-back rules analysis (Help wanted in #256)

  • Rule 1 (quad DPP readers under a quad-uniform guard): counter-example (win_back_counterexamples_issue_256::rule1). A per-lane guarded write (c2) followed by s_wqm gives a quad-uniform reader guard Quad(c2); a c2 lane reads 0 instead of old from its !c2 neighbor in the same quad.
  • Rule 2 (helper lanes in WQM reading what only real pixels wrote): counter-example in general (rule2) when helper values flow into quad_perm / ds_swizzle / implicit-LOD image_sample; sound only under the restricted forward-sink proof in safe_wqm_helper_read (rule2_safe).

How it was tested

  • cargo clippy --no-deps -j 2 -p victory-shader --all-targets --locked -- -D warnings (passed)
  • cargo test -j 2 -p victory-shader --locked -- --test-threads=2 (313 passed; 0 failed; 3 ignored benchmarks)
  • cargo xtask policy (asset policy: 369 files ok)
  • cargo test -j 2 -p victory-gpu --lib split_wave_tests -- --test-threads=2 (34 passed; 0 failed)
  • cargo test -j 2 -p victory-gpu --lib shader_tests -- --test-threads=2 (6 passed; 0 failed)

Note: hardware Metal execution tests skip locally because Metal Shader Converter is not installed; corpus fingerprint comparison has not been run locally yet.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5524023425 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/293). Originally posted by [gagarinyury](https://github.com/gagarinyury) on 2026-11-27T09:06:42Z. --- ## What this changes Refs #256 Implements lane-aware tracking for guarded and partial VGPR writes (`write_placed`, `place_bits`, `write_half`, `v_fma_mix*`, and guarded `ds_*`) so inactive/unwritten bits of a missing value or phi are not silently turned into `0` when a reader can still observe them: - `kept_old_of` / `get_val(..., genuine)` separate kept old-value preservation from genuine source reads - `resolve_kept_and_live_edges` replaces `live_edges`, propagating `(reach, !guard_write)` constraints backward from genuine `kept_reads` (widened for quad/wave cross-lane and implicit-LOD texture reads) into `phi_at` or direct `Val::Missing` refusals - Partial 16-bit writes preserving high bits keep `low16_src` reads working while refusing reads of the full dword or kept bits - Pixel WQM helper-lane reads (`safe_wqm_helper_read`) are kept accepted only when forward SSA uses cannot reach quad/wave/implicit-LOD ops, discards/branches, or unmasked exports/stores ### Win-back rules analysis (`Help wanted` in #256) - **Rule 1 (quad DPP readers under a quad-uniform guard):** counter-example (`win_back_counterexamples_issue_256::rule1`). A per-lane guarded write (`c2`) followed by `s_wqm` gives a quad-uniform reader guard `Quad(c2)`; a `c2` lane reads `0` instead of `old` from its `!c2` neighbor in the same quad. - **Rule 2 (helper lanes in WQM reading what only real pixels wrote):** counter-example in general (`rule2`) when helper values flow into `quad_perm` / `ds_swizzle` / implicit-LOD `image_sample`; sound only under the restricted forward-sink proof in `safe_wqm_helper_read` (`rule2_safe`). ## How it was tested - `cargo clippy --no-deps -j 2 -p victory-shader --all-targets --locked -- -D warnings` (passed) - `cargo test -j 2 -p victory-shader --locked -- --test-threads=2` (`313 passed; 0 failed; 3 ignored` benchmarks) - `cargo xtask policy` (`asset policy: 369 files ok`) - `cargo test -j 2 -p victory-gpu --lib split_wave_tests -- --test-threads=2` (`34 passed; 0 failed`) - `cargo test -j 2 -p victory-gpu --lib shader_tests -- --test-threads=2` (`6 passed; 0 failed`) Note: hardware Metal execution tests skip locally because Metal Shader Converter is not installed; corpus fingerprint comparison has not been run locally yet.
LakshanSivakumar commented 2026-11-27 10:32:32 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T10:32:32Z.


Thank you. Showing with counter-examples why two of the "win-back" rules are unsound is what #256 needed.

Before it can merge:

  1. Your workflow has not run; it needs my approval.
  2. The comparison by output over a corpus. This change refuses more, so I need how many shaders that translate today it refuses, per stage, and how many of those the game binds in a world run. I will run it on my corpus and post the table; I have not done it yet.
  3. The wrong accept in #256 needs a test with values on Metal. Please ask someone who has the converter to run it, or run it yourself.
  4. It touches the same file as #261, #271 and #302, so expect conflicts. The branch is behind main.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7216009184 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/293#issuecomment-7216009184). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T10:32:32Z. --- Thank you. Showing with counter-examples why two of the "win-back" rules are unsound is what #256 needed. Before it can merge: 1. Your workflow has not run; it needs my approval. 2. The comparison by output over a corpus. This change refuses more, so I need how many shaders that translate today it refuses, per stage, and how many of those the game binds in a world run. I will run it on my corpus and post the table; I have not done it yet. 3. The wrong accept in #256 needs a test with values on Metal. Please ask someone who has the converter to run it, or run it yourself. 4. It touches the same file as #261, #271 and #302, so expect conflicts. The branch is behind main.
gagarinyury commented 2026-11-27 10:53:27 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by gagarinyury on 2026-11-27T10:53:27Z.


Added guarded_write_tests.rs in victory-gpu (runs on Metal; Metal Shader Converter 4.0 beta 3 is installed here now) with the #256 shape as a synthetic compute program: if (v0 < 40) v2 = s_memtime; else v2 = 0;, then every lane stores v2. On main (2a3b03d) it translates and all 64 lanes read 0, so lanes 0..39 lose the timestamp they wrote; with this branch it is refused ("a scalar memory read as data"), and that test fails on main. When lanes 0..39 overwrite v2 under the same vcc before the store, it still translates and runs with 5 in lanes 0..39 and 0 in 40..63; an unguarded overwrite (a7fc47af's case) gives 7 in every lane. Full victory-gpu tests with the converter: 318 passed.

One cost I found: if the overwrite recomputes the compare (a second v_cmp_gt_u32 vcc, 40, v0) instead of reusing vcc, this branch refuses it, because each compare is its own atom in the lane booleans and the analysis cannot see that the two guards are equal. On main that program gives the right values. Your corpus table will show how often this happens; if it matters, folding equal compares into one atom would be a separate change.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7216429183 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/293#issuecomment-7216429183). Originally posted by [gagarinyury](https://github.com/gagarinyury) on 2026-11-27T10:53:27Z. --- Added `guarded_write_tests.rs` in victory-gpu (runs on Metal; Metal Shader Converter 4.0 beta 3 is installed here now) with the #256 shape as a synthetic compute program: `if (v0 < 40) v2 = s_memtime; else v2 = 0;`, then every lane stores v2. On main (2a3b03d) it translates and all 64 lanes read 0, so lanes 0..39 lose the timestamp they wrote; with this branch it is refused ("a scalar memory read as data"), and that test fails on main. When lanes 0..39 overwrite v2 under the same vcc before the store, it still translates and runs with 5 in lanes 0..39 and 0 in 40..63; an unguarded overwrite (a7fc47af's case) gives 7 in every lane. Full victory-gpu tests with the converter: 318 passed. One cost I found: if the overwrite recomputes the compare (a second `v_cmp_gt_u32 vcc, 40, v0`) instead of reusing vcc, this branch refuses it, because each compare is its own atom in the lane booleans and the analysis cannot see that the two guards are equal. On main that program gives the right values. Your corpus table will show how often this happens; if it matters, folding equal compares into one atom would be a separate change.
gagarinyury commented 2026-11-27 11:58:00 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by gagarinyury on 2026-11-27T11:58:00Z.


CI fails on emit::tests::interpolated_f16_writes_the_op_sel_half_with_modifiers (Windows-only, so I missed it here). Its program writes half of v2 with v_interp_p2_f16 over v2 = v_interp_p1_f32, then exports all of v2, so the export reads the other half, which is the p1 intermediate. This branch refuses that ("the first half of an interpolation"), as it refuses any read of a kept value without a DXIL form; main makes that half 0. #256 left the 16-bit keep undecided (794 shaders reach it, reads not measured), so I see two ways: (a) keep the refusal and change the test to export v_cvt_f32_f16 of v2, which still checks op_sel, omod and clamp; (b) take the 16-bit keeps (write_half, place_bits, v_fma_mix*) out of this pull request, so it only does the guarded writes of #256, and leave the partial bits to a separate change with its own corpus count. I would do (b) unless you prefer (a).

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7217680409 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/293#issuecomment-7217680409). Originally posted by [gagarinyury](https://github.com/gagarinyury) on 2026-11-27T11:58:00Z. --- CI fails on `emit::tests::interpolated_f16_writes_the_op_sel_half_with_modifiers` (Windows-only, so I missed it here). Its program writes half of v2 with `v_interp_p2_f16` over v2 = `v_interp_p1_f32`, then exports all of v2, so the export reads the other half, which is the p1 intermediate. This branch refuses that ("the first half of an interpolation"), as it refuses any read of a kept value without a DXIL form; main makes that half 0. #256 left the 16-bit keep undecided (794 shaders reach it, reads not measured), so I see two ways: (a) keep the refusal and change the test to export `v_cvt_f32_f16` of v2, which still checks op_sel, omod and clamp; (b) take the 16-bit keeps (`write_half`, `place_bits`, `v_fma_mix*`) out of this pull request, so it only does the guarded writes of #256, and leave the partial bits to a separate change with its own corpus count. I would do (b) unless you prefer (a).
LakshanSivakumar commented 2026-11-27 12:00:35 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T12:00:35Z.


Thank you for the Metal test and for telling me what the change costs (a recomputed identical compare is refused).

Two things: the Windows check job fails on e80bced1; please look at it and fix it before anything else. And I need the corpus table on your head (newly refused and bound by the game), because the cost you describe is exactly what the corpus will count. I have not run mine on this head; I will when check is green. Folding equal compares into one atom should be a separate pull request.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7217729207 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/293#issuecomment-7217729207). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T12:00:35Z. --- Thank you for the Metal test and for telling me what the change costs (a recomputed identical compare is refused). Two things: the Windows `check` job fails on e80bced1; please look at it and fix it before anything else. And I need the corpus table on your head (newly refused and bound by the game), because the cost you describe is exactly what the corpus will count. I have not run mine on this head; I will when `check` is green. Folding equal compares into one atom should be a separate pull request.
LakshanSivakumar commented 2026-11-27 12:02:49 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T12:02:49Z.


I did run the corpus on e80bced1 after all (33,625 containers, against main c1b95875):

stage gained lost changed hangs
pixel 0 212 462 0
vertex 0 284 0 0
compute 0 10 1 0

506 shaders that translate on main are refused with this change and 463 give different output; nothing is gained. Of the shaders the game binds in the world, 15 are lost. The new refusals I looked at carry many different reasons ("a descriptor built around a table in the code", "a descriptor read only as data", "a carry-in from an untracked mask", "a constant lane mask", "the first half of an interpolation", "barycentrics read directly", and two lane-mask ones), so the tracking reaches far beyond the guarded-write shape of #256. I cannot merge it like this. Please narrow it to the shape the test covers and show that the 462 changed pixel shaders mean the same as before, or say why they should change.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7217774876 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/293#issuecomment-7217774876). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T12:02:49Z. --- I did run the corpus on e80bced1 after all (33,625 containers, against main c1b95875): | stage | gained | lost | changed | hangs | |---|---|---|---|---| | pixel | 0 | 212 | 462 | 0 | | vertex | 0 | 284 | 0 | 0 | | compute | 0 | 10 | 1 | 0 | 506 shaders that translate on main are refused with this change and 463 give different output; nothing is gained. Of the shaders the game binds in the world, 15 are lost. The new refusals I looked at carry many different reasons ("a descriptor built around a table in the code", "a descriptor read only as data", "a carry-in from an untracked mask", "a constant lane mask", "the first half of an interpolation", "barycentrics read directly", and two lane-mask ones), so the tracking reaches far beyond the guarded-write shape of #256. I cannot merge it like this. Please narrow it to the shape the test covers and show that the 462 changed pixel shaders mean the same as before, or say why they should change.
gagarinyury commented 2026-11-27 12:07:11 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by gagarinyury on 2026-11-27T12:07:11Z.


Pushed 0ab00ca, option (b): the 16-bit and SDWA keeps (write_half, place_bits, v_fma_mix*) are back to main's behaviour, which makes interpolated_f16_writes_the_op_sel_half_with_modifiers translate again (I ran its program on macOS without dxc: refused before, translated now; the DXIL checks need the Windows job). That alone does not answer your table: I am now narrowing the rest to the guarded-write shape the test covers, and will come back with why the 462 pixel outputs change and what is left of them.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7217861366 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/293#issuecomment-7217861366). Originally posted by [gagarinyury](https://github.com/gagarinyury) on 2026-11-27T12:07:11Z. --- Pushed 0ab00ca, option (b): the 16-bit and SDWA keeps (`write_half`, `place_bits`, `v_fma_mix*`) are back to main's behaviour, which makes `interpolated_f16_writes_the_op_sel_half_with_modifiers` translate again (I ran its program on macOS without dxc: refused before, translated now; the DXIL checks need the Windows job). That alone does not answer your table: I am now narrowing the rest to the guarded-write shape the test covers, and will come back with why the 462 pixel outputs change and what is left of them.
gagarinyury commented 2026-11-27 12:15:09 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by gagarinyury on 2026-11-27T12:15:09Z.


Pushed 8c70e7f: the phi liveness walk had become a rewrite of live_edges that remembered six branch conditions instead of main's four. That changes which join edges of every branchy pixel shader count as dead, and so their output, whether or not they have a guarded write; it is back to four, so a program without a kept value should lower as on main. To check that without your dump I traced every program the victory-shader and victory-gpu tests lower: of the 714 that main lowers to one output each, all give main's DXIL byte for byte on 0ab00ca plus 8c70e7f. They are small programs, though, and e80bced does not change them either, so this is a likely cause of the 462, not a proven one. The 284 vertex refusals I cannot explain from here: could you rerun on 8c70e7f and, for the vertex ones that stay, give the counts by reason and describe one shape in words (which write is guarded, by what, and what reads the kept value)?

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7218018518 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/293#issuecomment-7218018518). Originally posted by [gagarinyury](https://github.com/gagarinyury) on 2026-11-27T12:15:09Z. --- Pushed 8c70e7f: the phi liveness walk had become a rewrite of `live_edges` that remembered six branch conditions instead of main's four. That changes which join edges of every branchy pixel shader count as dead, and so their output, whether or not they have a guarded write; it is back to four, so a program without a kept value should lower as on main. To check that without your dump I traced every program the victory-shader and victory-gpu tests lower: of the 714 that main lowers to one output each, all give main's DXIL byte for byte on 0ab00ca plus 8c70e7f. They are small programs, though, and e80bced does not change them either, so this is a likely cause of the 462, not a proven one. The 284 vertex refusals I cannot explain from here: could you rerun on 8c70e7f and, for the vertex ones that stay, give the counts by reason and describe one shape in words (which write is guarded, by what, and what reads the kept value)?
LakshanSivakumar commented 2026-11-27 16:23:51 +00:00 (Migrated from github.com)

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


Leaving this open. I swept my full corpus (21,600 shaders) with this head (8c70e7f5) on top of tonight's shader PRs: 604 shaders that translate without it are refused with it (19 compute, 393 pixel, 192 vertex), mostly as "a descriptor built around a table in the code" (219), "the first half of an interpolation" (194) and "barycentrics read directly" (93). It needs those losses gone before it can go in.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7223212372 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/293#issuecomment-7223212372). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T16:23:51Z. --- Leaving this open. I swept my full corpus (21,600 shaders) with this head (8c70e7f5) on top of tonight's shader PRs: 604 shaders that translate without it are refused with it (19 compute, 393 pixel, 192 vertex), mostly as "a descriptor built around a table in the code" (219), "the first half of an interpolation" (194) and "barycentrics read directly" (93). It needs those losses gone before it can go in.
gagarinyury commented 2026-11-27 18:02:01 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by gagarinyury on 2026-11-27T18:02:01Z.


Rebased #293 onto main (be7dc1b5, head 44111d61) and eliminated all locally reproducible regressions:

Changes

  • Separate kept_reads check from live_edges (Lower::resolve_kept_and_live_edges): keeps main's live_edges walk over read_phis (phi_at with MAX_KNOWN = 4 branch conditions) untouched while checking KeptWrite origins over the reaches_kept closure, propagating st.reach[q] on non-branch forward phi edges and deduplicating facts before MAX_KNOWN truncation.
  • Reader constraints on phi reads (Lower::get_val): records genuine is_phi reads in kept_reads with the reader's (reach, guard) facts alongside direct kept_writes reads (ReadKind::Lane only receives the lane's own path through the phi; cross-lane Quad/Wave reads still widen/clear facts).
  • v_readfirstlane_b32 (Lower::read_kind, exec_nonzero_at): waterfall_reads lower literally to the lane's own value (ReadKind::Lane); outside pixel shaders, v_readfirstlane_b32 with a dominating execz/execnz check matching both lo and hi (across scalar copies and loop-invariant EXEC phis) is also treated as ReadKind::Lane (marked as a Guess: in lower.rs and documented in docs/native-host.md). Without a matching nonzero check (even when st.guards[b][i] is None), it stays ReadKind::Wave.

Local sweep (25,985 containers vs be7dc1b5, sweep -j 4, wave32_host = true, zero_copy_memory = true)

  • tools/corpus/compare.sh: 25669 ok, 316 refused — 0 regressions, 0 output changes (newly translated: 0, output changed: 0, other reason now: 0).
  • Breakdown of the 20 local regressions seen before these fixes (19 pixel "the first half of an interpolation" and 1 compute): recording the reader's (reach, guard) facts on phi reads in get_val recovers all 20; propagating forward-edge st.reach[q] recovers 19 of the 20; the refusals only return when both are disabled.

Checks on 44111d61

  • cargo clippy -p victory-shader --all-targets -- -D warnings (host and --target x86_64-pc-windows-msvc): clean.
  • cargo test -p victory-shader --locked: 386 unit tests passed (3 ignored) + 5 sweep tests passed, including regression tests (verified to fail when their rule is reverted) for phi reader facts, forward reach[q], exec_nonzero_at (wave64 exec_hi and guards == None), and waterfall_reads.
  • cargo test -p victory-gpu --lib guarded_write_tests: 2 Metal tests passed.
  • cargo run -p xtask -- policy: 391 files ok.

Request for hashes

Neither "a descriptor built around a table in the code" nor "barycentrics read directly" regresses in our local 25,985-container corpus. Could you share sample hashes from your sweep for those two shapes (and any remaining "the first half of an interpolation", if any remain after this update) so we can reproduce and fix them?

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7225046537 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/293#issuecomment-7225046537). Originally posted by [gagarinyury](https://github.com/gagarinyury) on 2026-11-27T18:02:01Z. --- Rebased `#293` onto `main` (`be7dc1b5`, head `44111d61`) and eliminated all locally reproducible regressions: ### Changes - **Separate `kept_reads` check from `live_edges` (`Lower::resolve_kept_and_live_edges`)**: keeps `main`'s `live_edges` walk over `read_phis` (`phi_at` with `MAX_KNOWN = 4` branch conditions) untouched while checking `KeptWrite` origins over the `reaches_kept` closure, propagating `st.reach[q]` on non-branch forward phi edges and deduplicating facts before `MAX_KNOWN` truncation. - **Reader constraints on `phi` reads (`Lower::get_val`)**: records genuine `is_phi` reads in `kept_reads` with the reader's `(reach, guard)` facts alongside direct `kept_writes` reads (`ReadKind::Lane` only receives the lane's own path through the phi; cross-lane `Quad`/`Wave` reads still widen/clear facts). - **`v_readfirstlane_b32` (`Lower::read_kind`, `exec_nonzero_at`)**: `waterfall_reads` lower literally to the lane's own value (`ReadKind::Lane`); outside pixel shaders, `v_readfirstlane_b32` with a dominating `execz`/`execnz` check matching both `lo` and `hi` (across scalar copies and loop-invariant `EXEC` phis) is also treated as `ReadKind::Lane` (marked as a `Guess:` in `lower.rs` and documented in `docs/native-host.md`). Without a matching nonzero check (even when `st.guards[b][i]` is `None`), it stays `ReadKind::Wave`. ### Local sweep (`25,985` containers vs `be7dc1b5`, `sweep -j 4`, `wave32_host = true`, `zero_copy_memory = true`) - `tools/corpus/compare.sh`: `25669 ok`, `316 refused` — **`0` regressions, `0` output changes** (`newly translated: 0`, `output changed: 0`, `other reason now: 0`). - **Breakdown of the `20` local regressions** seen before these fixes (`19` pixel `"the first half of an interpolation"` and `1` compute): recording the reader's `(reach, guard)` facts on `phi` reads in `get_val` recovers all `20`; propagating forward-edge `st.reach[q]` recovers `19` of the `20`; the refusals only return when both are disabled. ### Checks on `44111d61` - `cargo clippy -p victory-shader --all-targets -- -D warnings` (host and `--target x86_64-pc-windows-msvc`): clean. - `cargo test -p victory-shader --locked`: `386` unit tests passed (`3` ignored) + `5` sweep tests passed, including regression tests (verified to fail when their rule is reverted) for `phi` reader facts, forward `reach[q]`, `exec_nonzero_at` (`wave64` `exec_hi` and `guards == None`), and `waterfall_reads`. - `cargo test -p victory-gpu --lib guarded_write_tests`: `2` Metal tests passed. - `cargo run -p xtask -- policy`: `391 files ok`. ### Request for hashes Neither `"a descriptor built around a table in the code"` nor `"barycentrics read directly"` regresses in our local 25,985-container corpus. Could you share sample hashes from your sweep for those two shapes (and any remaining `"the first half of an interpolation"`, if any remain after this update) so we can reproduce and fix them?
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/293:upstream-pr/293'
git switch 'upstream-pr/293'

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/293'
git switch 'upstream-pr/293'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/293'
git switch 'upstream-pr/293'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/293'
git switch 'main'
git merge --squash 'upstream-pr/293'
git switch 'main'
git merge --ff-only 'upstream-pr/293'
git switch 'main'
git merge 'upstream-pr/293'
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
LakshanSivakumar/Native-Victory-macOS!293
No description provided.