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

Merged
kibagami-nc merged 1 commit from upstream-pr/651 into main 2026-11-29 00:24:47 +00:00
kibagami-nc commented 2026-11-28 02:45:13 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kibagami-nc on 2026-11-28T02:45:13Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5535923298 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/651). Originally posted by [kibagami-nc](https://github.com/kibagami-nc) on 2026-11-28T02:45:13Z. --- ## 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.
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
trustno1-coder/VIctory-NVIDIA!651
No description provided.