pixel_aot: the last three SOPK forms (s_call_b64, s_subvector_loop_begin/end) — scope question #1779

Open
opened 2026-11-24 18:38:44 +00:00 by JB2WIN · 1 comment
JB2WIN commented 2026-11-24 18:38:44 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-24T18:38:44Z.


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, label

LLVM 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 through s_setpc_b64 (or s_swappc_b64) of that pair. pixel_aot lowers 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:

  • the callee is a straight-line block inside the program;
  • the callee ends in s_setpc_b64 of the unmodified saved pair;
  • nothing in the callee reads or writes that pair;
  • the callee contains no further call or branch.

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_b64 and an indirect s_setpc_b64 of anything else would be refused. That would cover s_call_b64 and the matching s_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_end

LLVM 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).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588840545 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1786). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-24T18:38:44Z. --- 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, label` LLVM 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 through `s_setpc_b64` (or `s_swappc_b64`) of that pair. `pixel_aot` lowers 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: - the callee is a straight-line block inside the program; - the callee ends in `s_setpc_b64` of the unmodified saved pair; - nothing in the callee reads or writes that pair; - the callee contains no further call or branch. 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_b64` and an indirect `s_setpc_b64` of anything else would be refused. That would cover `s_call_b64` and the matching `s_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_end` LLVM 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 commented 2026-11-24 20:01:16 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-24T19:08:13Z.


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) gives D.u64 = PC + 4; PC = PC + signext(SIMM16 * 4) + 4, and section 4.2 (PDF p. 35) gives SGPR_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:

  • begin: if EXEC[63:0] == 0, jump past the loop. Otherwise, if EXEC_LO == 0, set D0 = EXEC_LO and run the high pass only. Otherwise set D0 = EXEC_HI; EXEC_HI = 0 and run the low pass.
  • end: if EXEC_HI != 0, set EXEC_LO = D0. Otherwise, if S0 == 0, the loop is done. Otherwise set EXEC_HI = D0; D0 = EXEC_LO; EXEC_LO = 0 and jump back for the second pass.
  • Constraints: section 4.2.1 adds that the body must not let the working half of EXEC go to zero. The document says the opcodes have "well-defined semantics in wave32 mode".

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_HI as zero in wave32. If they do, the begin/end pair is a skip on an empty EXEC that leaves D0 = 0 and 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". The V_CVT_F32_F64 entry 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).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7141652922 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/1786#issuecomment-7141652922). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-24T19:08:13Z. --- 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) gives `D.u64 = PC + 4; PC = PC + signext(SIMM16 * 4) + 4`, and section 4.2 (PDF p. 35) gives `SGPR_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: - **begin:** if `EXEC[63:0] == 0`, jump past the loop. Otherwise, if `EXEC_LO == 0`, set `D0 = EXEC_LO` and run the high pass only. Otherwise set `D0 = EXEC_HI; EXEC_HI = 0` and run the low pass. - **end:** if `EXEC_HI != 0`, set `EXEC_LO = D0`. Otherwise, if `S0 == 0`, the loop is done. Otherwise set `EXEC_HI = D0; D0 = EXEC_LO; EXEC_LO = 0` and jump back for the second pass. - **Constraints:** section 4.2.1 adds that the body must not let the working half of EXEC go to zero. The document says the opcodes have "well-defined semantics in wave32 mode". 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_HI` as zero in wave32. If they do, the begin/end pair is a skip on an empty EXEC that leaves `D0 = 0` and 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". The `V_CVT_F32_F64` entry 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).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows#1779
No description provided.