Repository navigation
s_lshl<n>_add_u32 sets SCC to its carry - #1972
Open
Melow-code wants to merge 1 commit into
Open
Melow-code wants to merge 1 commit into
Melow-code wants to merge 1 commit into
Conversation
s_lshl1_add_u32 to s_lshl4_add_u32 left whether the result is not zero in SCC. The RDNA 2 ISA gives the unsigned overflow of the whole sum, shifted bits included, so an s_addc_u32 behind one added 1 to the high dword of nearly every address. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 task done
1 task done
|
Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch |
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.
Found by reading the scalar lowering against the RDNA 2 ISA. I found no issue or pull request for it here. It is a known defect elsewhere, with the same formula proposed: Marvisak/VIctory#168 and fxceless/victory-fork#350 (both open; their
s_min/s_maxhalf is already here through #1891). Marvisak/VIctory#2813 refuses such reads instead.What it changes
s_lshl1_add_u32tos_lshl4_add_u32left "the result is not zero" in SCC. The RDNA 2 ISA (12.1) gives the unsigned overflow of the whole sum, shifted-out bits included:An
s_addc_u32behind one, the high dword of a 64-bit address, therefore added 1 whenever the low dword was not zero. A branch or ans_cselectbehind one could take the wrong side.SCC is now the carry: the shift loses a set bit, or the addition wraps. Lyrnc measured this rule, lost bits included, on RDNA 2 hardware (gfx1036) in Marvisak/VIctory#168: 141 of 141 operand pairs for each of the four opcodes.
The change is in
sopinemit/lower.rs. The test evaluator inbitcode.rs(test code) learnsor, zero extension and three integer compares.How it was tested
shift_and_add_leave_their_carry_in_scclowers the four opcodes, each followed bys_addc_u32 s7, 0, 0, and evaluates what the module stores for 13 operand pairs (no carry, each lost bit, wraps, both). It runs on any host, without a device.(0x1 << 1) + 0x2: 1 where 0 is right.s_addc_u32twice, against 64-bit arithmetic, and 5,000 per opcode with a literal, an inline -1 and the destination over a source, read bys_cselect_b32. 400,000 values, no mismatch; both fail with the change reverted.s_add/s_addc,s_sub/s_subb,s_add_i32ands_lshl_b32give the right values before and after.cargo test -p victory-formats -p victory-shader --lib: 57 and 274 passed, 0 failed (5 and 2 ignored).CARGO_FEATURE_PURE=1 cargo clippy -p victory-gpu -p victory-shader --tests --target x86_64-pc-windows-msvc: exit 0, no warning on the changed lines. The existing one invictory-shader(manual_checked_ops) is still there.lower.rsis past thecargo xtask policysize limit on main already.Checked for overlap
🤖 Generated with Claude Code