shader: lower s_pack_ll/lh/hh_b32_b16 #89
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!89
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-89"
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:22 UTC · original
lcg007xd-c:shader-s-pack→main· +76 −0 · 2 files · 1 commits · openWhat is broken
The scalar packs decode, but a program using one fails to translate with
s_pack_ll_b32_b16 is not supported(or the matching name):s_pack_ll_b32_b16s_pack_lh_b32_b16s_pack_hh_b32_b16Compilers use them to build packed 16-bit constants and operands for the
v_pk_*instructions.How I found them: I translated, through the CPU harness of #62, a one-instruction program for every SOP1 and SOP2 opcode the decoder names, with the result in
s12. The scout coverage run useds10, which overlaps the program's UAV descriptor ins[8:11], so it reported nearly every scalar op as "a descriptor changed after loading". Withs12, 50 scalar opcodes turn out to be refused, and these three are among them.Semantics
AMD's RDNA2 ISA (§12.1, opcodes 50–52):
s_pack_ll_b32_b16:D = {S1[15:0], S0[15:0]}s_pack_lh_b32_b16:D = {S1[31:16], S0[15:0]}s_pack_hh_b32_b16:D = {S1[31:16], S0[31:16]}They write no SCC. The IR's
writes_sccalready leaves them out.The change (
emit/lower.rs, insop)Each source's named half is masked or shifted into place, and the two are ORed.
Tests
emit::lower::tests::scalar_packs_translate(every host): all three decode, and a program that moves the result tov0and stores it translates. Without thelower.rschange it fails:s_pack_ll_b32_b16 [990c0100, 7e00020c]: GFX10 code at 0x24: s_pack_ll_b32_b16 is not supported.valu_tests::scalar_packs_take_the_halves_their_names_say(Windows/GPU): two hand-computed cases per opcode.lli. I compared against a Rust reference on 60 scrambled pairs per opcode, also with src0 an inline constant (−1) and a 32-bit literal. 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
SOP2 0x32..=0x34 decoded but failed to translate ("s_pack_ll_b32_b16 is not supported"). AMD's RDNA2 ISA: D = {S1 half, S0 half}, taking the low (l) or high (h) half of each source as the name orders them, S0 first. 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.