Repository navigation
rdna2spirv: a 32-bit literal in v_cmp(x)_*_i64 is sign-extended (BUILD-713, on top of #2060) - #4106
controldebils wants to merge 7 commits into
Conversation
…does Measured natively on gfx1036 with the hardware oracle: a 32-bit literal in a 64-bit integer operand is sign-extended where the operand is i64 (s_ashr_i64, s_bfe_i64, s_flbit_i32_i64, v_ashrrev_i64, v_mad_i64_i32 S2) and zero-extended where it is b64/u64. The translator zero-extended every literal. New imm64() helper, design.md row, GPU test cs_w32_lit64 and its semantic fixture. AI-assisted.
# Conflicts: # runtime/test/shaders/check.py
Conflicts: docs/design.md AI-assisted.
Conflicts: docs/design.md runtime/test/shaders/check.py scripts/run_gpu_tests.py tests/semantic/regen_fixtures.py AI-assisted.
docs/design.md AI-assisted.
runtime/test/shaders/check.py scripts/run_gpu_tests.py tests/semantic/regen_fixtures.py AI-assisted.
…D-713, on ItsNotRexed#2060) On top of ItsNotRexed#2060's imm64: the ordered and equality 64-bit compare paths sign-extend a literal for _i64 and zero-extend it for _u64, as measured on an RX 6900 XT (gfx1030, tools/hw_oracle, wave32 and wave64 identical). test_literal64_sign.py holds the 114 gfx1030 cases; for every op both measured they agree with ItsNotRexed#2060's gfx1036 words, and the 6 v_cmp_*_i64 cases fail without this change. The design.md row lists the compares and the second chip. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kam471
left a comment
There was a problem hiding this comment.
Tested 948e8170 on Windows 11, RTX 5070 Ti.
python tests/semantic/test_literal64_sign.py-> 1 test, OK;python tests/semantic/test_lit64_sext.py-> 3 tests, OK.python -I scripts/run_gpu_tests.py --build ... --filter lit64-> 1/1 passed; translator 1 shader, 1 pass spirv-val.cs_w32_lit64returned0xF8000000 0xFFFFFFFF 0x30 0xFFFFFFFF 0xFFFFFFFF 0x8 0x20 0xFFFFFFFF.
The sign-extension of the 32-bit literal in v_cmp(x)_*_i64 is exact on this device, and the fixture is exercised on the GPU rather than only the interpreter. The branch is #2060's head plus this commit; only the last commit is new, as noted. No blocker.
|
Automated test:
Same machine and setup as my earlier manual reports. AI-assisted (Claude Code). |
|
Thanks @CaravelaLabs. The two wrong words are high words that should be AI-assisted (Claude Code). |
|
Tested at the head on Windows 11 / Python 3.13.0: the new test is 1 test / 114 cases / 38 ops, all OK, and it runs The rule is right: Note for the merge: this branch is Approve. AI-assisted review, no game files, no GPU. |
|
Re-checked
AI-assisted. |
|
Follow-up,
So this is the same Mesa 25.2 ACO class as |
BUILD-713 (claim). AI-assisted (Claude Code).
Depends on: #2060 (@Vonsek, EGEN-HW-LIT64). This branch is #2060's head
bc6d77d7plus one commit. #2060 already sign-extends a 32-bit literal in the five i64 operands it measured on gfx1036 and addsimm64and the "64-bit operand literals" row; I had missed it when I claimed BUILD-713 (thanks @ray3242). This PR keeps only what #2060 doesn't cover.What and why
On RDNA2 a 32-bit literal with bit 31 set in a
v_cmp(x)_*_i64source is sign-extended, like the other i64 operands:v_cmp_eq_i64matches0xffffffff_80000000, andv_cmp_gt_i64 0x80000000, 0is false.v_cmp(x)_*_u64zero-extends it. #2060's translator zero-extends the literal in all 64-bit compares.Changes
tools/rdna2spirv.py: the ordered (lt/le/gt/ge) and equality (eq/ne/lg) 64-bit compare paths call rdna2spirv: a 32-bit literal in an i64 operand is sign-extended, as on RDNA2 #2060'simm64(v, op.endswith("_i64")). Two lines.docs/design.md: rdna2spirv: a 32-bit literal in an i64 operand is sign-extended, as on RDNA2 #2060's "64-bit operand literals" row listsv_cmp(x)_*_i64as sign-extended andv_cmp(x)_*_u64as zero-extended, and records the gfx1030 confirmation.tests/semantic/test_literal64_sign.py(new): 114 cases measured on gfx1030 asint_hw_probebodies with the hardware's words, run through the translator.Tested
tools/hw_oracle, wave32 and wave64 identical. 114 cases, 38 operations × literals0x80000000,0xffff0000,0xc0000001. For every op both PRs measured, gfx1030 gives the same rule as rdna2spirv: a 32-bit literal in an i64 operand is sign-extended, as on RDNA2 #2060's gfx1036.v_cmp_gt_i64/v_cmp_eq_i64(the same 6 @ray3242 found); reverting the two lines brings them back.tests/semantic/test_lit64_sext.pyOK,regen_fixtures.py --checkOK;run_gpu_tests.py --filter cs_w32_lit64on the RX 6900 XT:PASS 4160749568 4294967295 48 4294967295 4294967295 8 32 4294967295.python -m unittest discover -s tests/semantic: 7460 tests, 7 failures and 2 errors, the same 9 as on rdna2spirv: a 32-bit literal in an i64 operand is sign-extended, as on RDNA2 #2060's head without this commit (5 intest_loop_ballot_barrier, which tests: test_loop_ballot_barrier follows #2089's structured wave64 emulation (main red since 1cc7497b) #3995 fixes;test_mutationsonv_mul_legacy_f32; twotest_cmp_class_f64rejected forms).tests/test_translate.py: 583 passed, 4 skipped.tests/test_docs_*.py,python -m compileall -q make_game.py tools tests: OK.Not measured:
v_cmpx_*_i64on its own (it shares the operand path withv_cmp), gfx1013 (the console) and RDNA1. No game data, keys or decryption.🤖 Generated with Claude Code