shader: per-lane v_cmp_* and v_cndmask_b32 in compute_store_aot #2167
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2175"
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-25T02:53:00Z.
Change
Refs #721. This is the general per-lane
v_cmp_*+v_cndmask_b32slice forcompute_store_aot(gfx1013), claimed in https://github.com/R0Y00/Xbox2Windows/issues/721#issuecomment-7150498483. It touches onlytools/compute_store_aot.py,tests/compute_store_check.py,CMakeLists.txt, anddocs/experiments.md(plus updated expected rejection diagnostics intests/compute_alu_cmp_ne_check.pyandtests/compute_lane_mask_check.pywhere previously unsupportedv_cmp_*/v_cndmask_b32forms are now parsed and refused downstream).Accepted forms (66 total: 64 compare forms + 2 select forms)
16forms):v_cmp_{f,lt,eq,le,gt,ne,ge,t}_u32_e32(intovcc_lo) andv_cmp_{f,lt,eq,le,gt,ne,ge,t}_u32_e64(intovcc_loors0..s105), comparinguintwords.16forms):v_cmp_{f,lt,eq,le,gt,ne,ge,t}_i32_e32(intovcc_lo) andv_cmp_{f,lt,eq,le,gt,ne,ge,t}_i32_e64(intovcc_loors0..s105), comparingasint(...).32forms):v_cmp_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f32_e32(intovcc_lo) andv_cmp_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f32_e64(intovcc_loors0..s105), comparingasfloat(...)with explicitisnan(...)checks for all ordered and unordered IEEE NaN predicates.2forms):v_cndmask_b32_e32 vD, S0, vS1, vcc_loandv_cndmask_b32_e64 vD, S0, S1, (vcc_lo|sN), lowering to(cond ? S1 : S0)when the mask holds a("cond", ...)(wave-size independent because only the same lane reads its bit).Existing lane guards (
s_and_saveexec_b32on uniformv_cmp_*), constant-maskv_cndmask_b32_e64, andvcc_carry/vcc_borrowkeep their current behavior. Any write tovcc_loinvalidates the other VCC-derived states.Refused (one control each)
f32source modifiers (-v1,|v1|);clamp, SDWA (_sdwa), and DPP (_dpp) spellings;condSGPR read by a scalar ALU instruction (s_add_u32) or used as a branch condition (s_cbranch_scc0);s_and_saveexec_b32on acondbuilt from loaded (v1) or ALU (v4) data;_cicarry-in from acond(vcc_loors4);condafter anothervcc_lowrite (v_add_co_u32).Verification
Commit
e3e132b1, onshader/compute-vcmp-selectfrome3e39c43. Windows 11 build 26300, VS 2019 Build Tools 16.11 (MSVC 14.29), DXC (Windows SDK 10.0.26100.0), Python 3.12, debug layer enabled.compared_words=320 mismatches=0,debug_errors=0 debug_warnings=0compared_words=320 mismatches=0,debug_errors=0 debug_warnings=0The LLVM 15 round trip in Docker (
x2w-llvm15) exited 0 (binary_exit=0):vcmp_select_binary()disassembles all 12 assembled programs and checks identicalv_cmp_*/v_cndmask_b32_*lines and identicalaot.lower()output.Negative control. With
tools/compute_store_aot.pyfromorigin/main,vcmp_select_controls()fails withValueError: Unverified lane guard compare.Evidence
gfx1013dispatches (buffer_store_dwordx4, 256 output words + 64SENTINELwords each = 3,840 words total) covering all 32 predicates (8u32+8i32+16f32) across equal values,0x7fffffffvs0x80000000,0vs0xffffffff, denormal raw words (0x00000001vs0x80000001),±0,NaNon either or both sides,±inf, and memory-loaded/tidinputs.ltandgtswapped: word 1;lt) used for unordered (nge): word 5;<for<=onu32;asintdropped oni32;isnanreplaced byisinfon unorderedf32.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 tedin7 on 2026-11-25T03:05:14Z.
Review: COMMENTED
Review of head
e3e132b14446805dde968785324446bc0e641625: 0 P1, 0 P2.Logic check against RDNA2 VOPC/VOP2 semantics:
asint) are correct.n*forms are true on NaN, andnge,nlg,ngt,nle,nltandneqare the exact complements of their ordered partners.lgis ordered!=.v_cndmask_b32takes a per-lanecondfrom VCC or an SGPR pair. The constant-mask path keeps the existing single-wave limit.vcc_condis cleared by the carry/borrow writers and merged at the guard end, so a stale condition is not reused.Commands run locally (Linux):
python3 -B tests/compute_store_check.py controlsand the lane_mask and cmp_ne controls: the self-controls ran with no failure.python3 tests/docs_links_check.py: PASS (401 links).python3 tests/bidi_controls_check.py: PASS.git diff --check origin/main...HEAD: clean.FLOAT_COMPARE_PREDICATES,ngewas changed to the ordered form. The controls failed with an AssertionError. I reverted it afterwards.Windows Server 2025 (WARP and hardware):
python3 x2w_pipe.py win2025 2175 --scope direct --targets offscreen_check --regex 'compute_store_aot_vcmp_select|compute_lane_mask|compute_alu_cmp_ne|compute_store_aot_(bfe|draw)'compute_store_aot_vcmp_select_warpandcompute_store_aot_vcmp_select_hardware, which compare GPU readback against the independent Python model.GitHub CI
Build and test on Windows: SUCCESS.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T05:47:27Z.
Ran head
e3e132b1on three adapters. All pass. Windows 11 build 26100, debug layer unavailable.compute_store_aot_vcmp_select_warpcompared_words=320 mismatches=0compute_store_aot_vcmp_select_hardware(XBOX2WINDOWS_ADAPTER=Quadro)compute_store_aot_vcmp_select_hardware(XBOX2WINDOWS_ADAPTER=Intel)AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T06:34:55Z.
Review: APPROVED
Verified head
e3e132b1on Windows x64 (devpreset, MSVC19.44.35228.0, SDK/DXC10.0.26100.0):cmake --build --preset dev --target offscreen_check-> succeededctest --preset dev --no-tests=error -R '^compute_store_aot_vcmp_select_' -V-> 2/2 passed (compute_store_aot_vcmp_select_hardware,compute_store_aot_vcmp_select_warp)AMD Radeon RX 7900 XTX(vendor=1002 device=744c, driver32.0.32029.2010)Microsoft Basic Render Driver(vendor=1414 device=008c, driver10.0.26100.9818)Verdict: Approved at
e3e132b1.