scripts: the short form v_add_co_ci_u32 vD, src0, src1 reads src0 (SCRIPTS-SHORT-CO-CI-OPERANDS) #2494

Merged
kawaii-shakal merged 2 commits from upstream-pr/2494 into main 2026-11-28 19:44:17 +00:00
kawaii-shakal commented 2026-11-27 19:17:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-27T19:17:01Z.


Item: SCRIPTS-SHORT-CO-CI-OPERANDS (claimed in #1608).

audit_shader4_regs.rbw_registers and vs_input_survey.read_before_write took every VOP _co_ op with a scalar second operand as vdst + carry-out. The assembler's short form v_add_co_ci_u32 vD, src0, src1 (also sub, subrev) has VCC as its carry-out and carry-in and names neither, so its second operand is src0, a read. On main, v_add_co_ci_u32_e32 v1, s3, v2 then s_mov_b32 s9, s3 reports no SGPR read before a write in either script; for audit_shader4_regs that hides the s3 read the audit exists to find. This is the follow-up wavehs suggested in #2357, which fixes the same form in lane_masks, wave64_halves and writes_exec; it does not depend on #2357.

Tests (Linux, Python 3.13, CPU only, no GPU or game files):

  • tests/test_audit_shader4_regs.py::test_short_form_carry_in_reads_s3_in_the_audit and tests/test_vs_input_survey_rbw.py::test_short_form_carry_in_reads_its_scalar_src0 (3 ops): fail on main 43a9d562 ({} != {'s3': 3}; s3 missing from read_s), pass here.
  • tests/test_audit_shader4_regs.py 21/21, tests/test_vs_input_survey_rbw.py 13/13, tests/test_vs_input_survey.py and tests/test_tool_stdout_encoding.py pass; check_no_game_data.py on the four files, compileall, test_text_write_line_endings.py and git diff --check are clean.

AI-assisted (Claude Code): the change and the tests were written with it; I reviewed them and ran the tests.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5531921124 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2494). Originally posted by [kawaii-shakal](https://github.com/kawaii-shakal) on 2026-11-27T19:17:01Z. --- Item: SCRIPTS-SHORT-CO-CI-OPERANDS (claimed in #1608). `audit_shader4_regs.rbw_registers` and `vs_input_survey.read_before_write` took every VOP `_co_` op with a scalar second operand as vdst + carry-out. The assembler's short form `v_add_co_ci_u32 vD, src0, src1` (also `sub`, `subrev`) has VCC as its carry-out and carry-in and names neither, so its second operand is src0, a read. On main, `v_add_co_ci_u32_e32 v1, s3, v2` then `s_mov_b32 s9, s3` reports no SGPR read before a write in either script; for `audit_shader4_regs` that hides the `s3` read the audit exists to find. This is the follow-up wavehs suggested in #2357, which fixes the same form in `lane_masks`, `wave64_halves` and `writes_exec`; it does not depend on #2357. Tests (Linux, Python 3.13, CPU only, no GPU or game files): - `tests/test_audit_shader4_regs.py::test_short_form_carry_in_reads_s3_in_the_audit` and `tests/test_vs_input_survey_rbw.py::test_short_form_carry_in_reads_its_scalar_src0` (3 ops): fail on main 43a9d562 (`{} != {'s3': 3}`; `s3` missing from `read_s`), pass here. - `tests/test_audit_shader4_regs.py` 21/21, `tests/test_vs_input_survey_rbw.py` 13/13, `tests/test_vs_input_survey.py` and `tests/test_tool_stdout_encoding.py` pass; `check_no_game_data.py` on the four files, `compileall`, `test_text_write_line_endings.py` and `git diff --check` are clean. AI-assisted (Claude Code): the change and the tests were written with it; I reviewed them and ran the tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
timbot103 commented 2026-11-28 01:34:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T01:34:11Z.


Reviewed at head 5acf0fa3f on Windows 11 (Python 3).

Verification

  • python -B -m unittest tests/test_audit_shader4_regs.py tests/test_vs_input_survey_rbw.py -v: 34/34 tests OK (0.104 s).

Notes

  • Both scripts/audit_shader4_regs.py (220-232) and scripts/vs_input_survey.py (86-98) now consistently classify src0 and src1 as reads for the 3-operand short forms of v_add_co_ci / v_sub_co_ci / v_subrev_co_ci while preserving the 5-operand explicit carry destination/source handling. Both regression tests cover the short and full forms cleanly.

Approve.

AI-assisted review + local Python verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7231759937 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2494#issuecomment-7231759937). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T01:34:11Z. --- Reviewed at head `5acf0fa3f` on Windows 11 (Python 3). ### Verification - `python -B -m unittest tests/test_audit_shader4_regs.py tests/test_vs_input_survey_rbw.py -v`: **34/34 tests OK** (`0.104 s`). ### Notes - Both `scripts/audit_shader4_regs.py` (`220-232`) and `scripts/vs_input_survey.py` (`86-98`) now consistently classify `src0` and `src1` as reads for the 3-operand short forms of `v_add_co_ci` / `v_sub_co_ci` / `v_subrev_co_ci` while preserving the 5-operand explicit carry destination/source handling. Both regression tests cover the short and full forms cleanly. Approve. AI-assisted review + local Python verification.
zmasi commented 2026-11-28 06:52:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T06:52:14Z.


#2494 | head 5acf0fa3fc (merged cleanly with main 09c153948) | python -I tests/test_audit_shader4_regs.py && python -I tests/test_vs_input_survey_rbw.py | red on main: FAILED (failures=1) ({} != {'s3': 3}) and FAILED (failures=3) (test_short_form_carry_in_reads_its_scalar_src0 on v_add_co_ci_u32 / v_sub_co_ci_u32 / v_subrev_co_ci_u32) | green on PR+main: 21 tests OK and 13 tests OK | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited rbw_registers in scripts/audit_shader4_regs.py and read_before_write in scripts/vs_input_survey.py: 3-operand short-form _co_ci_u32 instructions (vD, src0, src1 with implicit VCC carry in/out) now keep args[1] (src0) as a read instead of treating it as an explicit scalar carry-out destination, while leaving 5-operand VOP3 forms unchanged. Also passed tests/test_vs_input_survey.py, tests/test_text_write_line_endings.py (3 OK), tests/test_runner_calls_all_tests.py (3 OK), and scripts/check_no_game_data.py on the merged tree.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7235569191 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2494#issuecomment-7235569191). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T06:52:14Z. --- #2494 | head 5acf0fa3fcae19eb06674ac0fc6a52712d408d5d (merged cleanly with main 09c153948) | `python -I tests/test_audit_shader4_regs.py && python -I tests/test_vs_input_survey_rbw.py` | red on main: `FAILED (failures=1)` (`{} != {'s3': 3}`) and `FAILED (failures=3)` (`test_short_form_carry_in_reads_its_scalar_src0` on `v_add_co_ci_u32` / `v_sub_co_ci_u32` / `v_subrev_co_ci_u32`) | green on PR+main: `21 tests OK` and `13 tests OK` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `rbw_registers` in `scripts/audit_shader4_regs.py` and `read_before_write` in `scripts/vs_input_survey.py`: 3-operand short-form `_co_ci_u32` instructions (`vD, src0, src1` with implicit `VCC` carry in/out) now keep `args[1]` (`src0`) as a read instead of treating it as an explicit scalar carry-out destination, while leaving 5-operand VOP3 forms unchanged. Also passed `tests/test_vs_input_survey.py`, `tests/test_text_write_line_endings.py` (`3 OK`), `tests/test_runner_calls_all_tests.py` (`3 OK`), and `scripts/check_no_game_data.py` on the merged tree.
timbot103 commented 2026-11-28 13:23:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T13:23:14Z.

Review: APPROVED


Independently verified 5acf0fa3f merged cleanly onto main (d48a957bb) on Windows 11 (Python 3.14, zero game files):

Red on main (d48a957bb) control:

  • python -B -m unittest tests/test_audit_shader4_regs.py tests/test_vs_input_survey_rbw.py -v fails (34 tests, 4 failures: test_short_form_carry_in_reads_s3_in_the_audit plus all 3 subtests of test_short_form_carry_in_reads_its_scalar_src0 for v_add_co_ci_u32, v_sub_co_ci_u32, v_subrev_co_ci_u32).

Green on #2494 (5acf0fa3f):

  • python -B -m unittest tests/test_audit_shader4_regs.py tests/test_vs_input_survey_rbw.py -v: 34/34 passed (OK).

LGTM.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6098008949 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2494#pullrequestreview-6098008949). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T13:23:14Z. **Review:** APPROVED --- Independently verified `5acf0fa3f` merged cleanly onto `main` (`d48a957bb`) on Windows 11 (Python 3.14, zero game files): **Red on `main` (`d48a957bb`) control:** - `python -B -m unittest tests/test_audit_shader4_regs.py tests/test_vs_input_survey_rbw.py -v` fails (`34` tests, `4` failures: `test_short_form_carry_in_reads_s3_in_the_audit` plus all 3 subtests of `test_short_form_carry_in_reads_its_scalar_src0` for `v_add_co_ci_u32`, `v_sub_co_ci_u32`, `v_subrev_co_ci_u32`). **Green on `#2494` (`5acf0fa3f`):** - `python -B -m unittest tests/test_audit_shader4_regs.py tests/test_vs_input_survey_rbw.py -v`: **34/34 passed (`OK`)**. LGTM.
MoonEyes commented 2026-11-28 19:44:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T19:44:14Z.


Red/green: tests/test_audit_shader4_regs.py and tests/test_vs_input_survey_rbw.py fail 1 and 3 assertions on main (short v_add_co_ci_u32 src0 taken as a carry-out) and pass with the PR (cloud run on main 7daa4a4).
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main 7daa4a4a5 in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7244767587 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2494#issuecomment-7244767587). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T19:44:14Z. --- Red/green: tests/test_audit_shader4_regs.py and tests/test_vs_input_survey_rbw.py fail 1 and 3 assertions on main (short v_add_co_ci_u32 src0 taken as a carry-out) and pass with the PR (cloud run on main 7daa4a4). Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main 7daa4a4a5 in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2494
No description provided.