compute: accept VCC and EXEC as sources in 64-bit scalar shifts #3406
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!3406
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3404"
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:20 UTC · original
Ammmae0x:compute/salu-shift64-vcc-exec→main· +283 −5 · 5 files · 1 commits · merged 2026-11-29 08:42 UTCChange
Accept
VCC(106) andEXEC(126) as 64-bitS0sources ins_lshl_b64,s_lshr_b64ands_ashr_i64in the direct C++ compute path (src/gfx1013_direct_compute.inl).Refs #3226, #2935
The shift handler previously accepted only aligned SGPR pairs as
S0(
s0 <= 104 && !(s0 & 1)), refusingVCCandEXECeven thoughi.dstalready acceptsVCCand sibling 64-bit ops (
s_not_b64,s_cselect_b64,s_bcnt*/s_ff*/s_flbit*) acceptVCC/EXECas 64-bit sources. One line changess0_pairto also accepts0 == 106 || s0 == 126;lo = operand32(i, s0)andhi = operand32(i, s0 + 1)are read before writingi.dst/i.dst + 1,so in-place
s_lshl_b64 vcc, vcc, k/s_lshr_b64 vcc, vcc, kkeep their original inputs, andSCC = (D != 0)is unchanged. Odd SGPRs,M0(124),EXECas destination and invalids1shift sources are still refused with the exact existing error strings.
This is AI-assisted.
Verification
Commit under test:
b1fca1f08105f17b1b045f3a71c1eaec3d7ede26(
compute: accept VCC and EXEC as sources in 64-bit scalar shifts), branchcompute/salu-shift64-vcc-exec, fromorigin/main0614f68c.Linux (this host; no Windows toolchain, no GPU):
/tmp/pe-env/bin/python -B /tmp/shift64_vcc_exec_harness.py(offline harness in/tmp, not inthe repo; decodes every case program with
tools/disasm_rdna2.pyand cross-checkseval_shiftagainst an independent brute-force reference):
harness OK: 18 cases x wave32/wave64, shift encodings, SCC pack, store offsets, references and s0_pair guard all match/tmp, neverin the worktree): M1
s_lshl_b64reference computed as a right shift, M2 in-place op emittedfirst instead of last, M3
EXECrestore dropped, M4s0 == 106 || s0 == 126dropped from theC++ guard, M5 SCC pack using the wrong temp register — all 5 killed.
/tmp/pe-env/bin/python -B tests/form_coverage_check.py:form coverage checks passed/tmp/pe-env/bin/python -B tests/docs_links_check.py:Checked 160 Markdown files and 682 links./tmp/pe-env/bin/python -B tests/bidi_controls_check.py:Checked 2582 tracked source, script and build/CI files: no bidirectional controls.python3 -B -m py_compileon both touched test files: pass.g++ -std=c++20 -Wall -Wextraon the guard expression: accepts0/104/106/126, refuses23/105/124/127/107.tools/disasm_rdna2.pyand matchthe intended instructions.
Not run here (needs Windows):
cmake --build --preset dev --target compile_dxil native_store_replayand
ctest --preset dev --no-tests=error -R '^(native_salu_shift64_vcc_exec_|native_salu_shift64_)' -V,including
native_salu_shift64_vcc_exec_hardwareon a real adapter (exit 77 is a skip, not a pass).Evidence and follow-up
New fixture
tests/native_salu_shift64_vcc_exec_check.py(synthetic; followstests/native_salu_shift64_check.pyand the Task 2native_salu_bitscan64_vcctest, which passedWindows verification 5/5 on the first try): each of the 18 hardware dispatches runs all three
shifts from one
VCC/EXECsource value and stores four planes (one result plane per op plus apacked SCC plane: bit 0 lshl, bit 1 lshr, bit 2 ashr). Coverage: wave64 amounts
0, 1, 31, 32, 63, 64(64 & 63wraps to0) for both sources, wave32 amounts0, 32, 64for both sources,in-place
s_lshl_b64 vcc, vcc, 1ands_lshr_b64 vcc, vcc, 32folded into the wave64vccdispatches, sign-bit preservation vs zero-fill (
s_ashr_i64vss_lshr_b64), andSCC = (D != 0)per op (primed opposite before each op, so every op must write
SCC). Negative controls refuseM0, odd SGPR,EXECas destination,exec_hialone asS0, and invalids1(VCC/EXEC/M0).Assumptions:
EXECas a source narrows the active lane mask, so the fixture restoresEXECtoall ones before the vector readback stores (wave64:
s_mov_b64 exec, -1; wave32: thes_mov_b32pair). The 12-bit MUBUF store offset caps wave64 at four planes, so the three SCC bits are packed
into one word with
s_or_b32/s_lshl_b32instead of a fifth plane.The existing
tests/native_salu_shift64_check.pyobsoleteVCC-as-S0refusal is replaced withan
M0refusal; theEXECdestination refusal and theVCC-as-S1refusal are intact.docs/experiments/native-direct-salu-shift64.mddocumentsVCC/EXECasS0.Checklist
Windows Verification (
b1fca1f0)26100, MSVC 19.50.35727.0, adapterNVIDIA GeForce RTX 4050 Laptop GPU(driver32.0.15.9186,XBOX2WINDOWS_ADAPTER=NVIDIA), D3D12 debug layer off, commitb1fca1f08105f17b1b045f3a71c1eaec3d7ede26.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_shift64_vcc_exec_|native_salu_shift64_)' --output-on-failure->4/4passed (0skips)ctest --preset release --no-tests=error -R '^(native_salu_shift64_vcc_exec_|native_salu_shift64_)' --output-on-failure->4/4passed (0skips).\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 2584 tracked source, script and build/CI files: no bidirectional controls.(exit0)@Leyukaka on GitHub · 2026-11-29 03:45 UTC · original · approved these changes
Reviewed
b1fca1f0(diff only). Approve.src/gfx1013_direct_compute.inl:3642: VCC (106) and EXEC (126) are accepted as the 64-bitS0pair ofs_lshl_b64/s_lshr_b64/s_ashr_i64. The high word comes fromoperand32(i, s0 + 1)(107/127, accepted at:180-184).lo,hiand the amount are read at:3648-3656, before the writes at:3664-3666, so in-placevcc, vccis safe.exec_hialone (127), odd registers andm0asS0, and VCC/EXEC/m0asS1, stay refused.S0refusal attests/native_salu_shift64_check.py:148is replaced bym0. No other test onmain(212d4b5f) asserts that refusal.main212d4b5fplus other pending changes: the fournative_salu_shift64*tests pass; with|| s0 == 126dropped,native_salu_shift64_vcc_exec_controlsandnative_salu_shift64_vcc_exec_hardwarefail and the two older tests still pass._hardware;_controlschecks compilation, the presence of the three i64 shift ops and the refusals.prpreset filter (CMakePresets.json:51) has nonative_salu_*. After merge, push CI runs_controlsbut excludes_hardware$.enable_execsetsexec_hito 1 (ZERO + 1), while the doc says the fixture restoresexecto all ones; that holds only forexec_lo.