rdna2spirv: read %vcc and %vcc_hi for plain 64-bit scalar data in s_bcnt/s_ff/s_flbit _b64/_i64 (SHADER-B64-BITOPS-VCC-DATA) #1973
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1973"
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 ShotTechOp on 2026-11-25T17:08:06Z.
Claimed in #1608 as
SHADER-B64-BITOPS-VCC-DATA.What and why
When
vccholds plain 64-bit scalar data (not tracked as a lane mask bytools/lane_masks.py, e.g., written vias_mov_b32 vcc_lo, ...; s_mov_b32 vcc_hi, ...), the 64-bit scalar bit-count and bit-scan instructions mishandledvcc(ands_flbit_i32_{b64,i64}also rejectednull):s_bcnt1_i32_b64/s_bcnt0_i32_b64(tools/rdna2spirv.py): whenself.holds_lane_mask(a[1])wasFalse,vccfell through tolo, hi = (self.mask_src(a[1]), self.cu(0)), dropping%vcc_hicompletely (hi = 0). For example,vcc = (0x3, 0xF)returned2instead of6ons_bcnt1_i32_b64, andvcc = (0xFFFFFFFF, 0xFFFFFFFF)returned32(SCC = 1) instead of0(SCC = 0) ons_bcnt0_i32_b64.s_ff1_i32_b64/s_ff0_i32_b64(tools/rdna2spirv.py): same fallthrough (lo, hi = self.mask_src(a[1]), self.cu(0)), dropping%vcc_hisovcc = (0, 0x8)returned-1instead of35ons_ff1_i32_b64, andvcc = (0xFFFFFFFF, 0xFFFFFFFF)returned32instead of-1ons_ff0_i32_b64.s_flbit_i32_b64/s_flbit_i32_i64(tools/rdna2spirv.py): only accepted SGPR pairs and immediates on the non-mask path, raisingUnsupportedon plain-datavccandnull.Both
s_bitcmp[01]_b64(bitcmp) ands_cmp_eq/lg_u64already handle plain-datavccby loading%vccand%vcc_hi, andnullas(0, 0).Changes
tools/rdna2spirv.py:a[1]/x==vcc(whenholds_lane_mask(...)isFalse) by loading(%vcc, %vcc_hi)andnullas(0, 0)ins_bcnt[01]_i32_b64,s_flbit_i32_{b64,i64}, ands_ff[01]_i32_b64.vcc(holds_lane_mask(...) == True) continues to take the existingwave_mask()path unchanged.docs/design.md:vccandnullhandling in theWave64 mask ballotrow of the translator contract table.tests/semantic/test_b64_bitops_vcc_data.py:s_bcnt1_i32_b64+ SCC,s_bcnt0_i32_b64+ SCC,s_ff1_i32_b64,s_ff0_i32_b64,s_flbit_i32_b64,s_flbit_i32_i64) on plain-datavccacross 9 edge-case(lo, hi)pairs in native wave64,--wave64-emulate, and FSPX wave32 (s_flbit_i32_{b64,i64}), plus lane-mask-to-plain-data transitions,nullsources, and a real lane-maskvcccontrol.Verification
spirv_mini_interp; no GPU, LLVM, or SPIRV-Tools installed locally).python -I tests/semantic/test_b64_bitops_vcc_data.py -vpython -m unittest discover -s tests/semantic -p test_scalar_bitcmp.pypython -m unittest discover -s tests/semantic -p test_salu_flbit_lane_mask.pypython -m unittest discover -s tests/semantic -p test_wave64_vcc_half_write.pypython -m unittest discover -s tests/semantic -p test_scmp_u64_mask_pairs.pypython -m unittest discover -s tests -p "test_docs_*.py"python -I tests/test_text_write_line_endings.pypython -m compileall -q tools/rdna2spirv.py tests/semantic/test_b64_bitops_vcc_data.pypython -I scripts/check_no_game_data.py tools/rdna2spirv.py docs/design.md tests/semantic/test_b64_bitops_vcc_data.pygit diff --checkorigin/main(tools/rdna2spirv.pyatfe15534):tests/semantic/test_b64_bitops_vcc_data.pyfails onorigin/main—test_bcnt_and_ff_plain_vcc_data_reads_high_wordsilently miscompiles all 4(lo, hi)cases (%vcc_hidropped to 0, e.g. returning[2, 1, 62, 1, 0, 2]instead of[6, 1, 58, 1, 0, 2]for(0x3, 0xF)and[0, 0, 64, 1, 0xffffffff, 0]instead of[1, 1, 63, 1, 35, 0]for(0, 0x8)), and all 5s_flbit_i32_{b64,i64}tests raiseUnsupported: s_flbit_i32_b64 source; the lane-mask control passes.Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:16:42Z.
Verified on physical gfx906, native subgroup 64 (RADV Mesa 26.0.8), with synchronization validation enabled. Same eight input pairs on main
d48a957bbanda186754abmerged with it. For example, with VCC low = 0 and high = 8, main reported a population count of 0 and no set bit; the merge returned 1 and bit index 35.The count/find shader went from 2/8 to 8/8 matching readbacks (1,664 wrong output words to zero). Main separately refused the shader containing
s_flbit_i32_b64before dispatch; the merge ran both signed and unsigned leading-bit forms correctly on all eight inputs. The genuine VCC lane-mask and ordinary SGPR-pair controls returned byte-identical data on both trees. Overall: 32/32 merge dispatches matched, 19,456 output words correct, all guards intact, no validation errors.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T00:00:27Z.
Tested
a186754abmerged (no commit) withmainaa918e5d9. Python 3.12.4, Windows 11 10.0.26300, CPU only, withLLVM_MC(conda-forge llvm-tools) and SPIRV-Tools from the Vulkan SDK 1.4.363.1.check_no_game_data.pyis clean.tests/semantic/test_b64_bitops_vcc_data.py, 7 tests pass.tools/rdna2spirv.pyback tomain, 4 failures and 5 errors (e.g.[32, 1, 32, 1, 0, 32] != [63, 1, 1, 1, 0, 35]).Overlap check across #1973, #1977, #1990, #1943, #1994, #1996 and #1803 (same translator area):
s_wqm, #1990 forsrc64_data/is_mask_op;s_movintoexec_hi, #1996 form0/scc;docs/design.md, between #1990, #1943 and #1994.main(docs/design.mdtaken frommain), each PR's own test file passes. The full semantic suite (scripts/run_semantic_tests.py tests/semantic -j 4, 528 files, 6513 tests) fails in 2 files:test_valu_cvt_f16_int16_mods, which fails on plainmaintoo;test_wave64_emulate_opt, which comes from #1990 alone (see #1990).No blocker from my side.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T00:12:05Z.
Merged after TheGeogeo's red/green check (check) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto
main829530dbdwithout conflict, and its test file(s) (tests/semantic/test_b64_bitops_vcc_data.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.