shader: lower s_sext_i32_i8 and s_sext_i32_i16 #91
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/uiliannn--VItoriaBr!91
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-91"
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?
@lcg007xd-c on GitHub · 2026-11-25 22:24 UTC · original
lcg007xd-c:shader-s-sext→main· +64 −0 · 2 files · 1 commits · openWhat is broken
s_sext_i32_i8(SOP1 0x19) ands_sext_i32_i16(SOP1 0x1A) decode, but a program using either fails to translate withs_sext_i32_i8 is not supported(or thei16name). They sign-extend a byte or a short held in an SGPR, which compilers emit forint8/int16loads and for packed constants.How I found them: I translated every SOP1/SOP2 opcode the decoder names through the CPU harness of #62, with the result in
s12. The earlier coverage run wrotes10, which overlaps the UAV descriptor, so it could not see scalar gaps. The same sweep found thes_pack_*gap (#89).Semantics
AMD's RDNA2 ISA (§12.2, opcodes 25 and 26):
D.i = signext(S0.i[7:0])andD.i = signext(S0.i[15:0]). They write no SCC, and the IR'swrites_sccalready leaves them out.The change (
emit/lower.rs, insop)Each is a shift left by 24 (or 16) followed by an arithmetic shift right by the same amount.
Tests
emit::lower::tests::scalar_sign_extensions_translate(every host): both decode, and a program that moves the result tov0and stores it translates. Without thelower.rschange it fails:s_sext_i32_i8 [be8c1901, 7e00020c]: GFX10 code at 0x24: s_sext_i32_i8 is not supported.valu_tests::scalar_sign_extensions_match_rdna2(Windows/GPU): three hand-computed cases each, covering negative and positive bytes and halves with junk above them.lli. I compared against Rust'sas i8/as i16casts on 80 scrambled inputs, plus a 32-bit literal source. All match.Run here (Linux, Rust 1.98.1):
cargo test -p victory-shader --lib --locked: 188 passed, 0 failed, 2 ignored.CARGO_FEATURE_PURE=1 cargo clippy -p victory-shader --all-targets --target x86_64-pc-windows-msvc -- -D warnings: clean.Not run here: the GPU case, since I have no Windows machine.
🤖 Generated with Claude Code
SOP1 0x19 and 0x1A decoded but failed to translate ("s_sext_i32_i8 is not supported"). AMD's RDNA2 ISA: D.i = signext(S0[7:0]) and signext(S0[15:0]); they write no SCC. Co-Authored-By: Claude Opus 5.5 <[email protected]>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.