feat(shader): implement S_SWAPPC_B64 and S_RFE_B64 #901
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/901"
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 Kikoarl on 2026-10-06T14:26:47Z.
What
Implement the remaining RDNA 2 SOP1 control flow instructions:
S_SWAPPC_B64(opcode0x21) andS_RFE_B64(opcode0x22), completing the SOP1 instruction category (65/65).S_SWAPPC_B64with destination 64-bit SGPR pairsdst(dataDwordCount = 2) and 64-bit scalar targetssrc0, preserving existing alias toS_SETPC_B64whensdstis the null register (125).S_RFE_B64with null destination and 64-bit scalar targetssrc0.GraphBuilderbasic block boundary discovery and control-flow barriers.Tested
Linux x86_64, unit test
scalar_sop1verifying decoding, 64-bit destination pair, null-destination aliasing, graph builder boundaries, and translation throw path.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-06T14:28:22Z.
Progress report (
68010df→7fe92f9)📈 GPU shader instructions: 97.86% (+0.18%, +2 implemented instructions)
✅ 2 implemented
S_RFE_B64S_SWAPPC_B64Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T08:29:13Z.
Review: CHANGES_REQUESTED
Thanks. Build and ctest are green on top of current
main, and the test encodings matchllvm-mc -mcpu=gfx1013. One semantic problem before merging:s_rfe_b64is modelled as the end of the program (TerminatorKind::Return,GraphBuilder.cpp:523and:571), andScalarControlFlowSop1.cpp:94pins that. On hardware (gfx1035, user mode) it doesn't end the wave: it jumps tossrc0the same ways_setpc_b64does. Measured:s_getpc_b64 s[20:21], thens20 += .Ltarget - .Lpc,s_rfe_b64 s[20:21],v_mov_b32 v10, 1,.Ltarget: v_mov_b32 v11, 2givesv10 = 0, v11 = 2, so thev_movgets skipped and the wave keeps running at the target. Since translation throws, no wrong output gets through today, but the CFG and the test record the wrong behaviour. Please either throw insplitIntoBlocksas you do fors_swappc_b64, or treat it ass_setpc_b64(dynamic target), and update the test to match.SSwappcB64translation case (ScalarInstructions.cpp:32) and thefindLastWriterclause (GraphBuilder.cpp:325) can't be reached, becausesplitIntoBlocksalready throws for every non-null-destinations_swappc_b64. Up to you whether to keep them.Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-07T12:52:38Z.
@adriadam10 Thanks for the hardware measurement and guidance! Rebased on latest main and updated
s_rfe_b64to throw insplitIntoBlocksmatchings_swappc_b64, removed it fromTerminatorKind::ReturninlinkBlocks, and updatedScalarControlFlowSop1.cppto verify thatGraphBuilder::Buildthrows. Ready for review.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T12:58:33Z.
Thanks for following up on the
s_rfe_b64point. With that change, though, the PR no longer changes behaviour: onmainboth opcodes already stop the recompilation ("unsupported SOP1 opcode 33/34"), and here they stop it insplitIntoBlocks/translation with a different message. What remains is decoding plus a throw, which only moves the progress metric (+2 instructions) without making any shader run that didn't before. We closed #980 and the related PRs for the same reason, and we said in our last review that throwing was one of the options, sorry for not flagging this then.Closing for that reason. You're welcome to reopen once
s_swappc_b64(call with a return address) ands_rfe_b64(indirect jump, measured on gfx1035 as behaving likes_setpc_b64) are actually translated, with an execution test that runs through them.Pull request closed