shader: set the SCC of s_lshl<n>_add_u32 from the 64-bit overflow #86
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!86
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-86"
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?
@Olima34 on GitHub · 2026-11-26 13:52 UTC · original
Olima34:fix/shader-lshl-add-scc→main· +56 −2 · 3 files · 2 commits · merged 2026-11-26 15:01 UTCWhat this changes
ir::writes_scclistss_lshl1_add_u32..s_lshl4_add_u32as writing SCC, but their arm returned no carry, so SCC fell to the defaultresult != 0:s_lshl1_add_u32 1, 2gave 4 with SCC 1 instead of 0, ands_lshl4_add_u32 0x10000000, 0gave 0 with SCC 0 instead of 1. A followings_addc_u32for a high dword would read a wrong carry; the title forms heap addresses withs_lshl4_add_u32.RDNA2 ISA reference, section 12.1 (SOP2 46-49):
D.u = (S0.u << N) + S1.u; SCC = ((S0.u << N) + S1.u) >= 0x100000000, and the RDNA3 manual writes the sum out in 64 bits, so bits shifted out of S0 count. SCC is now the 32-bit add's carry (add_sub_carry) orS0 >> (32 - N) != 0. Mesa ACO ignores the bits shifted out (it fusess_lshl+s_add_u32even when SCC is read); the manual is followed, and docs/native-host.md says so. The signed-overflow SCC ofs_add_i32/s_sub_i32is left for another PR.Tests: Windows value probes in
scalar_probes()for the four opcodes over the edge pairs plus1<<1 + 2,0x80000000<<1,0x7FFFFFFF<<1 + 2,0x3FFFFFFF<<2,0x10000000<<4,0x0FFFFFFF<<4 + 0x10and-1<<3 + -1, with the inputs the old SCC got wrong tagged and checked byscalar_shift_adds_set_scc_from_the_overflow.How it was tested
cargo test -p victory-shader(the value probes run only in the Windows CI)cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings, also with--all-featurescargo test --workspaceandcargo xtask policyChecklist
VICTORY_*variable and documented (none added)@LakshanSivakumar on GitHub · 2026-11-26 14:54 UTC · original · approved these changes
Looks right against the ISA (SCC from the 64-bit sum), thanks for documenting the ACO difference.