Shaders: a live set's registers are walked by their bits (port of Marvisak#1833) #651

Manually merged
github merged 1 commit from github-bot/gh-651 into main 2026-11-29 00:28:10 +00:00 AGit
Owner

@⁠kibagami-nc on GitHub · 2026-11-28 02:45 UTC · original
kibagami-nc:perf/ir-live-set-members-by-bits → main · +54 −4 · 1 files · 1 commits · merged 2026-11-29 00:24 UTC

The change

members (crates/victory-shader/src/ir.rs) returns the registers of a live set. It tested every one of the 513 places of a RegSet to find the few that are set, and it runs twice for each block of a program.

It now walks the set's nine words by their lowest set bit (trailing_zeros, then bits &= bits - 1), and gives the registers in the same order. Only insert sets bits, so none lies past REGS; one there would end the walk rather than reach reg_at.

This is a port of slatefield's change (Marvisak/VIctory#1833). It measured ir::build 4.5 % faster, and range::build 4.1 % faster, on synthetic GFX10 programs of 12,000 and 24,000 instructions. I did not measure it again here.

It is a change to the translator's source, so cached translations are made again once (VICTORY_TRANSLATOR).

Tests

  • New ir::tests::a_live_set_walked_by_its_bits_is_every_place_tested. It compares the walk with a test of every place for:
    • the empty set and the full set;
    • 300 random sets of 1 to 300 registers;
    • the places at the ends of words.
  • cargo test -p victory-shader --locked: 291 passed, 4 ignored.
  • cargo clippy -p victory-shader --all-targets -- -D warnings, with and without --all-features: no warnings.

No game files, dumps or extracted data are included.

**@⁠kibagami-nc** on GitHub · 2026-11-28 02:45 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/651) `kibagami-nc:perf/ir-live-set-members-by-bits` → `main` · +54 −4 · 1 files · 1 commits · merged 2026-11-29 00:24 UTC ## The change `members` (`crates/victory-shader/src/ir.rs`) returns the registers of a live set. It tested every one of the 513 places of a `RegSet` to find the few that are set, and it runs twice for each block of a program. It now walks the set's nine words by their lowest set bit (`trailing_zeros`, then `bits &= bits - 1`), and gives the registers in the same order. Only `insert` sets bits, so none lies past `REGS`; one there would end the walk rather than reach `reg_at`. This is a port of slatefield's change ([Marvisak/VIctory#1833](https://github.com/Marvisak/VIctory/pull/1833)). It measured `ir::build` 4.5 % faster, and `range::build` 4.1 % faster, on synthetic GFX10 programs of 12,000 and 24,000 instructions. I did not measure it again here. It is a change to the translator's source, so cached translations are made again once (`VICTORY_TRANSLATOR`). ## Tests - New `ir::tests::a_live_set_walked_by_its_bits_is_every_place_tested`. It compares the walk with a test of every place for: - the empty set and the full set; - 300 random sets of 1 to 300 registers; - the places at the ends of words. - `cargo test -p victory-shader --locked`: 291 passed, 4 ignored. - `cargo clippy -p victory-shader --all-targets -- -D warnings`, with and without `--all-features`: no warnings. No game files, dumps or extracted data are included.
members() tested every one of the 513 places of a RegSet to give the few
registers that are live, twice for each block of a program. It now walks
the set's nine words by their lowest set bit (trailing_zeros, then
bits &= bits - 1), in the same order. Only insert sets bits, so none lies
past REGS; one there would end the walk rather than reach reg_at.

Port of slatefield's change (Marvisak/VIctory#1833), which measured
ir::build 4.5 % faster on synthetic programs of 12,000 and 24,000
instructions. Not measured again here.

Test: a_live_set_walked_by_its_bits_is_every_place_tested compares the
walk with a test of every place for the empty and the full set, 300
random sets of 1 to 300 registers, and the places at the ends of words.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 02:48:19 +00:00
github-bot referenced this pull request from a commit 2026-11-29 00:27:22 +00:00
github manually merged commit 278026f4a4 into main 2026-11-29 00:28:10 +00:00
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/trustno1-coder--VIctory-NVIDIA!651
No description provided.