shader: lower 64-bit shifts without INT64 #3202
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3202
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3202"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Jackster on GitHub · 2026-11-26 12:28 UTC · original
Jackster:new-66-64bit-shifts→main· +253 −21 · 3 files · 1 commits · openSummary
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
NEW-66. AI-assisted.
@cloph-dsp on GitHub · 2026-11-26 12:43 UTC · original
Independent local verification of head
6344a95on 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).@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).
@oni-swr on GitHub · 2026-11-26 13:06 UTC · original
WARP test report (claim: #1633)
6344a9580c4ecd23ea474db122ea874c6486e686, base:origin/main63bcca43c6(head sits directly on it, no merge needed)rust-toolchain.toml,cargo test --locked -p victory-shader --lib -- --test-threads=1,VICTORY_D3D12_WARP=1andVICTORY_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.26100dxil.dll. Synthetic word streams only, no game data.victory-shadersuite: 301 passed, 4 failed, 3 ignored. New testsscalar_64_bit_shifts_need_no_int64,vector_64_bit_shifts_need_no_int64andsixty_four_bit_shifts_count_to_six_bitsall pass; none skipped (WARP runs the 64-bit-shift GPU test).mainalone): 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) andsixty_four_bit_shifts_count_to_six_bitspasses.shift64for Shl/LShr/AShr at counts 0, 1, 31, 32, 33, 63 and past 63 (thecnt == 0and>= 32selects 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.AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5).
@Lyrnc on GitHub · 2026-11-26 17:21 UTC · original
Checked
6344a95on 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:
v_lshlrev_b64,v_lshrrev_b64andv_ashrrev_i64.s_lshl_b64,s_lshr_b64ands_ashr_i64, with SCC read back throughs_cselect_b32. On the hardware side each row fills a whole wave, and its operands come in throughv_readfirstlane.There are 158 rows:
0x100,0x13f,0x80000020,0xffffffc1and0xffffffff, each with both sign patterns;That gives 2,370 results (low dword, high dword, and SCC).
Translator: the same words through a local copy of the
build_valu_csharness (a local test, not part of this PR). I ran it onmain63bcca4and on the PR merged onto it, on the RTX 5080 (610.88) and on the same Radeon (picked with a local adapter-name filter inhardware_adapter).So the 32-bit lowering gives the same results as main's 64-bit shifts and as the hardware:
0x13fshifts by 63.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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.