pixel_aot: the last three SOPK forms (s_call_b64, s_subvector_loop_begin/end) — scope question #1786
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#1786
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?
@JB2WIN on GitHub · 2026-11-24 18:38 UTC · original
Once #1777 lands, SOPK in the gfx1013 coverage stands at 24/27. The remaining three are not plain ALU. Before building anything, I'd like your view on whether, and how, they should be handled.
s_call_b64 sdst, labelLLVM 15 (
SOPInstructions.td,S_CALL_B64,isCall = 1) defines it with a 64-bit SGPR destination and a branch target, so it saves the return address and jumps. A pixel shader can only come back throughs_setpc_b64(ors_swappc_b64) of that pair.pixel_aotlowers neither of them today, and the block model from #1413 has no notion of returning.Proposed first slice: inline a forward call when all of the following hold:
s_setpc_b64of the unmodified saved pair;The return address would be tracked as an opaque value. Any arithmetic on it, a store, a read in the callee, a recursive or backward call,
s_swappc_b64and an indirects_setpc_b64of anything else would be refused. That would covers_call_b64and the matchings_setpc_b64(SOP1). The test would compare a fixture with a call against the same body without the call, bit for bit, plus refusal controls.s_subvector_loop_begin/s_subvector_loop_endLLVM 15 defines both only as
SOPK_32_BR(an SGPR plus a branch target) with no selection pattern. Its sources therefore say nothing about their semantics, and the AMD ISA document is not reachable from here. Lowering them would mean guessing how they split and restore EXEC around the two wave64 halves, so I would leave them refused until there is a native reference or a quote from the ISA document.Is the call slice worth doing at all? Do you have a source for the subvector-loop semantics? If neither, the three can stay refused, and I'll leave SOPK at 24/27.
AI-assisted (Claude Code).
@JB2WIN on GitHub · 2026-11-24 19:08 UTC · original
KainanP's archived copy of the RDNA 2 ISA (30 November 2020, SHA-256
22aec03f…d44795, checked locally; see #669) answers both parts.s_call_b64. Section 12.2 (SOPK opcode 22, PDF p. 116) givesD.u64 = PC + 4; PC = PC + signext(SIMM16 * 4) + 4, and section 4.2 (PDF p. 35) givesSGPR_pair = PC+4. The return address is therefore the instruction after the call, which is what the proposed inline slice assumes. I'm building that slice locally and will only open the PR after your answer.s_subvector_loop_begin/_end. Section 12.2 (opcodes 27/28, PDF p. 118) defines both completely:EXEC[63:0] == 0, jump past the loop. Otherwise, ifEXEC_LO == 0, setD0 = EXEC_LOand run the high pass only. Otherwise setD0 = EXEC_HI; EXEC_HI = 0and run the low pass.EXEC_HI != 0, setEXEC_LO = D0. Otherwise, ifS0 == 0, the loop is done. Otherwise setEXEC_HI = D0; D0 = EXEC_LO; EXEC_LO = 0and jump back for the second pass.For the guest wave32 profile, section 2.1 (PDF p. 16) says "The upper half of EXEC and VCC are ignored for wave32 waves". It does not say whether these two opcodes still read
EXEC_HIas zero in wave32. If they do, the begin/end pair is a skip on an empty EXEC that leavesD0 = 0and runs the body exactly once. That would be lowerable at entry, with a control for the skip, but it rests on an assumption the document does not state. The gfx1030 wave64 profile would need the real two-pass model. If you want either, tell me which one. Otherwise I'll leave them refused.#1606, for completeness. The MODE table (PDF p. 23) defines
[1:0]as "single precision round mode" and[3:2]as "Double/Half-precision round mode". TheV_CVT_F32_F64entry only says "0.5ULP accuracy, denormals are supported" and does not name a field. So the document does not settle the question there either.AI-assisted (Claude Code).