shader: lower compute v_sub_co_u32 / v_subrev_co_u32 and their carry-in forms #2126
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2134"
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 R0Y00/Xbox2Windows. Originally posted by henriazz10 on 2026-11-25T01:23:04Z.
Change
Refs #721. Lower
v_sub_co_u32,v_subrev_co_u32(VOP3),v_sub_co_ci_u32(_e32and_e64), andv_subrev_co_ci_u32(_e32and_e64) intools/compute_store_aot.py, touching onlytools/compute_store_aot.py,tests/compute_store_check.py,CMakeLists.txt, anddocs/experiments.md.v_sub_co_u32 vD, sDst, S0, S1computes(S0 - S1) mod 2^32intovDand tracks the per-lane borrow-out(S0 < S1 ? 1u : 0u)insDst(vcc_loors0..s105);v_subrev_co_u32swapsS0andS1.v_sub_co_ci_u32andv_subrev_co_ci_u32(_e32/_e64) subtract the tracked per-lane borrow-incand write the new borrow-out((a < b || (a - b) < c) ? 1u : 0u).("borrow", expr)value, not a uniform scalar word. Writingvcc_loclears any priorv_cmpguard state, and any non-_cireader (s_*ALU,v_*ALU,v_cndmask,s_and_saveexec_b32) is refused. Groups larger than 32 threads requirewave_size=32.Verification
Commit
baa0302f, on71ae5584. The maintainer then integrated it with the merged carry-out add (#2132) in36b814b7, which shares one VCC state between carry and borrow. The results below are forbaa0302f. The draws,controls()and the LLVM 15 round trip were re-run onbaa0302f. Windows 11 build 26300, DXC 10.0.26100.0, Python 3.12, debug layer enabled.compared_words=320 mismatches=0,debug_errors=0compared_words=320 mismatches=0,debug_errors=0docs_links_check.py(18 Markdown files, 396 links),bidi_controls_check.py(1429 files), andgit diff --check HEAD~1all exited 0.The LLVM 15 round trip in Docker (
x2w-llvm15) exited 0 (binary_exit=0):Negative control. With
tools/compute_store_aot.pyfromorigin/main,sub_co_controls()fails withValueError: Unsupported compute instruction: v_sub_co_u32 v10, vcc_lo, 16, v3.Evidence
The
SUB_COfixture is source-built in LLVM 15 spelling for one 64-thread group (wave_size=32,buffer_store_dwordx4, 256 output words plus 64SENTINELwords). It exercisesv_sub_co_u32+v_sub_co_ci_u32_e32viavcc_lo(borrowing fortid.x > 16) andv_subrev_co_u32+v_subrev_co_ci_u32_e64vias4/s5(borrowing fortid.x < 32), comparing all 320 words against an independent Python model.v_sub_co_ci_u32_e64andv_subrev_co_ci_u32_e32), 32-thread group acceptance withoutwave_size=32, and refusals for >32 threads withoutwave_size=32, unknown/pending sources, invalid destinations, unverified borrow-in, non-_cireaders of the borrow SGPR (s_add_u32,v_add_nc_u32_e32,v_cndmask_b32_e64,s_and_saveexec_b32), modifiers (clamp,-,|...|,mul:2), and_e64onv_sub_co_u32.vcc borrow dropped: word 69;subrev operand order swapped: word 2;sgpr borrow-in ignored: word 3;sentinel past group: word 256.vcc borrow comparison flipped;sgpr borrow-in zeroed.Checklist
docs/experiments.md).AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) wrote the change and ran the checks; Claude Code reviewed it.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T01:42:13Z.
I resolved the conflict with the merged add-with-carry fixture and kept both registrations. The two paths now overwrite the same tracked VCC value. Two controls reject using a stale carry after a borrow write and a stale borrow after a carry write. Windows WARP and RTX 4060 Laptop passed both draw cases, 320 words per case with zero mismatches or debug-layer messages.