shader: lower 64-bit shifts without INT64 #3202

Open
github-bot wants to merge 1 commit from github-bot/gh-3202 into main AGit
Owner

@⁠Jackster on GitHub · 2026-11-26 12:28 UTC · original
Jackster:new-66-64bit-shifts → main · +253 −21 · 3 files · 1 commits · open

Summary

Lower the six RDNA2 64-bit shift opcodes using pairs of 32-bit DXIL values. Shaders that use these shifts can run without the SFI0 INT64 feature when they have no other 64-bit integer operations.

The lowering preserves RDNA2’s six-bit shift count and arithmetic sign extension. Counts of 32–63 shift across dwords, and counts of 64 or more wrap modulo 64. Every emitted 32-bit shift uses an in-range count.

Validation

  • Synthetic tests keep both result dwords live and verify that SFI0 INT64 stays clear for all six opcodes.
  • Runtime tests compare both dwords against a 64-bit CPU reference on a hardware GPU and WARP.
  • The full workspace test suite, both strict Clippy configurations, and the repository asset-policy check passed.

NEW-66. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-26 12:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/3202) `Jackster:new-66-64bit-shifts` → `main` · +253 −21 · 3 files · 1 commits · open ## Summary Lower the six RDNA2 64-bit shift opcodes using pairs of 32-bit DXIL values. Shaders that use these shifts can run without the SFI0 INT64 feature when they have no other 64-bit integer operations. The lowering preserves RDNA2’s six-bit shift count and arithmetic sign extension. Counts of 32–63 shift across dwords, and counts of 64 or more wrap modulo 64. Every emitted 32-bit shift uses an in-range count. ## Validation - Synthetic tests keep both result dwords live and verify that SFI0 INT64 stays clear for all six opcodes. - Runtime tests compare both dwords against a 64-bit CPU reference on a hardware GPU and WARP. - The full workspace test suite, both strict Clippy configurations, and the repository asset-policy check passed. NEW-66. AI-assisted.
Lower the six scalar and vector shift opcodes using pairs of 32-bit DXIL values. Preserve the six-bit counts and check both result dwords in the synthetic SFI0 and runtime tests.

NEW-66. AI-assisted.

Co-authored-by: new-66 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:32:56 +00:00
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 12:43 UTC · original

Independent local verification of head 6344a95 on Windows 11, Rust 1.100.0/MSVC:

  • cargo test --locked -p victory-shader --lib -- emit::lower::tests::scalar_64_bit_shifts_need_no_int64 --exact — 1 passed, 0 failed.
  • cargo test --locked -p victory-shader --lib -- emit::lower::tests::vector_64_bit_shifts_need_no_int64 --exact — 1 passed, 0 failed.
  • git diff --check origin/main HEAD — clean.

Worktree-local CARGO_TARGET_DIR; synthetic GFX10 word streams only, no game assets or DRM material used. AI-assisted (Hy4 flash). GPU/driver N/A (CPU-side lowering tests only).

**@⁠cloph-dsp** on GitHub · 2026-11-26 12:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/3202#issuecomment-7192366030) Independent local verification of head `6344a95` on Windows 11, Rust 1.100.0/MSVC: - `cargo test --locked -p victory-shader --lib -- emit::lower::tests::scalar_64_bit_shifts_need_no_int64 --exact` — 1 passed, 0 failed. - `cargo test --locked -p victory-shader --lib -- emit::lower::tests::vector_64_bit_shifts_need_no_int64 --exact` — 1 passed, 0 failed. - `git diff --check origin/main HEAD` — clean. Worktree-local `CARGO_TARGET_DIR`; synthetic GFX10 word streams only, no game assets or DRM material used. AI-assisted (Hy4 flash). GPU/driver N/A (CPU-side lowering tests only).
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 12:50 UTC · original · approved these changes

Verified on RTX 5090 & WARP against origin/main (63bcca4):

  • cargo test -p victory-shader --lib bit_shifts -- --test-threads=1: 3/3 passed on RTX 5090 and WARP (scalar_64_bit_shifts_need_no_int64, vector_64_bit_shifts_need_no_int64, sixty_four_bit_shifts_count_to_six_bits).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Cleanly lowers 64-bit scalar and vector shifts using 32-bit operations without requiring the DXIL INT64 feature flag.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 12:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/3202#pullrequestreview-6074412312) · **approved these changes** Verified on RTX 5090 & WARP against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib bit_shifts -- --test-threads=1`: 3/3 passed on RTX 5090 and WARP (`scalar_64_bit_shifts_need_no_int64`, `vector_64_bit_shifts_need_no_int64`, `sixty_four_bit_shifts_count_to_six_bits`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Cleanly lowers 64-bit scalar and vector shifts using 32-bit operations without requiring the DXIL INT64 feature flag. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 13:06 UTC · original

WARP test report (claim: #1633)

  • Head: 6344a9580c4ecd23ea474db122ea874c6486e686, base: origin/main 63bcca43c6 (head sits directly on it, no merge needed)
  • Backend: WARP (VICTORY_D3D12_WARP=1). Windows 11, Rust per rust-toolchain.toml, cargo test --locked -p victory-shader --lib -- --test-threads=1, VICTORY_D3D12_WARP=1 and VICTORY_WARP=1 (the shader tests only honour the latter, so every device in the run was WARP; no physical GPU). Validator: Windows SDK 10.0.26100 dxil.dll. Synthetic word streams only, no game data.
  • victory-shader suite: 301 passed, 4 failed, 3 ignored. New tests scalar_64_bit_shifts_need_no_int64, vector_64_bit_shifts_need_no_int64 and sixty_four_bit_shifts_count_to_six_bits all pass; none skipped (WARP runs the 64-bit-shift GPU test).
  • Control (main alone): suite 298 passed, 4 failed, 3 ignored. The same 4 fail on main and on the PR, so they are not caused by it (synthetic_tests: a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out). With the PR's tests applied to main alone, the two SFI0 INT64 tests fail (main sets INT64) and sixty_four_bit_shifts_count_to_six_bits passes.
  • Review: no defect found. I traced shift64 for Shl/LShr/AShr at counts 0, 1, 31, 32, 33, 63 and past 63 (the cnt == 0 and >= 32 selects are right, the complementary shift stays in range). Note that WARP evidently runs the old INT64 form correctly, so the behaviour test cannot show a regression there; the SFI0 tests are the guard for this change. 11 other tests print a skip message and pass (no console/PC compiler, no wave-of-32/64 pipeline); none touch this change.
  • cloph-dsp's earlier report on this head (12:43 UTC) predates the claim and covers only the two SFI0 tests; this adds the behaviour test and the full suite.

AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5).

**@⁠oni-swr** on GitHub · 2026-11-26 13:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/3202#issuecomment-7192892963) **WARP test report (claim: #1633)** - Head: `6344a9580c4ecd23ea474db122ea874c6486e686`, base: `origin/main` 63bcca43c6a0 (head sits directly on it, no merge needed) - Backend: WARP (VICTORY_D3D12_WARP=1). Windows 11, Rust per `rust-toolchain.toml`, `cargo test --locked -p victory-shader --lib -- --test-threads=1`, `VICTORY_D3D12_WARP=1` and `VICTORY_WARP=1` (the shader tests only honour the latter, so every device in the run was WARP; no physical GPU). Validator: Windows SDK 10.0.26100 `dxil.dll`. Synthetic word streams only, no game data. - `victory-shader` suite: **301 passed, 4 failed, 3 ignored**. New tests `scalar_64_bit_shifts_need_no_int64`, `vector_64_bit_shifts_need_no_int64` and `sixty_four_bit_shifts_count_to_six_bits` all pass; none skipped (WARP runs the 64-bit-shift GPU test). - Control (`main` alone): suite 298 passed, 4 failed, 3 ignored. The same 4 fail on main and on the PR, so they are not caused by it (`synthetic_tests`: `a_mask_joined_with_data_at_a_uniform_loop_is_its_number`, `gathers_at_a_level_match_the_hardware`, `permutes_mask_high_address_bits_and_divergent_branches`, `permutes_read_the_lane_named_and_zero_from_lanes_left_out`). With the PR's tests applied to main alone, the two SFI0 INT64 tests **fail** (main sets INT64) and `sixty_four_bit_shifts_count_to_six_bits` **passes**. - Review: no defect found. I traced `shift64` for Shl/LShr/AShr at counts 0, 1, 31, 32, 33, 63 and past 63 (the `cnt == 0` and `>= 32` selects are right, the complementary shift stays in range). Note that WARP evidently runs the old INT64 form correctly, so the behaviour test cannot show a regression there; the SFI0 tests are the guard for this change. 11 other tests print a skip message and pass (no console/PC compiler, no wave-of-32/64 pipeline); none touch this change. - cloph-dsp's earlier report on this head (12:43 UTC) predates the claim and covers only the two SFI0 tests; this adds the behaviour test and the full suite. AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5).
Author
Owner

@⁠Lyrnc on GitHub · 2026-11-26 17:21 UTC · original

Checked 6344a95 on RDNA2 hardware for all six 64-bit shifts, using the same instruction words on both sides.

  • Hardware: Radeon iGPU (Ryzen 7 9800X3D), gfx1036 / RDNA2, driver 32.0.21042.62. A HIP kernel (assembled by the driver's amd_comgr) runs the shifts in two forms:

    • VOP3: v_lshlrev_b64, v_lshrrev_b64 and v_ashrrev_i64.
    • SOP2: s_lshl_b64, s_lshr_b64 and s_ashr_i64, with SCC read back through s_cselect_b32. On the hardware side each row fills a whole wave, and its operands come in through v_readfirstlane.

    There are 158 rows:

    • every count from 0 to 127 on random values, with the sign bit set for odd counts;
    • counts such as 0x100, 0x13f, 0x80000020, 0xffffffc1 and 0xffffffff, each with both sign patterns;
    • a few fixed edges.

    That gives 2,370 results (low dword, high dword, and SCC).

  • Translator: the same words through a local copy of the build_valu_cs harness (a local test, not part of this PR). I ran it on main 63bcca4 and on the PR merged onto it, on the RTX 5080 (610.88) and on the same Radeon (picked with a local adapter-name filter in hardware_adapter).

Host branch matches the hardware bit for bit other differences
Radeon gfx1036 main 2,370 0
Radeon gfx1036 #3202 2,370 0
RTX 5080 main 2,370 0
RTX 5080 #3202 2,370 0

So the 32-bit lowering gives the same results as main's 64-bit shifts and as the hardware:

  • Only count bits 5:0 are used, so a count of 0x13f shifts by 63.
  • The arithmetic shift fills with the sign.
  • SCC is set when the scalar result is nonzero.

I didn't check the SFI0 INT64 bit, because your tests cover it.

No game data was used.

AI use: Claude Code (Claude Opus 5.5) wrote the probe and the comparison and ran them on the GPUs above; the numbers come from those runs.

**@⁠Lyrnc** on GitHub · 2026-11-26 17:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/3202#issuecomment-7198889730) Checked `6344a95` on RDNA2 hardware for all six 64-bit shifts, using the same instruction words on both sides. - **Hardware:** Radeon iGPU (Ryzen 7 9800X3D), gfx1036 / RDNA2, driver 32.0.21042.62. A HIP kernel (assembled by the driver's amd_comgr) runs the shifts in two forms: - VOP3: `v_lshlrev_b64`, `v_lshrrev_b64` and `v_ashrrev_i64`. - SOP2: `s_lshl_b64`, `s_lshr_b64` and `s_ashr_i64`, with SCC read back through `s_cselect_b32`. On the hardware side each row fills a whole wave, and its operands come in through `v_readfirstlane`. There are 158 rows: - every count from 0 to 127 on random values, with the sign bit set for odd counts; - counts such as `0x100`, `0x13f`, `0x80000020`, `0xffffffc1` and `0xffffffff`, each with both sign patterns; - a few fixed edges. That gives 2,370 results (low dword, high dword, and SCC). - **Translator:** the same words through a local copy of the `build_valu_cs` harness (a local test, not part of this PR). I ran it on `main` 63bcca4 and on the PR merged onto it, on the RTX 5080 (610.88) and on the same Radeon (picked with a local adapter-name filter in `hardware_adapter`). | Host | branch | matches the hardware bit for bit | other differences | |---|---|---|---| | Radeon gfx1036 | main | 2,370 | 0 | | Radeon gfx1036 | #3202 | 2,370 | **0** | | RTX 5080 | main | 2,370 | 0 | | RTX 5080 | #3202 | 2,370 | **0** | So the 32-bit lowering gives the same results as main's 64-bit shifts and as the hardware: - Only count bits 5:0 are used, so a count of `0x13f` shifts by 63. - The arithmetic shift fills with the sign. - SCC is set when the scalar result is nonzero. I didn't check the SFI0 INT64 bit, because your tests cover it. No game data was used. AI use: Claude Code (Claude Opus 5.5) wrote the probe and the comparison and ran them on the GPUs above; the numbers come from those runs.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3202/head:github-bot/gh-3202'
git switch 'github-bot/gh-3202'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3202'
git switch 'github-bot/gh-3202'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3202'
git switch 'github-bot/gh-3202'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3202'
git switch 'main'
git merge --squash 'github-bot/gh-3202'
git switch 'main'
git merge --ff-only 'github-bot/gh-3202'
git switch 'main'
git merge 'github-bot/gh-3202'
git push origin 'main'
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!3202
No description provided.