Skip to content

test(semantic): add reference oracle and semantic tests for ds_xor_rtn_b32 - #2896

Merged
ItsNotRexed merged 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-lds-xor-rtn-b32
Nov 22, 2026
Merged

ItsNotRexed merged 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-lds-xor-rtn-b32

Conversation

@slopgobblercobbler

Copy link
Copy Markdown
Contributor

What and why

Adds a bit-accurate reference mathematical oracle and comprehensive semantic validation suite for ds_xor_rtn_b32 in tests/semantic/test_lds_xor_rtn_b32.py.

Implements the 8-atomic-commit semantic pipeline:

  • Reference mathematical oracle for RDNA2 Local Data Share (LDS) atomic 32-bit XOR with return (ds_xor_rtn_b32) and 64 KiB LDS architectural memory model.
  • Symbolic AST opcode definitions, register operand range verification, immediate offset validation, disassembly formatter, and symbolic expression rewriting for XOR algebra.
  • Deterministic scalar instruction interpreter modeling workgroup LDS memory scratchpad and in-place memory atomic update with operand latching.
  • Wave32 and Wave64 SIMD multi-lane divergence and 32/64-bit EXEC masking with inactive lane preservation and intra-wave collision serialization in lane order.
  • Register aliasing hazards (vdst == vaddr, vdst == vdata0, vdst == vaddr == vdata0) and in-place operand preservation.
  • Condition codes, status flags (Z, N, P, modified, carry-free addition), and carry/borrow generation relations without hardware exception traps.
  • Untyped raw dword IEEE 754 bit-pattern handling: signed zeros (+0.0 / -0.0), normals (+1.0 / -1.0), infinities, subnormals (no flush-to-zero), and NaNs (payload preservation without quietening).
  • Negative controls, syntax rejection, and mutation detection catching swapped operands, unmasked overflows, premature register writeback, and inactive lane leaks.

Tested

  • python -m compileall -q tests (Clean, 0 errors)
  • python -I tests/semantic/test_lds_xor_rtn_b32.py (67/67 tests passing in 0.004s)
  • Standard library Python only (python -I compatible, 0 external dependencies)
  • AI-assisted: yes

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

@Yourrespawn

Copy link
Copy Markdown
Contributor

Same structural note as #2819: ds_xor_rtn_b32 is a real RDNA2 opcode (llvm-mc gfx1030 assembles it), but the suite imports no repo code — it checks its in-file oracle against its in-file interpreter, so it can neither regress nor verify the translator. The repo CPU-checks the LDS atomics and has hardware-verified rows for the family in docs/design.md. Differential wiring against tools/rdna2spirv.py + tests/semantic/spirv_mini_interp.py is what would make it contribute.

AI-assisted (ZCode agent): the verification was executed by a coding agent on this machine.

@evilclanker9000

Copy link
Copy Markdown
Contributor

Measured on gfx1036 (RDNA2, driver 26.10.1, game MODE; integer op), through raw hw_oracle kernels, one lane, LDS dword seeded, then ds_xor_rtn_b32 v4, v1, v3 and a ds_read_b32: every (memory M, data D) pair of {0, 1, 2, 5, 0x7fffffff, 0x80000000, 0xfffffffe, 0xffffffff, 0x12345678}, 81 cases. The returned register is the old word and the word afterwards is M ^ D in all 81. I compared the instruction's behaviour with the formula in this PR's header; the PR's test file and any translation were not part of this run. The script is local, not pushed. AI-assisted.

@ItsNotRexed
ItsNotRexed merged commit d2903c9 into ItsNotRexed:main Nov 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants