shader: lower s_bfe_u64, s_bfe_i64 and s_bfm_b64 #97
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!97
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-97"
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:34 UTC · original
lcg007xd-c:shader-s-bfe64→main· +154 −0 · 2 files · 1 commits · openWhat is broken
The 64-bit scalar bitfield instructions decode, but a program using one fails to translate with
s_bfe_u64 is not supported(or the matching name). Their 32-bit forms (s_bfe_u32,s_bfe_i32,s_bfm_b32) already lower.s_bfe_u64s_bfe_i64s_bfm_b64They are part of the scalar gap the sweep through the CPU harness of #62 turned up (see #89).
Semantics (AMD's RDNA2 ISA, §12.1, opcodes 37, 41, 42)
s_bfe_u64:D.u64 = (S0.u64 >> S1[5:0]) & ((1 << S1[22:16]) - 1)andSCC = (D != 0).s_bfe_i64sign-extends the field from its top bit.s_bfm_b64:D.u64 = ((1 << S0[5:0]) - 1) << S1[5:0]. It writes no SCC.bfehelper already treats a width of 32 or more fors_bfe_u32.The change (
emit/lower.rs, insop's 64-bit section)INT64flag), mirroring the 32-bitbfehelper: a full-width mask, then a sign extension skipped for widths 0 and ≥ 64.Tests
emit::lower::tests::scalar_64_bit_bitfields_translate(every host): all three decode, and a program that stores the result translates. Without thelower.rschange it fails:s_bfe_u64 [948c0200, 7e00020c]: GFX10 code at 0x24: s_bfe_u64 is not supported.valu_tests::scalar_64_bit_bitfields_match_rdna2(Windows/GPU): both dwords of each result for four cases: a field across the dword boundary, a sign-set top nibble, width 64, and width 0.lli. I compared both dwords against a Rustu64/i64reference on 38 cases. They include widths 1, 32, 63+, 127 and junk in S1's other bits, plus SCC for both extracts. 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. I could not check widths above 64 on RDNA2 hardware, so they follow the 32-bit lowering's rule.
🤖 Generated with Claude Code
SOP2 0x29, 0x2A and 0x25 decoded but failed to translate ("s_bfe_u64 is not supported"): the 64-bit forms of s_bfe_u32/s_bfe_i32/s_bfm_b32. AMD's RDNA2 ISA: s_bfe extracts a field of width S1[22:16] at offset S1[5:0] (sign-extended for _i64; a width of 64 or more takes every remaining bit, as the 32-bit lowering does for 32), SCC = (D != 0); s_bfm_b64 builds ((1 << S0[5:0]) - 1) << S1[5:0] with no SCC. Computed in 64-bit integers. 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.