Repository navigation
rdna2spirv: SDWA selects on the long-form carry ops land on their sources (SHADER-SDWA-CO-CI-SELECT) - #1116
rdna2spirv: SDWA selects on the long-form carry ops land on their sources (SHADER-SDWA-CO-CI-SELECT)#1116tiguan26 wants to merge 1 commit into
Conversation
…rces (SHADER-SDWA-CO-CI-SELECT) Gen.insn() attached src0_sel/src1_sel from args[1] on. In the long form of v_add_co_ci_u32, v_sub_co_ci_u32 and v_subrev_co_ci_u32 (vD, carry out, src0, src1, carry in) args[1] is the carry out, so src0_sel landed on it, src1_sel narrowed src0 and src1 was read whole: a silent wrong result. With v1 = v4 = 0x00050003, src0_sel:WORD_1 src1_sel:WORD_0 and no carry in, v_sub_co_ci_u32_sdwa gave 0xfffb0000 with a borrow instead of 2. The selects now start at src0 for these ops; the short form (vD, src0, src1) was right and is unchanged. tests/semantic/test_sdwa_carry_select.py checks both forms of all three ops, carry in 0 and 1, byte/word/dword selects and seeded cases against a plain-Python reference. The SDWA row in docs/design.md says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Reviewed and verified. In ools/rdna2spirv.py, the long-form 5-argument layout of VOP2 carry instructions (�_add_co_ci_u32, �_sub_co_ci_u32, �_subrev_co_ci_u32) places carry_out at �rgs[1]. Adjusting irst = 2 when len(args) == 5 correctly applies src0_sel to �rgs[2] and src1_sel to �rgs[3]. Verified against ests/semantic/test_sdwa_carry_select.py and semantic regression suite (0 failures). 100% clean-room compliant with zero game data.
|
Verified
AI-assisted: yes |
|
Recommendation: [MERGE] Reasoning: Fixes a silent wrong result: in the long form of Impact level: 4/10 |
|
Closing as superseded. The same fix landed on main in 073b8bb by @thesubtleties (SHADER-SDWA-CARRY-SEL): |
Claimed in the coordination issue as: SHADER-SDWA-CO-CI-SELECT
What and why
Gen.insn()attaches the SDWAsrc0_sel/src1_selfromargs[1]on (first = 1). In the long form ofv_add_co_ci_u32,v_sub_co_ci_u32andv_subrev_co_ci_u32(vD, carry out, src0, src1, carry in)args[1]is the carry out, sosrc0_sellanded on it,src1_selnarrowed src0 and src1 was read whole: a silent wrong result, not a refusal.With v1 = v4 =
0x00050003,src0_sel:WORD_1 src1_sel:WORD_0and no carry in,maingives:v_sub_co_ci_u32_sdwa0xfffb0000, borrow 12, borrow 0v_add_co_ci_u32_sdwa0x50006, carry 08, carry 0v_subrev_co_ci_u32_sdwa0x50000, borrow 00xfffffffe, borrow 1The fix starts the selects at src0 for these three ops when the long form is printed (
SDWA_CARRY_OPS). The short formvD, src0, src1already gave the expected words and is unchanged; so is every other op.Impact: the SDWA row's hardware measurement over the 172 SDWA forms in the corpus lists no mismatch for these ops, so the current corpus most likely has no long-form carry op with a narrowing select. This is a correctness fix for the rule, not a known game bug. Found while reviewing #1093.
Tested
Linux, Python 3.13.18, on
main6293c1c:tests/semantic/test_sdwa_carry_select.py(4 tests): the reported words, both forms of all three ops with carry in 0 and 1 over byte/word/dword selects, and 24 seeded cases, against a plain-Python reference of the ISA semantics. Onmainthe three long-form tests fail and the short-form control passes; with the fix all four pass.python -I scripts/run_semantic_tests.py tests/semantic: 471 files, 6172 tests, 0 files failed.tests/test_docs_design_rows.py,test_docs_table_rows.py,test_docs_links.py,test_text_write_line_endings.py,python -m compileall -q tools tests,scripts/check_no_game_data.pyon the three files,git diff --check: clean.docs/design.mdgains one sentence on the long-form carry ops and how it was checked.GPUs tested: n/a (CPU interpreter only; not GPU-checked)
AI-assisted: yes (Claude)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.