shader: lower s_cmov_b32, s_cmov_b64 and s_cmovk_i32 #92
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!92
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-92"
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:26 UTC · original
lcg007xd-c:shader-s-cmov→main· +95 −0 · 2 files · 1 commits · openWhat is broken
The scalar conditional moves decode, but a program using one fails to translate with
s_cmov_b32 is not supported(or the matching name):s_cmov_b32s_cmov_b64s_cmovk_i32The rest of the pipeline already handles them:
ir.rs, "These change (or may keep) the destination's old value");s_cmov(resource.rs).Only the lowering was missing. I found the gap with a scalar sweep through the CPU harness of #62, the same sweep as #89 and #91.
Semantics
AMD's RDNA2 ISA (§12.2 opcodes 5–6, §12.4 opcode 2):
if (SCC) D = S0. Fors_cmovk_i32the value issignext(SIMM16). Otherwise D keeps its value. They write no SCC.The change (
emit/lower.rs, insop)s_cmov_b64: the same select for each dword, besides_cselect_b64.Tests
emit::lower::tests::scalar_conditional_moves_translate(every host): afters_movintos[12:13]ands_cmp_eq_u32 s0, s1, each conditional move decodes, and a program that movess12tov0and stores it translates. Without thelower.rschange it fails:s_cmov_b32 [be8c0502]: GFX10 code at 0x30: s_cmov_b32 is not supported.valu_tests::scalar_conditional_moves_keep_the_destination_when_scc_is_clear(Windows/GPU): each form with SCC set and clear, reading both dwords fors_cmov_b64. The sign-extended0x8000checkss_cmovk_i32.lli: four input sets per form, SCC both ways. 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 0x05/0x06 and SOPK 0x02 decoded but failed to translate ("s_cmov_b32 is not supported"). AMD's RDNA2 ISA: if SCC, D = S0 (for s_cmovk_i32 the sign-extended 16-bit immediate); otherwise D keeps its value. The IR already reads SCC and the old destination for them, and resource tracking already follows descriptors through s_cmov; only the lowering was missing. 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.