image_bvh_census: keep source SGPR in 3-operand VOP2 carry forms (BVH-CENSUS-CO-CI-3OP) #3397

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u  "fix/image-bvh-census-co-ci:blud-fix/image-bvh-census-co-ci"
git switch "blud-fix/image-bvh-census-co-ci"
Open
leonida/mandy
blud wants to merge 1 commit from blud/mandy:fix/image-bvh-census-co-ci into main

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/image-bvh-census-co-ci:blud-fix/image-bvh-census-co-ci'
git switch 'blud-fix/image-bvh-census-co-ci'
First-time contributor

Claimed in the coordination issue as: BVH-CENSUS-CO-CI-3OP (addressing the finding that tools/image_bvh_census.py's sgpr_step and mask_writes cleared a[1] on 3-operand v_add_co_ci_u32).

What and why

In tools/image_bvh_census.py, both sgpr_step and mask_writes treated a[1] as a written carry/scale SGPR whenever len(a) > 1 and ("_co_" in bop or bop.startswith("v_div_scale")).

For the 3-operand short VOP2 carry forms (v_add_co_ci_u32 vD, src0, src1, v_sub_co_ci_u32, v_subrev_co_ci_u32), carry-out and carry-in are implicit vcc, so a[1] is src0 (read, not written). Treating a[1] as written cleared descriptor literals in sgpr_step and saved EXEC masks in exec_step.

This:

  1. Tightens the check in mask_writes to len(a) >= 4 (all explicit-sdst VOP3b carry/scale forms have 4 or 5 operands: vD, sdst, src0, src1[, src2]).
  2. Deduplicates sgpr_step to reuse mask_writes(ins) directly instead of maintaining a second copy of the SGPR-write logic.

Tested

  • Red on main (0043b8d33): SummaryTests.test_three_operand_co_ci_does_not_clobber_sgpr_source fails with AssertionError: None != 2139095040 : v_add_co_ci_u32.
  • Green with fix:
    • python -I tests/test_image_bvh_census.py -v — 22/22 passed (covers all three 3-operand _co_ci_ ops for both descriptor literals and saved EXEC masks, plus 4-op and 5-op explicit-carry negative cases).
    • python -I scripts/red_green.py fix/image-bvh-census-co-ci --base leonida/main --no-fetch --no-cargo --mutate — verdict: red then green (1 red→green, 21 pass on both, all functional hunks caught).
    • python -I scripts/check_no_game_data.py tools/image_bvh_census.py tests/test_image_bvh_census.py — exit 0.
  • Independent review: separate read-only reviewer subagent (Gemini 4 Neon) — APPROVE.

GPUs tested: n/a (standard-library Python static analysis tool with synthetic .s fixtures; no game files or GPU needed).

AI-assisted: yes — Gemini 4 Neon via Antigravity (implementation, regression test, and a separate read-only reviewer subagent using Gemini 4 Neon).

Checklist

  • Based on current main (0043b8d33) and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed (n/a: no translator rule changed).
Claimed in the coordination issue as: [`BVH-CENSUS-CO-CI-3OP`](https://git.leonida.now/leonida/mandy/issues/3312#issuecomment-23475) (addressing the finding that `tools/image_bvh_census.py`'s `sgpr_step` and `mask_writes` cleared `a[1]` on 3-operand `v_add_co_ci_u32`). ### What and why In `tools/image_bvh_census.py`, both `sgpr_step` and `mask_writes` treated `a[1]` as a written carry/scale SGPR whenever `len(a) > 1 and ("_co_" in bop or bop.startswith("v_div_scale"))`. For the 3-operand short VOP2 carry forms (`v_add_co_ci_u32 vD, src0, src1`, `v_sub_co_ci_u32`, `v_subrev_co_ci_u32`), carry-out and carry-in are implicit `vcc`, so `a[1]` is `src0` (read, not written). Treating `a[1]` as written cleared descriptor literals in `sgpr_step` and saved EXEC masks in `exec_step`. This: 1. Tightens the check in `mask_writes` to `len(a) >= 4` (all explicit-`sdst` VOP3b carry/scale forms have 4 or 5 operands: `vD, sdst, src0, src1[, src2]`). 2. Deduplicates `sgpr_step` to reuse `mask_writes(ins)` directly instead of maintaining a second copy of the SGPR-write logic. ### Tested - **Red on `main` (`0043b8d33`):** `SummaryTests.test_three_operand_co_ci_does_not_clobber_sgpr_source` fails with `AssertionError: None != 2139095040 : v_add_co_ci_u32`. - **Green with fix:** - `python -I tests/test_image_bvh_census.py -v` — `22/22` passed (covers all three 3-operand `_co_ci_` ops for both descriptor literals and saved EXEC masks, plus 4-op and 5-op explicit-carry negative cases). - `python -I scripts/red_green.py fix/image-bvh-census-co-ci --base leonida/main --no-fetch --no-cargo --mutate` — `verdict: red then green` (`1` red→green, `21` pass on both, all functional hunks caught). - `python -I scripts/check_no_game_data.py tools/image_bvh_census.py tests/test_image_bvh_census.py` — exit `0`. - **Independent review:** separate read-only reviewer subagent (Gemini 4 Neon) — `APPROVE`. GPUs tested: n/a (standard-library Python static analysis tool with synthetic `.s` fixtures; no game files or GPU needed). AI-assisted: yes — Gemini 4 Neon via Antigravity (implementation, regression test, and a separate read-only reviewer subagent using Gemini 4 Neon). ### Checklist - [x] Based on current `main` (`0043b8d33`) and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed (n/a: no translator rule changed).
First-time contributor

Independent verification of this change (no code changed by me).

  • Head f9ad6eb7, merge base 0043b8d3. The test is new on the base: git grep -F test_three_operand_co_ci_does_not_clobber_sgpr_source 0043b8d3 -- tests/test_image_bvh_census.py -> exit 1.
  • On the PR head: python -m unittest tests.test_image_bvh_census.SummaryTests.test_three_operand_co_ci_does_not_clobber_sgpr_source -v -> OK; the whole module python -m unittest tests.test_image_bvh_census -> 22 tests OK.
  • Red/green: with the PR's test file placed on the merge base, the same case fails (AssertionError: None != 2139095040 : v_add_co_ci_u32), so the tool change is required, not just the test.
  • git diff --check 0043b8d3 f9ad6eb7 -> clean. python -I scripts/check_no_game_data.py tools/image_bvh_census.py tests/test_image_bvh_census.py -> clean.

GPUs tested: none (pure Python instruction analysis, no device-gated test). Driver: n/a. No game data, assets or extracted shaders were used or attached.

AI-assisted: yes, Hy4 flash (verification only). No approval implied; this is a local test report.

Independent verification of this change (no code changed by me). - Head `f9ad6eb7`, merge base `0043b8d3`. The test is new on the base: `git grep -F test_three_operand_co_ci_does_not_clobber_sgpr_source 0043b8d3 -- tests/test_image_bvh_census.py` -> exit 1. - On the PR head: `python -m unittest tests.test_image_bvh_census.SummaryTests.test_three_operand_co_ci_does_not_clobber_sgpr_source -v` -> OK; the whole module `python -m unittest tests.test_image_bvh_census` -> 22 tests OK. - Red/green: with the PR's test file placed on the merge base, the same case fails (`AssertionError: None != 2139095040 : v_add_co_ci_u32`), so the tool change is required, not just the test. - `git diff --check 0043b8d3 f9ad6eb7` -> clean. `python -I scripts/check_no_game_data.py tools/image_bvh_census.py tests/test_image_bvh_census.py` -> clean. GPUs tested: none (pure Python instruction analysis, no device-gated test). Driver: n/a. No game data, assets or extracted shaders were used or attached. AI-assisted: yes, Hy4 flash (verification only). No approval implied; this is a local test report.
Sign in to join this conversation.
No description provided.