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--gone-20261201!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]>@lmouz823-lang on GitHub · 2026-11-28 08:05 UTC · original
I can take native Windows GPU validation at exact head
91424850be390994344e55cff8d55f209e95bc5d. I will run both existing exact tests, add focused fixed-expectation byte/halfword boundaries and SCC-preservation coverage, and verify a targeted negative control followed by restored-source recompilation. Final runs will use RTX 4060 Laptop and WARP with the SDK validator. Counts, skipped cases and remaining native AMD/game limits will accompany the small patch. AI-assisted with Codex.@lmouz823-lang on GitHub · 2026-11-28 08:18 UTC · original
Native Windows GPU validation completed for exact head
91424850be390994344e55cff8d55f209e95bc5d. The original translation and GPU regressions each execute exactly one test and pass. The original GPU test runs 12 dispatches across RTX 4060 Laptop and WARP.I added one 61-line fixed-expectation regression. Seven inputs cover byte boundaries 0/0x7f/0x80/0xff and halfword boundaries 0/0x7fff/0x8000/0xffff with upper-bit junk. Each input runs with incoming SCC 0 and 1 supplied dynamically through a root constant. The value and outgoing SCC are read separately for both instructions. A real
0xbeef7f80literal additionally checks byte result0xffffff80and halfword result0x00007f80, with both incoming flags preserved. Expectations follow AMD's RDNA2 ISA, the integer arithmetic summary and SOP1 opcodes 25/26.Four main shaders times 14 inputs times two backends give 112 passing dispatches. Four literal shaders times two inputs times two backends add 16, for 128 passing dispatches. The test checks the result and SCC independently through s12 and s15, with the carry seed written to s14.
A temporary IR mutation wrongly lists the
sextstem among SCC writers. The original value-only GPU test still passes. The new test fails on hardware at input0xabcd007fwith incoming SCC 0, reporting outgoing SCC 1 against the expected 0. Its exact selection executes one test and exits 101. After restoring the original IR bytes and removing diagnostics, I cleaned only the isolated shader package release target and confirmed an actual 1m34s compilation before the final new GPU, original GPU and translation exact selections each pass. All three final selections have 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 validation plus the container-hash assertion confirmed all eight new modules and both original modules passed those checks. The markers were removed for the final runs. Independent review checked the fixed values, encodings, registers, counts and source restoration.One preliminary diagnostic-setup assertion incorrectly expected a single validator-load site. This head has separate VALU and wave helper sites, and the assertion stopped before the new function was written. A subsequent test attempt selected zero tests and was rejected by the exact-test runner. Both preparation and zero-selection records are excluded from acceptance. The corrected preparation targets the VALU helper, checks its exit code and verifies the function is present before dependent tests. The preliminary log is retained separately.
Environment was Windows 11 Pro build 26200, RTX 4060 Laptop, NVIDIA 610.88 and Rust 1.98.1 MSVC, release. Package Clippy with
--all-targets -- -D warnings, asset policy (195 files), 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 full shader/workspace suites remain unverified. Coverage is limited to the listed synthetic patterns and flag states.Reproduction uses an installed SDK validator and the project's Windows build prerequisites.
AI assistance from Codex covered the synthetic regression, execution, independent review and this report.
Fixed-expectation regression 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.