Repository navigation
Conversation
Decodes DS_CONDXCHG32_RTN_B64 (DS opcode 0x7E), the last missing DS instruction, with its encoding from the AMD machine-readable RDNA2 ISA spec cross-checked against LLVM's assembler for gfx1031. Implements it as a locked 64-bit LDS atomic like ds_cmpswap_b64: VDST returns the old value pair and each 32-bit half is written iff that half's bit31 is set, storing the data with bit31 cleared - measured on RDNA2 hardware (gfx1031) with the hardware oracle over seven cases covering every write-enable combination and the mask edges. A GDS variant throws: 64-bit GDS atomics are not supported, as for every other 64-bit DS atomic.
This was referenced Oct 8, 2026
popcoder565
added a commit
to popcoder565/AnyPS5
that referenced
this pull request
Oct 8, 2026
… shared lines boykopovar#1372 adds its test after the vop1 decode tests and boykopovar#1314 its debt entry after s_setkill, the places where this branch added its own. The wave control decode test now precedes the vop1 decode tests and the s_sethalt entry follows sceRtcParseDateTime, so either pull request can merge first without a conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adriadam10
pushed a commit
to popcoder565/AnyPS5
that referenced
this pull request
Oct 8, 2026
… shared lines boykopovar#1372 adds its test after the vop1 decode tests and boykopovar#1314 its debt entry after s_setkill, the places where this branch added its own. The wave control decode test now precedes the vop1 decode tests and the s_sethalt entry follows sceRtcParseDateTime, so either pull request can merge first without a conflict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Decodes and implements
ds_condxchg32_rtn_b64(DS opcode 0x7E) — the last DS instruction intools/rdna_isa.txtthat the decoder did not recognize and that no open pull request covers. Shader instructions: 1139/1166 -> 1140/1166.amdgpu_isa_rdna2.xml) — VDST is a B64 pair, ADDR a B32, DATA0 a B64 pair, plus implicit DSMEM — read from the fields every other DS instruction uses;gdsbit 17 is kept ininstruction.gds. Classified as a DS atomic likeds_wrxchg_rtn_b64.data & 0x7FFFFFFF— bit31 is a write-enable flag. Seven oracle cases cover every write-enable combination (both halves, low only, high only, neither), bit31-only and bit30-only immediates, and the mask edges (0xFFFFFFFF,0x80000000,0x00000001as data). A second conditional exchange fed back from LDS confirms the returned value is the state before each write.SharedAtomicCondxchg64IR opcode lowered through the same locked 64-bit LDS path asds_cmpswap_b64(SharedAtomic64, workgroup spinlock viaLockedLdsUpdatewhen analysis requires it), so the read-modify-write is atomic across the wave. The GDS variant throws "64-bit GDS atomics are not supported", consistent with every other 64-bit DS atomic.Sources:
amdgpu_isa_rdna2.xml, DS_CONDXCHG32_RTN_B64, opcode 126 = 0x7E) cross-checked byte-for-byte against LLVM's assembler for gfx1031. The words in the tests areclang --target=amdgcn-amd-amdhsa -mcpu=gfx1031encodings (ds_condxchg32_rtn_b64 v[16:17], v8, v[6:7]->D9F80000 10000608, gds variant ->D9FA0000 ...).tools/hw-oracle); not derived from documentation. The ISA guide describes the same conditional exchange; the measurements pin down the bit31 write-enable and the mask.Tested
Windows 11, NVIDIA Blackwell desktop GPU (driver 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7):
agc_ds_condxchg32_decode,agc_driver_ds_condxchg32_b64and the full suite report100% tests passed out of 406. Conventions check (tools/check_conventions.py) passes.agc_ds_condxchg32_decode: decodes three LLVM-encoded programs (plain,offset:255,gds) and checks opcode, length, operands, offset and gds flag.agc_driver_ds_condxchg32_b64: runs two chained conditional exchanges on the GPU through the recompiler and SPIR-V backend with 32 lanes whose data halves drive every write-enable combination, and checks all eight output dwords per lane against the measured semantics; also checks that the GDS variant is rejected.Not tested: no title or homebrew (LLVM emits this instruction only from explicit assembly, never from intrinsics). Concurrent contention on one LDS address from several lanes is not exercised; the workgroup lock makes the pair access atomic with respect to the other 64-bit LDS atomics, which are not ordered against concurrent 32-bit accesses (TechnicalDebt).
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)