Repository navigation
Shaders: lower align instructions through bounded shifts - #3691
Open
Ingenioeren wants to merge 1 commit into
Open
Ingenioeren wants to merge 1 commit into
Ingenioeren wants to merge 1 commit into
Conversation
|
Independent software WARP verification (
AI disclosure: independent verification assisted by Gemini 4 Neon. |
|
Hardware run: RX 5700 XT (Navi 10, RDNA1, 32–64 lanes, driver 32.0.21045.29003, Windows 11 26200), head
AI use: Claude Code (Claude Opus 5.5). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v_alignbit_b32andv_alignbyte_b32currently mask the complementary shift, then compare/select away the high word when the shift is zero. Split that high-word shift into(a << 1) << (31 - sh): both individual shifts stay below 32, and together discard every bit at zero. This removes two written DXIL instructions from each dynamic-input form while preserving the existing shift masking.Synthetic shader counts, including the same root-constant loads and live UAV store:
v_alignbit_b32v_alignbyte_b32The count regression fails on the original lowering at
[26, 27]and passes at[24, 25]. The execution test uses an independent 64-bit concatenation reference: 18,432 inputs x two opcodes x four destinations x full/partial EXEC = 294,912 cases per adapter and revision. RX 6750 XT and WARP both match every result before and after, with no adapter differences. It covers every effective shift, ignored shift bits, single-bit/complemented sources, unsigned edge values, deterministic random inputs, all source/destination overlaps, and preservation of inactive destinations. Emitted DXIL validates with the local validator.Validation (Windows, main
63bcca4):cargo test -p victory-shader --locked --offline align_ -- --nocapture: tests-only control 1 passed / 1 expected count failure; final 2 passed.cargo test -p victory-shader --locked --offline --no-fail-fast: baseline 300 passed / 2 failed / 3 ignored; final 302 passed / the same 2 failed / 3 ignored. Both failures are the existing local PSV validator mismatches inrectangles_get_their_fourth_cornerandelements_sharing_a_row_keep_their_order. Integration tests: 3 passed / 1 ignored on both; doc tests: 0.cargo clippy -p victory-shader --locked --offline --all-targets --all-features -- -D warnings: passes before and after.cargo run -p xtask --locked --offline -- policy --staged: passes before (0 changed files) and after (3 changed files).git diff --check: clean. Main already has formatting deviations; all three changed files retain exactly those deviations, with the added code formatted.The test-only written-instruction counter is identical to #3600 and the subsequent lowering PRs; keep one copy when integrating. #2020 addresses the separate source-modifier handling of these opcodes; this change leaves that handling alone. Closed #1379's smaller hardware test is already in main.
The measured gain is written DXIL size (7.7% / 7.4% for these synthetic shaders). GPU timing, Linux/RADV, graphics/mesh and game behavior were not tested. No game files were used.
AI assistance: prepared with OpenAI Codex, reviewed by Ingenioeren.