shader_meta: handle short v_*_co_ci_u32, SMEM atomics, buffer_load lds, and VGPR swap/rel vscale (SHADER-META-OPERANDS-AND-LDS) #2018

Open
github-bot wants to merge 1 commit from github-bot/gh-2018 into main AGit
Owner

@⁠ShotTechOp on GitHub · 2026-11-25 18:14 UTC · original
ShotTechOp:fix/shader-meta-operands-lds → main · +148 −13 · 2 files · 1 commits · open

Claimed in #1608 as SHADER-META-OPERANDS-AND-LDS.

What and why

Fixes four static-analysis bugs in tools/shader_meta.py:

  1. 3-operand v_*_co_ci_u32 short forms (v_add_co_ci_u32 vD, src0, src1 and sub/subrev variants with implicit VCC): _split_operands previously treated a[1] as a written carry-out SGPR regardless of arity, dropping a user SGPR in src0 from reads and marking it written. Carry-out a[1] is now treated as a write only when len(a) >= 4.
  2. SMEM atomics (s_atomic_*, s_buffer_atomic_*): _split_operands previously placed a[0] in writes only, missing it as a read-before-write operand and falsely clobbering it when glc is absent. _step_state now also classifies a[1] as ptr64/ptr32_lo (s_atomic_*) or vsharp (s_buffer_atomic_*).
  3. LDS DMA buffer loads (buffer_load* / tbuffer_load* with lds): these omit vdata, placing srsrc (V#) at a[1] instead of a[2]. _step_state now inspects a[1] when lds is present so user-SGPR V#s are classified as vsharp.
  4. VGPR vscale tracking across v_swap_b32 and v_movreld_b32/v_movrelsd_b32/v_movrelsd_2_b32/v_swaprel_b32: v_swap_b32 now swaps vscale between both operands instead of only clearing a[0], and relative VGPR writes clear vscale entries at or above the base VGPR.

Testing

  • AI-assisted: yes.
  • Environment: Windows 11, Python 3.12 (no GPU / LLVM / SPIRV-Tools installed locally).
  • New test suite: tests/test_shader_meta_split_and_lds.py.
  • RED control on origin/main: tests/test_shader_meta_split_and_lds.py fails with FAILED (failures=9) across all 4 test methods on origin/main.
  • GREEN checks on branch:
    • python -I tests/test_shader_meta_split_and_lds.py -v (4/4 OK)
    • python -I tests/test_shader_meta.py (28/28 OK)
    • python -I tests/test_shader_meta_operands.py (5/5 OK)
    • python -I tests/test_text_write_line_endings.py (3/3 OK)
    • python -m compileall -q tools/shader_meta.py tests/test_shader_meta_split_and_lds.py
    • python -I scripts/check_no_game_data.py tools/shader_meta.py tests/test_shader_meta_split_and_lds.py
    • git diff --check
**@⁠ShotTechOp** on GitHub · 2026-11-25 18:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2018) `ShotTechOp:fix/shader-meta-operands-lds` → `main` · +148 −13 · 2 files · 1 commits · open Claimed in #1608 as `SHADER-META-OPERANDS-AND-LDS`. ## What and why Fixes four static-analysis bugs in `tools/shader_meta.py`: 1. **3-operand `v_*_co_ci_u32` short forms** (`v_add_co_ci_u32 vD, src0, src1` and `sub`/`subrev` variants with implicit VCC): `_split_operands` previously treated `a[1]` as a written carry-out SGPR regardless of arity, dropping a user SGPR in `src0` from `reads` and marking it written. Carry-out `a[1]` is now treated as a write only when `len(a) >= 4`. 2. **SMEM atomics (`s_atomic_*`, `s_buffer_atomic_*`)**: `_split_operands` previously placed `a[0]` in `writes` only, missing it as a read-before-write operand and falsely clobbering it when `glc` is absent. `_step_state` now also classifies `a[1]` as `ptr64`/`ptr32_lo` (`s_atomic_*`) or `vsharp` (`s_buffer_atomic_*`). 3. **LDS DMA buffer loads (`buffer_load*` / `tbuffer_load*` with `lds`)**: these omit `vdata`, placing `srsrc` (V#) at `a[1]` instead of `a[2]`. `_step_state` now inspects `a[1]` when `lds` is present so user-SGPR V#s are classified as `vsharp`. 4. **VGPR `vscale` tracking across `v_swap_b32` and `v_movreld_b32`/`v_movrelsd_b32`/`v_movrelsd_2_b32`/`v_swaprel_b32`**: `v_swap_b32` now swaps `vscale` between both operands instead of only clearing `a[0]`, and relative VGPR writes clear `vscale` entries at or above the base VGPR. ## Testing - **AI-assisted**: yes. - **Environment**: Windows 11, Python 3.12 (no GPU / LLVM / SPIRV-Tools installed locally). - **New test suite**: `tests/test_shader_meta_split_and_lds.py`. - **RED control on `origin/main`**: `tests/test_shader_meta_split_and_lds.py` fails with `FAILED (failures=9)` across all 4 test methods on `origin/main`. - **GREEN checks on branch**: - `python -I tests/test_shader_meta_split_and_lds.py -v` (4/4 OK) - `python -I tests/test_shader_meta.py` (28/28 OK) - `python -I tests/test_shader_meta_operands.py` (5/5 OK) - `python -I tests/test_text_write_line_endings.py` (3/3 OK) - `python -m compileall -q tools/shader_meta.py tests/test_shader_meta_split_and_lds.py` - `python -I scripts/check_no_game_data.py tools/shader_meta.py tests/test_shader_meta_split_and_lds.py` - `git diff --check`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:14:54 +00:00
This pull request can be merged automatically.
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 origin '+refs/pull/2018/head:github-bot/gh-2018'
git switch 'github-bot/gh-2018'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2018'
git switch 'github-bot/gh-2018'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2018'
git switch 'github-bot/gh-2018'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2018'
git switch 'main'
git merge --squash 'github-bot/gh-2018'
git switch 'main'
git merge --ff-only 'github-bot/gh-2018'
git switch 'main'
git merge 'github-bot/gh-2018'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.