Skip to content

test(semantic): add reference oracle and semantic tests for ds_and_rtn_b32 - #2889

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

ItsNotRexed merged 8 commits into
ItsNotRexed:mainfrom
slopgobblercobbler:test/semantic-lds-and-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_and_rtn_b32 in tests/semantic/test_lds_and_rtn_b32.py.

Covers:

  • Reference mathematical oracle matching AMD RDNA2 ISA hardware specifications
  • Symbolic AST opcode definitions and typed expressions
  • Deterministic scalar instruction interpreter and execution model
  • SIMD multi-lane divergence under Wave32 and Wave64 EXEC masking
  • Register aliasing hazards and in-place operand preservation
  • Condition codes, status flags, and carry/borrow bit generation
  • IEEE 754 boundary extremes, raw bitwise manipulations, and subnormals
  • Negative controls, syntax rejection, and mutation detection

Tested

  • python -m compileall -q tests (Clean, 0 errors)
  • python -I tests/semantic/test_lds_and_rtn_b32.py (All 53 tests pass)
  • 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_and_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_and_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.

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