Shaders: all 12 s_cmpk_* SOPK scalar comparisons have no hardware test #867
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#867
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@kss306 on GitHub · 2026-11-24 12:59 UTC · original
All twelve
s_cmpk_*SOPK scalar comparison instructions are implemented incrates/victory-shader/src/emit/lower.rsbut have no hardware test usingbuild_valu_csandrun_casesincrates/victory-shader/src/emit/valu_tests.rs.Affected instructions
s_cmpk_eq_i32s_cmpk_lg_i32s_cmpk_gt_i32s_cmpk_ge_i32s_cmpk_lt_i32s_cmpk_le_i32s_cmpk_eq_u32s_cmpk_lg_u32s_cmpk_gt_u32s_cmpk_ge_u32s_cmpk_lt_u32s_cmpk_le_u32Implementation evidence
lower.rs,sop(), handles boths_cmp_*SOPC ands_cmpk_*SOPK in a shared branch:The SIMM16 sign-extension (
i32::from(imm as i16)) only runs fors_cmpk_*i32variants and is not shared with any other tested instruction.Missing test
valu_tests.rscontains no call tobuild_valu_cswith anys_cmpk_*word. The SOPK encoding puts the opcode and source register in the high 16 bits and the signed 16-bit immediate in the low 16 bits:For example,
s_cmpk_gt_i32 s0, -1=0xB500_FFFF(op=0x5=s_cmpk_gt_i32 at SOPK position, ssrc=0, simm16=0xFFFF=-1).Critical edge case
s_cmpk_gt_i32 s0, -1checks whether s0 > -1 (i.e., s0 >= 0). If sign-extension were missing (treating0xFFFFas+65535instead of-1), all small positive values would compare incorrectly. This is the same class of sign-extension risk that was verified fors_bfe_i32inbfe_signed_and_unsigned_match_rdna2.Suggested test
Add
fn s_cmpk_matches_s_cmp()tovalu_tests.rs. The result is in SCC; reading it back requiresv_cndmask_b32froms6:The test skips gracefully when no SM 6.6 device is available and runs on WARP. No game data needed.
AI-assisted: found with Kiro (Claude) and independently confirmed by five separate analysis passes without cross-contamination; no hardware run, no game data.
@MichaelSmithAI on GitHub · 2026-11-24 13:06 UTC · original
Daniel added the hardware test on
ffe310e. It uses all 12 GFX1030 assembler-checked SOPK comparison encodings and immediately consumes each SCC result withs_cselect_b32, so the readback observes the comparison itself. One correction to the example:s_cmpk_gt_i32 s0, -1encodes as0xb280ffff;0xb500ffffencodess_cmpk_lg_u32 s0, 0xffff.All 72 results (six inputs per instruction) matched on RTX 4090 under Wine/vkd3d-proton 3.2. Using the same immediate bits for −1 and 65,535 exercises the signed and unsigned paths, with inputs below, at, and above each comparison point. Wine's WARP enumeration returned the same hardware adapter. The commit adds only the test. Patch on main
@fuzeofficlal on GitHub · 2026-11-24 13:09 UTC · original
I replayed
777177dunchanged on native Windows. All 72 comparisons passed on the default hardware adapter and all 72 passed again on software WARP. Neither backend was skipped. This adds a native D3D12 and software result to the Wine run above.@Marvisak on GitHub · 2026-11-25 06:55 UTC · original
Automated triage for the maintainers.
Correct:
s_cmpk_*is lowered insopincrates/victory-shader/src/emit/lower.rs(with the 16-bit immediate sign-extended for the_i32forms), andemit/valu_tests.rsonmainhas no test for it. Open PR #1046 ("Shaders: hardware test for the s_cmpk_* scalar comparisons") adds that test, and #1875 covers the SOPK forms of the carry chain, so review can continue there. The test in the comments (777177d, all 72 cases on Wine, native hardware and WARP) can be compared against #1046. Note the encoding correction in the comments:0xb500ffffiss_cmpk_lg_u32, nots_cmpk_gt_i32.Left for the maintainers.
Generated by Claude Code