compute: accept VCC as source in 64-bit scalar bit-count and bit-scan #3404
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3404
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3402"
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?
@Ammmae0x on GitHub · 2026-11-28 22:05 UTC · original
Ammmae0x:compute/salu-bitscan64-vcc→main· +267 −5 · 6 files · 1 commits · merged 2026-11-29 13:41 UTCChange
Accept
VCC(s0 == 106) as the 64-bit source in the direct C++ compute path for the six 64-bit scalarbit-count and bit-scan instructions
s_bcnt0_i32_b64,s_bcnt1_i32_b64,s_ff0_i32_b64,s_ff1_i32_b64,s_flbit_i32_b64ands_flbit_i32_i64(src/gfx1013_direct_compute.inl, one-lines0_pairchange:s0 == 106alongside aligned SGPR pairs andEXEC).vcc_lo/vcc_hiare read viaoperand32(i, s0)andoperand32(i, s0 + 1), exactly as the existingEXECpath readsexec_lo/exec_hi.M0(124), odd SGPRsand invalid destinations (
i.dst > 105) are still refused with the exact existing error strings.Refs #3226, #2935. In #3226's refreshed census,
invalid s_bcnt1_i32_b64 sourceblocks 10 wave64 shaders(16,894 dispatches) and
invalid s_ff1_i32_b64 sourceblocks 7 wave64 shaders (8,236 dispatches). This is asingle cohesive change, independent of #3359 (which added
VCCas a destination fors_bfm_b64and isalready merged in
main).New
tests/native_salu_bitscan64_vcc_check.py+tests/cmake/native_salu_bitscan64_vcc.cmake(
native_salu_bitscan64_vcc_controls/native_salu_bitscan64_vcc_hardware): all 6 ops withS0 = VCCinwave32 and wave64 (102 cases), populating VCC both with explicit
s_mov_b32 vcc_lo/vcc_hipairs (zero,all-ones, low-half-only, high-half-only, sign-bit, bit 32) and with lane comparisons (
v_cmp_lt_u32against16,
v_cmp_eq_u32against 0); exact result words andSCCare verified (counts updateSCC = (D != 0),scans preserve
SCC), plusM0/odd-SGPR/invalid-destination refusals. The two existing refusal tests thatasserted
VCCis refused as a source for these ops now useM0instead(
tests/native_wave64_exec_salu_check.pyBCNT1_B64,tests/native_salu_bitscan64_check.pyFLBIT_B64).docs/experiments/native-direct-salu-bitscan64.mddocumentsVCCasS0across all 6 ops.AI-assisted.
Verification
Commit under test:
414874b6ba1ca87852b53b42479bb85abad7ea92(branchcompute/salu-bitscan64-vcc, fromorigin/main8ecd30fe).Linux (this VM; no Windows toolchain here):
/tmp/bitscan64_vcc_harness.py, not in the repo): decodes every case program withtools/disasm_rdna2.py(all 6 ops appear ass_*_i32_b64 s24, vcc;v_cmp_lt_u32/v_cmp_eq_u32encodings verified; no bare-VGPR
vmove()— VGPRs are stored directly,vmove()is only used for SGPRs),cross-checks
eval_bitscan()against an independent brute-force reference for all 102 cases, verifies thehardware expected-layout build (no double-writes, in bounds, store planes at 0 and
16 * wave_sizebytes),and evaluates the
s0_pairguard expression straight from the.inl(accepts 0/2/22/104/106/126, refuses105/107/124/127/23). Result:
harness OK: 102 cases x wave32/wave64, VCC source encodings, references, layout and s0_pair guard all match.git status/git diffshow onlythe intended change): M1 VCC source replaced by SGPR pair (72 failures); M2 bare-VGPR
vmove(2, 256 + dst)(102 failures — the Task 1/5 failure mode); M3
s0 == 106dropped from the C++ guard (s0=106 refused);M4
v_cmp_lt_u32opcode swapped tone(decoded asv_cmp_ne_u32); M5 store plane stride halved(102 failures). The M2 check itself was fixed during the run: the disassembler prints
v_mov_b32_e32,which the first version of the check missed.
/tmp/pe-env/bin/python -B tests/form_coverage_check.py—form coverage checks passed, exit 0./tmp/pe-env/bin/python -B tests/docs_links_check.py—Checked 160 Markdown files and 682 links, exit 0./tmp/pe-env/bin/python -B tests/bidi_controls_check.py—Checked 2578 tracked source, script and build/CI files: no bidirectional controls, exit 0.py_compileon all three touched/related test files — pass. The changed guard expression compiles cleanunder
g++ -std=c++20 -Wall -Wextrain a standalone check (accepts 106, refuses 124/23/127); a standalone-fsyntax-onlyof the whole.inlfails identically before and after this change (missing includecontext), so it proves nothing new either way.
Not run here — needs Windows:
cmake --build --preset dev --target compile_dxil native_store_replayandctest --preset dev --no-tests=error -R '^(native_salu_bitscan64_vcc_|native_wave64_exec_salu|native_salu_bitscan64)' -V,including
native_salu_bitscan64_vcc_hardwareon a real adapter (exit 77 is a skip, not a pass). Note thehardware test has 102 replay cases; if it approaches the 60 s timeout on Windows, split it by wave size.
Evidence and follow-up
s_mov_b32immediates or derived fromv_cmp_*lanecomparisons against
v0; no game files, dumps or distribution links are involved.v_cmpwritesVCCthrough the same ballot path the direct compute path already uses forv_cmpx/EXEC; the hardware test is the check for that on a real adapter.gfx2hlsltext translator and pixel path are untouched; whether they also acceptVCCas a source forthese ops is out of scope here.
Checklist
Windows Verification (
414874b6)26100, MSVC 19.50.35727.0, adapterNVIDIA GeForce RTX 4050 Laptop GPU(driver32.0.15.9186,XBOX2WINDOWS_ADAPTER=NVIDIA), D3D12 debug layer off, commit414874b6ba1ca87852b53b42479bb85abad7ea92.cmake --build --preset dev --target compile_dxil native_store_replay-> exit0cmake --build --preset release --target compile_dxil native_store_replay-> exit0ctest --preset dev --no-tests=error -R '^(native_salu_bitscan64_vcc_|native_wave64_exec_salu|native_salu_bitscan64)' --output-on-failure->5/5passed ( skips)ctest --preset release --no-tests=error -R '^(native_salu_bitscan64_vcc_|native_wave64_exec_salu|native_salu_bitscan64)' --output-on-failure->5/5passed ( skips).\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py->form coverage checks passed(exit0).\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py->Self-test passed. Checked 160 Markdown files and 682 links.(exit0).\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py->Self-test passed. Checked 2580 tracked source, script and build/CI files: no bidirectional controls.(exit0)@Ammmae0x on GitHub · 2026-11-28 22:10 UTC · original · edited 2026-11-28 22:14 UTC
Windows
releaseverification for commit414874b6ba1ca87852b53b42479bb85abad7ea92:XBOX2WINDOWS_ADAPTER=NVIDIA ctest --preset release --no-tests=error -R '^(native_salu_bitscan64_vcc_|native_wave64_exec_salu|native_salu_bitscan64)' -VNVIDIA GeForce RTX 4050 Laptop GPU(driver32.0.15.9186, D3D12 debug layer off)AI-assisted.
@Leyukaka on GitHub · 2026-11-29 01:59 UTC · original · requested changes
Request changes on
414874b6.The guard change itself is correct. Outside the graphics path
operand32already reads 106/107 as VCC (src/gfx1013_direct_compute.inl:175-191on main), the handler is gated oncompute, and the existing count/scan lowering does not depend on which pair is the source.Blocking:
tests/native_scalar_mask64_check.py:90-92(added in #3337, not touched by this PR) still asserts the old refusal:count_program()defaults tosrc=106and setsvcc_lo/vcc_hiwiths_mov_b32literals. Withs0 == 106accepted, the guard no longer refuses these two programs, and it is the only place that emits this diagnostic fors_bcnt1_i32_b64, socompile_case(lines 46-47) andnative_scalar_mask64_controlsfail. Your ctest regex^(native_salu_bitscan64_vcc_|native_wave64_exec_salu|native_salu_bitscan64)does not select that test. CI does not either: thepull_requestWindows job runsctest --preset pr(.github/workflows/windows.yml:493), and its filter (CMakePresets.json:51) matches none ofnative_salu_bitscan64*,native_wave64_exec_salu*ornative_scalar_mask64*.Fix: remove lines 90-92 (or switch the two entries to
count_program(src=124), M0, which stays refused) and keepcount_program(src=107)on line 89.Smaller points:
vcc_hi(107) asS0. A guard ofs0 == 106 || s0 == 107is caught only by thecount_program(src=107)case above, in the file this PR leaves failing. Asop1(op, 24, VCC + 1)refusal in the new controls would cover it.cmp_lt16/cmp_eq0cases expectvcc_hi == 0. In wave32write_ballotwrites onlyvcc_lo, so the expected value relies on the initialvcc_hi, which those cases do not set.Basis: diff read in full against main
212d4b5f; nothing built or run.git merge-treeof414874b6with main212d4b5fis clean.@JohnConnorNPC on GitHub · 2026-11-29 12:55 UTC · original
Review of head
414874b6. Its merge-base is8ecd30fe.git merge-tree --write-tree --name-only origin/main 414874b6againstmainaf1cab5cexits 0. Read only, nothing built or run.Checked: the only source edit is the guard (
|| s0 == 106 ||).operand32(i, s0)andoperand32(i, s0 + 1)readvcc_lo/vcc_hi. The count and scan lowering after the guard is unchanged, and it usesunaryBits31/32/33 = Countbits/FirstbitLo/FirstbitHi, which matches the DXIL opcode table. Default path: since #3451, these ops are lowered in default runs once VCC is accepted, the same as for the other scalar lowerings.MUST
main.git grep -n 'VCC stays refused' origin/main -- tests→tests/native_scalar_mask64_check.py:90: # VCC stays refused as a 64-bit count source., followed by the twocount_program()cases at:91-92that expectinvalid s_bcnt1_i32_b64 source. This PR does not touch that file:git diff --stat 8ecd30fe 414874b6lists 6 files, and it is not one of them. Addingnative_scalar_mask64_to the posted ctest regex would show the failure. Nothing else from me blocks.NIT
5/5 passed ( skips), so a count is missing. The quoted log shows 0 skips.AI-assisted.
@Leyukaka on GitHub · 2026-11-29 13:22 UTC · original
Taking this over since there has been no activity for 2 h; will hand back if you resume.
Plan:
414874b6unchanged and merge it withmainc04e0dd6(git merge-treeis clean).mainstill refuses VCC atsrc/gfx1013_direct_compute.inl:4158; your one-line guard change is the only source edit.tests/native_scalar_mask64_check.py:90-92(the comment and the twocount_program()cases that expectinvalid s_bcnt1_i32_b64 sourcefor source 106), keepingcount_program(src=107)at:89.vcc_hi(107) source refusal next to the existing ones intests/native_salu_bitscan64_vcc_check.py:172-177.ctest -R '^(native_salu_bitscan64|native_wave64_exec_salu|native_scalar_mask64_)'in an isolated environment and post the result.414874b6.@Leyukaka on GitHub · 2026-11-29 13:32 UTC · original
Continued in #3458:
414874b6unchanged (you remain its author), merged withmainc04e0dd6, plus one test commitee117c4fthat removes the twocount_program()VCC refusals intests/native_scalar_mask64_check.pyand adds avcc_hi(107) source refusal to the new controls. 7/7 pass withctest --preset dev --no-tests=error -R '^(native_salu_bitscan64|native_wave64_exec_salu|native_scalar_mask64_)'on a hardware adapter.You can take it back at any time: say so here or push to this branch, and #3458 gets closed.