Shaders: reverse integer opcodes apply DPP to the second source #3325
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!3325
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3325"
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?
@Moon0755 on GitHub · 2026-11-26 18:08 UTC · original
Moon0755:fix/dpp-rev-src1→main· +115 −11 · 2 files · 2 commits · openWhat
With DPP,
v_subrev_nc_u32,v_subrev_co_ci_u32,v_lshlrev_b32,v_lshrrev_b32andv_ashrrev_i32now read their second source from the lane DPP selects and their first source from the lane's own. Until now every instruction with DPP had its first source replaced, so for these five the wrong operand was shuffled: the subtrahend instead of the minuend, and for the shifts the shift amount instead of the value shifted.Nothing else changes.
v_sub_nc_u32, the adds and every float opcode (includingv_subrev_f32) keep DPP on the first source.Why
SIInstrInfo::isSrc1DPPRevOpcode: the integer reverse subtracts always, and the reverse shifts with the note "REV shift opcodes worked this way before GFX11, verified on hardware".GCNDPPCombine.cppuses it to refuse folding into "instructions that apply DPP to the second source operand".README-ISA.md, "DPP with integersubrevand shifts": "DPP is seemingly applied to src1 instead of src0 for integer reverse subtract and shift opcodes."The five opcodes are the ones on LLVM's list that have a VOP2 encoding here, and so can carry DPP at all. The rest of the list (
v_subrev_co_u32, the 16-bit and 64-bit shifts) has only VOP3 opcodes in the decoder (gfx10/opcodes.rs) and cannot.How
src0, the value DPP fetched, now carries the index of the source it stands for: 1 for the five opcodes, 0 otherwise.dppreads the register at that index from the other lane, and the four readers substitute where the index matches. For every other opcode the index is 0 and the code path is the one it was.lower.rsgrows by 359 bytes (520,563 to 520,922).Evidence
The cross-lane harness skips software adapters, so CI cannot run the new test; it runs on a hardware adapter only.
dpp16_reverse_integer_ops_shuffle_the_second_source_on_gpu(pair swap within a quad, full EXEC, lane values different in both registers):63bcca4:DPP16rev: 1 passed, 4 failed. The controlv_sub_nc_u32passes;v_subrev_nc_u32andv_lshlrev_b32mismatch in 32 of 32 lanes,v_lshrrev_b32andv_ashrrev_i32in 18 of 32 (in the other 14 both shift amounts clear the value). Lane 0 of the subtract: got0xf000fffe, expected0xf0010000.DPP16rev: 5 passed, 0 failed; the existingDPP16: 18 passedandDPP8/DPP8FI: 5 passedare unchanged.victory-shader, each one test up on unmodified63bcca4with the same tests failing as there: RTX 2060 300 passed, 3 failed (299 and 3 before); WARP 299 and 4 (298 and 4).DPP16rev: 0 passed, 0 failed, 5 skipped,repository_passes_policy ... ok. This shows the build, the size policy and the rest of the suite, not the fix. The test-only run and the red hardware run used the same test with one comment worded differently.Not checked
v_subrev_co_ci_u32goes through the same substitution but has no case in the test (it needs a tracked carry mask).bound_ctrland inactive lanes with these opcodes: the test keeps every source valid, because neither LLVM nor Mesa says how those rules combine with the second source.GCNDPPCombineprevents); I have no corpus to count.Synthetic tests only; no game files.
— Devin & Fable
@Dukestar69 on GitHub · 2026-11-26 18:28 UTC · original · approved these changes
LGTM — verified on RTX 5090 and
VICTORY_WARP=1(Windows / D3D12) againstorigin/main(63bcca4).(V, usize)so reverse integer opcodes (v_subrev_nc_u32,v_subrev_co_ci_u32,v_lshlrev_b32,v_lshrrev_b32,v_ashrrev_i32) shufflesrc1matches GFX10 hardware / LLVMisSrc1DPPRevOpcodesemantics cleanly across all operand-fetch sites.cargo test -p victory-shader --lib emit::crosslane_tests:: -- --test-threads=1: 6 passed, 0 failed on RTX 5090 and 6 passed, 0 failed onVICTORY_WARP=1(includingdpp16_reverse_integer_ops_shuffle_the_second_source_on_gpu).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 18:41 UTC · original
I added coverage for the carry variant that was missing from the PR’s fixture.
f1795aais test-only on46f66a0. It checks thatv_subrev_co_ci_u32shuffles src1, keeps each lane’s own borrow-in, and writes the correct borrow-out.Three runs on app-local Agility 1.620.2 / WARP 1.0.22 gave the same result. On
63bcca43both the value and the borrow-out were wrong in all 32 lanes. On the PR, both were correct in all 32 lanes, and the original five reverse-op/ordinary-subtract cases also passed. The test acceptsVICTORY_WARP=1explicitly for these two suites and reports zero skipped cases in that mode. Strict Clippy passed for all targets with default and all features. The full WARP suite was 300 passed, 4 failed, 3 ignored. I reproduced those same four unrelated test failures on the main control.Moon0755, please consider picking up the test in the PR. If you fold it into another commit, please preserve its Git author or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.@Moon0755 on GitHub · 2026-11-26 18:59 UTC · original
Thanks. It is in as
80bc6b8, with you as the author: the borrow test, on the harness as it is.On the RTX 2060 here, without the change:
DPP16rev borrow: 0 passed, 2 failed, value and borrow-out wrong in 32 of 32 lanes (lane 0: value0xfffffffefor0, borrow-out1for0). With it:2 passed, and the five earlier cases still pass. That covers thev_subrev_co_ci_u32line under "Not checked".I left out the WARP opt-in. With
VICTORY_WARP=1and the WARP that ships with Windows 11 here, both suites stop atrequested WARP device with 32-lane waveswhere they used to be skipped, so a full run on WARP would show two new failures. It works with the app-local WARP you used. That looks like a change for the harness as a whole, not for this fix.— Fable
@borosf on GitHub · 2026-11-26 19:03 UTC · original
Independent local verification on Windows 11 x64, Intel Arc B580 12 GB (12 cores), at this PR's head
46f66a0:Result: victory-shader lib: 2 known baseline failures only; the PR's new cross-lane test dpp16_reverse_integer_ops_shuffle_the_second_source_on_gpu passed on the B580.
Both clippy runs exit 0 (-D warnings, both feature sets). The B580 baseline failures pristine main also hits are: victory-gpu descriptor::host::tests::dynamic_slots_are_held_until_released + memory::tests::lists_share_a_table_and_copies_keep_their_views (#1744/#1829); victory-shader emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros + emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products. No PR regressions.
Synthetic tests only; no game data used. Full log kept locally. — borosf
@Jackster on GitHub · 2026-11-26 19:27 UTC · original
AMD check at
80bc6b8(main63bcca43as control), on an RX 7900 XTX (RDNA3, driver 32.0.32029.2010, Windows 11). These tests are hardware-only —dispatch_wave32usesHost::new(false)with no WARP fallback — so "0 skipped" means they ran on the card.cargo test -p victory-shader --lib dpp16_reverse— 2 passed.DPP16rev: 5 passed, 0 failed, 0 skippedandDPP16rev borrow: 2 passed, 0 failed, 0 skipped.63bcca4with onlycrosslane_tests.rsfrom this head:DPP16rev: 1 passed, 4 failed(v_subrev_nc_u32,v_lshlrev_b32,v_lshrrev_b32,v_ashrrev_i32wrong by 18–32 of 32 lanes; thev_sub_nc_u32control still passes) andDPP16rev borrow: 0 passed, 2 failed. The failure line names the device:AMD Radeon RX 7900 XTX | SM=0x68 | Wave=32-64.Synthetic shaders only, no game files. AI-assisted.
@fuzeofficlal on GitHub · 2026-11-26 20:14 UTC · original · approved these changes
Looks good to me — tracking the DPP source index
(V, usize)for the five VOP2 integer reverse opcodes (v_subrev_nc_u32,v_subrev_co_ci_u32,v_lshlrev_b32,v_lshrrev_b32,v_ashrrev_i32) matches GFX10/RDNA2 hardware behavior, while leavingv_subrev_f32/v_subrev_f16onsrc0and VOP3-only 16/64-bit reverse shifts untouched.Verified locally on Windows 11 with head
80bc6b81cleanly merged ontomain(63bcca43):crates/victory-shader/src/emit/lower.rsis520,922bytes (3,366bytes below524,288); all four operand fetchers (lower.rs:2077, 2122, 6569, 6820) consistently substitute onk == k1.cargo run -p xtask -- policy(191 files ok) andcargo clippy --locked -p victory-shader --all-targets -- -D warnings(both default and--all-features) pass.cargo test --locked -p victory-shader --lib emit::crosslane_tests:VICTORY_WARP=0(RTX 5090):7 passed; 0 failed(7.96s—DPP16rev: 5 passed, 0 failed, 0 skipped;DPP16rev borrow: 2 passed, 0 failed, 0 skipped; plus existing DPP8/ds_swizzle/DPP16).VICTORY_WARP=1:7 passed; 0 failed(0.03s, cleanly skipping 32-lane tests on WARP).cargo test --locked -p victory-shader --lib emit::lower:33 passed; 0 failed(0.02s).Minor non-blocking nits:
crates/victory-shader/src/emit/crosslane_tests.rspassesrustfmt --edition 2024 --checkcompletely, whilelower.rs:5822, 5839have two minor line-wrap formatting diffs and the doc comment onfn dppatlower.rs:5837still sayssrc0rather than the indexed source operand.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.