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--gone-20261201!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]>@lmouz823-lang on GitHub · 2026-11-28 06:11 UTC · original
I can take native Windows GPU validation at exact head
91f81aea7b4ac5319958a26dd72a5ad91aa23d62. I will run both existing exact regressions and add focused fixed-expectation coverage for SCC preservation, destination retention and conditional-immediate boundaries. I will verify a targeted negative control and restored-source recompilation on RTX 4060 Laptop and WARP with the SDK validator, then report counts, skipped cases and the remaining native AMD/game scope with a small patch. AI-assisted with Codex.@lmouz823-lang on GitHub · 2026-11-28 06:21 UTC · original
Native Windows GPU validation completed for exact head
91f81aea7b4ac5319958a26dd72a5ad91aa23d62. The original translation and GPU tests each execute exactly one test and pass. The original GPU test runs 16 dispatches across RTX 4060 Laptop and WARP.I added one 67-line fixed-expectation regression. Two input pairs include zero and nonzero values in each old and replacement dword. The test reads the conditional result and outgoing SCC separately for
s_cmov_b32, both halves ofs_cmov_b64, ands_cmovk_i32with immediates0,0x7fff,0x8000and0xffff. Its two SCC configurations use a constant carry seed of 0 or 1. The existing test supplies an additional uniform comparison-based condition.The new test has 13 operation/readback configurations times two incoming flags, giving 26 shaders. Each shader runs two inputs on two backends, for 104 passing dispatches. It checks retention of the old destination when SCC is clear, replacement when SCC is set, sign extension of the immediate, and preservation of SCC. Expectations follow AMD's RDNA2 ISA, Table 12, SOP1 opcodes 5/6 and SOPK opcode 2.
A temporary IR mutation incorrectly marks
s_cmov_b32as an SCC writer. The existing result-only GPU test still passes. The new test fails on hardware with incoming SCC 0 and old low dword0x89abcdef, observing outgoing SCC 1 where the fixed expectation is 0. That exact test runs one test and exits 101. After restoring the IR bytes and removing diagnostics, I confirmed fresh compilation before the final three exact selections passed again. Each has zero failed or ignored tests and no skip diagnostics.The explicitly selected SDK
dxil.dll1.8.2502.11 successfully createdIDxcValidator. Temporary markers after load and after DXIL validation plus the container-hash assertion confirmed all 26 new modules and all four original modules passed those checks. The markers were removed for the final runs. Independent review checked the fixed values, encodings, registers, counts and restoration evidence.Environment was Windows 11 Pro build 26200, i9-14900HX, NVIDIA 610.88 and Rust 1.98.1 MSVC, release. Package Clippy with
--all-targets -- -D warnings, asset policy, new-function rustfmt andgit diff --checkpass. Whole-file rustfmt exits 1 on both original and final source, with the same 17 existing formatting hunks after file/line headers are removed. Native AMD execution, game behavior, other platforms and the remaining shader/workspace suites remain unverified. Coverage is limited to the listed synthetic patterns and incoming flags.Reproduction uses an installed SDK validator and the project's Windows build prerequisites.
AI assistance from Codex covered the test, execution, independent review and this report.
Focused test patch against this PR head
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.