rdna2spirv: scalar pair moved into VCC gives lane-dependent 64-bit population counts #2598
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-29T00:35:04Z.
On main
48bae6cade49aea69f63eb8871572dcd6931cd4b, moving a scalar register pair into VCC withs_mov_b64changes the result of the following 64-bit population count. For input(1, 0), every lane should report one set bit. On the RTX 4090 one lane reported 64 and the other 63 reported zero. Two separate 32-bit moves into VCC give the expected result, as does counting the source register pair directly.The affected path is in Gen.mov64. In this shader it converts the source to a per-lane mask and stores the same value in both VCC words. This matters on main with the bit-count reader from #1973. A related producer problem was previously observed with a different consumer on #1990.
Reproduce on CPU
Save the following as a Python file and run it with
python -Ifrom the repository root. It uses the existing semantic-test interpreter and writes one output word per logical lane.Both interpreter modes returned
{64: 1, 0: 63}. Expected{1: 64}. Replacing the pair move withs_mov_b32 vcc_lo, s4ands_mov_b32 vcc_hi, s5returned{1: 64}.GPU readback
Windows 11 build 26300, Ryzen 7 7800X3D, RTX 4090 driver 616.64, Python 3.13.18, SPIRV-Tools 2026.4. I built the translator fixtures and the CMake
vk_compute_testharness at the revision above. The physical GPU ran one 64-lane workgroup per input withLEONIDA_W64_EMULATE=1, subgroup size 32 and Khronos validation enabled.Only the all-zero and all-one inputs passed in the first row. All three modules passed
spirv-val --target-env vulkan1.2. All 24 dispatches preserved the 16 guard words and produced zero Vulkan validation errors. The inputs and shaders were synthetic.Coordination claim. AI-assisted with OpenAI Codex (GPT-6).
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-29T01:07:16Z.
The attached four-file patch fixes the reported pair move on
aa52446f7db3c68756133792d33c0cff95c7e46c. It keeps both scalar words in VCC when neither source register has held a lane mask. That treatment was previously limited to shaders that also used VCC as a load address. A genuine saved compare mask still takes the mask path.RTX 4090, Windows 11, NVIDIA 616.64. I built
vk_compute_testat the stated revision and ran the synthetic shaders with wave64 emulation and Vulkan validation enabled.The regression fixture also stores a conditional selection for each lane. Those eight dispatches matched all 1,024 output words. A separate fixture wrote a vector comparison into an SGPR pair and moved that genuine mask into VCC. All 896 output words matched across seven cases, including thresholds on either side of lane 32. All 39 patched dispatches preserved their guard words and completed with zero Vulkan validation errors.
CPU. The new test failed all six input/mode combinations before the change and passed all six after it. The semantic suite ran 6,507 tests across 526 files. The only failing module was
test_valu_cvt_f16_int16_mods, with the same two failures on the untouched base. The separate docs-link check also reproduced the same missing README anchors on the base. The changed-file game-data check andgit diff --checkpassed.The patch is ready for review. I verified that applying it to the base reproduces the tested Git tree
48770468f3837041d155df956924021d0886c62f. Coordination claim. AI-assisted with OpenAI Codex (GPT-6).Patch for git am
Copy the following block to
vcc-pair.patchand rungit am vcc-pair.patch.Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-29T03:18:52Z.
Independent Windows CPU verification on
c8bf0e7b6. With only the proposed test and fixture applied, test_b64_bitops_vcc_data.py reported six failing subcases. With the translator patch applied, the same eight tests passed. This checks the synthetic interpreter paths; no Vulkan dispatch or retail run was performed here. AI-assisted with OpenAI Codex (GPT-6).Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-29T15:57:47Z.
Independent Linux GPU check of the posted four-file patch, applied unchanged to current main
1d3da5ebc. Both arms used the samevk_compute_testbuild and synthetic inputs.s_mov_b64into VCC on mainIn every configuration, the scalar count improved from 128/768 to 768/768 words. The lane selection matched all 768 words before and after. Two separate 32-bit writes (12/12) and genuine vector comparison masks moved through an SGPR pair (8/8, including thresholds 31–33) passed on both trees. Those two control modules were byte-identical between trees in both modes.
All 192 offline dispatches preserved their 16 guard words and reported zero Vulkan validation errors. All 12 SPIR-V modules passed
spirv-val --target-env vulkan1.2. The Linux semantic run withLEONIDA_REQUIRE_SPIRV_TOOLS=1ran 6,527 tests in 529 files on each tree, with the new fixture enabled in both. Its six VCC subcases failed on main and passed with the patch. The same two existingtest_interp_computed_ij_fallbackfailures remained on both. Synthetic inputs only. AI-assisted with OpenAI Codex (GPT-6).Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T17:06:42Z.
Closing this issue because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (
d3d12/) available now. Thank you for the report/contribution! If you believe this issue was closed by mistake (for example, if it still applies to active tools,d3d12/, or general docs), please feel free to reopen it.