Files
metal2vulkan/docs
Anees Iqbal c7db26da1b Keep an unrolled entry only where it comes out no larger than its loops
What: canonicalization runs the unrolling rounds (and the SCCP after
each) on a trial body and keeps it only where its size is at most the
entry's before unrolling; otherwise the loops stay as they were and
the trial's undefined-constant reads are dropped with it. The size is
`unroll::live_size`: the instructions that stay once unobserved code
is deleted (every one that is not pure, and every pure one those read,
directly or through others), not counting unconditional branches and
PHIs of one entry, which the copies leave where their blocks join.

Why: with the previous commit alone, a translation census of the
private corpus on the nvidia-rtx5080-laptop profile (no constants
supplied) grew 87 of the 15499 rows both builds translate and shrank
20: 83262314 words in all before the series, 84265507 after (+1.2%),
the largest growth 9546 -> 62171 words (6.5x) and 50185 -> 123245
(2.5x). Those loops' counters pick among a few cheap arms of a body
they run many times, so the copies add more than they decide away, and
the module is what the driver compiles. The fixture this item is for
still unrolls: `fold_loop_extract` specialized is 2296 words (the
baked form 2612). `engine/simd_divergent` `uniform_continue_k`, whose
38 golden cells the previous commit moved, now stays a loop and its
cells are as they were.

Not a speed-for-accuracy choice: either way the program computes the
same answers (unrolling copies every operation as it is), so
`docs/FAST-PATHS.md` has no row for it.

Tests: `canon::tests::unrolling` reworked: the switch's default arm is
80 operations, so copies taking the cheap arms are smaller than the
loop (unrolled, including at `TRIPS`), and copies taking the default
are larger (the loop stays, for supplied and for unsupplied lanes).

Verified: `cargo nextest run -p metal2vulkan-air -p metal2vulkan
--all-features -E 'package(metal2vulkan-air) |
test(/engine_arena|engine_specialized_folds|engine_simd_emulated|golden_hashes_match/)'`:
556 of 557 passed, golden_hashes failing only on the 380 new cells of
the fold fixtures (20 entries on 19 profiles) and no moved cell;
clippy on the crate with all targets and features.

(cherry picked from commit 8dc34fec499b1803bf13b0b1fe57ce1df8241f48)
(cherry picked from commit b1fe70ab5e41dbcf4d2879b7475b76aa1f5fc62c)
2026-11-03 00:45:19 -08:00
..