Shaders: walk a live set's registers a bit at a time #1833

Manually merged
github merged 1 commit from gh-pr/1833/head into gh-pr/1833/base 2026-11-26 04:46:09 +00:00
Owner

@⁠slatefield on GitHub · 2026-11-24 23:08 UTC · original
slatefield:shader/live-set-bits → main · +13 −3 · 1 files · 1 commits · merged 2026-11-25 21:51 UTC

members() bit-tests all 385 register slots and returns the few that are live, twice per block. a 1651 block shader = 1.27M tests per translation for nothing.

now it walks the 7 u64 words by their lowest set bit (trailing_zeros, bits &= bits - 1), same register order out. the set only ever gets bits from insert(reg), so nothing past 385 can be set.

measured (min of 5, alternating binaries, taskset): ir::build -4.5% on 12.1k and 24.2k instruction synthetic GFX10 programs, range::build -4.1%. 118 lib tests pass.

not #369 (CFG traversal) or #1757 (operand arena).

**@⁠slatefield** on GitHub · 2026-11-24 23:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/1833) `slatefield:shader/live-set-bits` → `main` · +13 −3 · 1 files · 1 commits · merged 2026-11-25 21:51 UTC `members()` bit-tests all 385 register slots and returns the few that are live, twice per block. a 1651 block shader = 1.27M tests per translation for nothing. now it walks the 7 u64 words by their lowest set bit (`trailing_zeros`, `bits &= bits - 1`), same register order out. the set only ever gets bits from `insert(reg)`, so nothing past 385 can be set. measured (min of 5, alternating binaries, taskset): ir::build -4.5% on 12.1k and 24.2k instruction synthetic GFX10 programs, range::build -4.1%. 118 lib tests pass. not #369 (CFG traversal) or #1757 (operand arena).
members() tested all 385 register slots to return the few that are live,
twice for every block of a program: 1.27 M tests for a 1,651-block
shader. Walk the seven set words by their lowest set bit instead, in the
same register order. The IR build is 4.5% faster on a synthetic GFX10
program of 12k and 24k instructions, and range::build 4.1% faster.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:46:08 +00:00
github manually merged commit f52b800615 into gh-pr/1833/base 2026-11-26 04:46:09 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 23:15 UTC · original

NVIDIA run: RTX 3070 8 GB, driver 616.56, plus WARP, Windows 11, debug, f52b800 (on main 70564ae). cargo test -p victory-shader --locked: 206 passed, 3 failed, 2 ignored. The 3 are #1744's NVIDIA heap-cap failures on main, so there are no new failures.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-24 23:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1833#issuecomment-7147192092) NVIDIA run: RTX 3070 8 GB, driver 616.56, plus WARP, Windows 11, debug, `f52b800` (on `main` `70564ae`). `cargo test -p victory-shader --locked`: 206 passed, 3 failed, 2 ignored. The 3 are #1744's NVIDIA heap-cap failures on `main`, so there are no new failures. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

@⁠dcastell1 on GitHub · 2026-11-24 23:42 UTC · original

Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. main@ffe310e baseline on this box: 342 passed, 0 failed, 6 ignored.

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace
342 passed; 0 failed; 6 ignored   (exit 0)

Same count as the baseline: walking a live set's registers a bit at a time changes no verdict here.

Tree restored afterwards; no game data. AI-assisted (opencode).

**@⁠dcastell1** on GitHub · 2026-11-24 23:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/1833#issuecomment-7147696871) Verified on native Windows (no Wine): NVIDIA GeForce RTX 5090 (driver 621.24), Windows 11 10.0.26300, Rust 1.98.1, MSVC 14.44.35207, debug build. `main@ffe310e` baseline on this box: **342 passed, 0 failed, 6 ignored**. ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace 342 passed; 0 failed; 6 ignored (exit 0) ``` Same count as the baseline: walking a live set's registers a bit at a time changes no verdict here. Tree restored afterwards; no game data. AI-assisted (opencode).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:32 UTC · original

Automated triage for the maintainers.

Merge candidate. members in crates/victory-shader/src/ir.rs walked all 385 register indices and tested a bit for each. It now visits only the set bits, word by word, with trailing_zeros. I checked that it is equivalent. The order is the same, ascending index, which the callers rely on ("in Reg order"). RegSet is [u64; REGS.div_ceil(64)], and bits past REGS are never set, so the extra 63 bit positions in the last word yield nothing. The change is small and local, on a path the liveness analysis runs for every instruction.

No measurement is given. A before/after time for translate over a pack would show how much it saves.

CI: no check runs on the head commit.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 06:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1833#issuecomment-7154903184) <!-- victory-triage v1 head=f52b80061522e913e69e61d9092704bed3d1325f verdict=merge-candidate at=2026-11-25T06:39:00Z --> Automated triage for the maintainers. **Merge candidate.** `members` in `crates/victory-shader/src/ir.rs` walked all 385 register indices and tested a bit for each. It now visits only the set bits, word by word, with `trailing_zeros`. I checked that it is equivalent. The order is the same, ascending index, which the callers rely on ("in `Reg` order"). `RegSet` is `[u64; REGS.div_ceil(64)]`, and bits past `REGS` are never set, so the extra 63 bit positions in the last word yield nothing. The change is small and local, on a path the liveness analysis runs for every instruction. No measurement is given. A before/after time for `translate` over a pack would show how much it saves. CI: no check runs on the head commit. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 12:19 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head f52b8006 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 12:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/1833#issuecomment-7162217473) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head f52b8006 onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1833
No description provided.