feat(shader): implement s_cmovk_i32, s_version and s_setreg_imm32_b32 #333
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/333"
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?
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-02T06:52:46Z.
What
Three SOPK opcodes threw
unsupported SOPK opcode. The ISA sweep found them.s_cmovk_i32(0x02):if (SCC) D = sext(simm16). Measured on an RDNA2 GPU:0x8001writes0xffff8001, and with SCC clear the register is unchanged.s_version(0x01): marker for the ISA version, no effect.s_setreg_imm32_b32(0x15): likes_setreg_b32, but the value is a literal dword that follows the instruction. The decoder now consumes that literal, so the next instruction decodes from the right word. Likes_setreg_b32, it is translated as a no-op.s_setreg_b32already ignored its writes without being listed. Both are now listed under silent stubs indocs/dev/TechnicalDebt.md: writes to MODE (rounding/denormals) and the other hardware registers have no effect.Test
agc_driver_scalar_sopk_misc:s_cmovk_i32taken (negative and positive immediates) and not taken, plus ans_mov_b32right afters_setreg_imm32_b32to check the literal is skipped. Expected values were measured on the RDNA2 GPU.Tested
Linux, full ctest (99) passes.
cmovk_not_taken is 0x00007fff, expected 0x22222222.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-02T07:02:17Z.
Progress report (
cd61f15→eff7af9)📈 GPU shader instructions: 73.41% (+0.25%, +3 implemented instructions)
✅ 3 implemented
S_CMOVK_I32S_SETREG_IMM32_B32S_VERSIONImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T05:41:37Z.
Thanks,
s_cmovk_i32ands_versionlook right to me (I checked the SOPK encodings with llvm-mc for gfx1013, and the literal skip is a good catch).One thing I can't merge as is:
s_setreg_imm32_b32becomes a silent no-op and is listed under silent stubs. CONTRIBUTING limits silent stubs to UI-only behaviour that unblocks a title, and a MODE write changes rounding and denormal results. Since the value here is a literal, could the translation accept only writes that leave what the recompiler models unchanged and throw for anything else (or leave the opcode throwing for now)? The existings_setreg_b32no-op is worth recording, but under "Functional" in TechnicalDebt.md rather than "Silent stubs". With that split, the rest is ready from my side.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-04T06:28:55Z.
Thanks, agreed. Rebased onto main and changed it:
s_setreg_imm32_b32is a no-op only when it writes 0 (round to nearest even) inside MODE's FP_ROUND bits [3:0]. Any other register, a field that reaches the denormal bits, or a nonzero value throws.hwreg(MODE, 0, 4), 0xf) is refused. The refusal check fails if the guard is removed.s_setreg_b32no-op is recorded under "Functional".Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-04T22:37:53Z.
Thanks, that's exactly the split I meant.
s_setreg_imm32_b32is now a no-op only for a write of 0 into MODE's FP_ROUND bits (hwreg id 1, offset plus size within bits 3:0), which is round to nearest even and what the recompiler assumes; any other register, a field that reaches the denormal bits, or a nonzero value throws. The refusal test covers the round toward zero case, and the existings_setreg_b32no-op now sits under "Functional" in TechnicalDebt.md.agc_driver_scalar_sopk_miscpasses on my NVIDIA machine on current main, and fails on main's code.All three are opcodes main refused, so this is ready to merge from my side.