[PR #460] [MERGED] tests: cover the computed-EXEC write path #24 left without a test #511

Closed
opened 2026-11-26 20:18:07 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/460
Author: @Len1k
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: test/atomic-guard-writes-exec


📝 Commits (1)

  • 891fb8f tests: exercise the real active-lane guard when a shader writes EXEC

📊 Changes

1 file changed (+101 additions, -6 deletions)

View changed files

📝 tests/semantic/test_image_atomics_guard.py (+101 -6)

📄 Description

Claimed in the coordination issue as: TEST-ATOMIC-GUARD — see the note at the end, this turned out to be a follow-up rather than that item.

What this actually adds

b3eaa3d7b ("tests: image atomics guard keeps a dynamic EXEC case", 04:20 UTC) already restored the case @Okamizs asked for in the coordination issue, so the folded-constant gap is closed on main before this PR. That commit's own comment names what it left out:

Both EXEC writes come from a per-lane compare (VCC), not from a computed SGPR value, which is SHADER-1264's path.

SHADER-1264 is fixed — #24, "a computed value written to EXEC sets the lanes of its bits" — and that PR changed tools/rdna2spirv.py and docs/design.md with no test. So the lowering #24 introduced is the one shape the guard suite cannot express today, and nothing would catch a regression in it.

This PR adds that case, and the helper change needed to write it.

Why the helper has to change

With a computed mask, the branch condition is a value derived from the load, not the load:

s_mov_b32 s4, 1
s_and_b32 exec_lo, exec_lo, s4
image_atomic_add v0, v[1:2], s[4:11] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm

lowers to (trimmed):

%t6  = OpLoad %bool %active
%t5  = OpSelect %uint %t6 %cffffffff %c0
...
%t20 = OpSelect %uint %t21 %cffffffff %c0
%t4  = OpBitwiseAnd %uint %t5 %t20
%t23 = OpShiftRightLogical %uint %t4 %t22
%t24 = OpBitwiseAnd %uint %t23 %c1
%t34 = OpINotEqual %bool %t24 %c0
      OpStore %active %t34
      OpBranchConditional %t34 %t123_do %t124_end

%t34 is the lane's bit of the new mask, which is the correct guard, but find_guarded_texel_block accepted only ids produced by OpLoad %bool %active (plus the folded %true). Against main the new fixture fails with AssertionError: OpImageTexelPointer in unguarded block %t123_do.

Widening the helper to accept any condition would have been worse — a guard that never consults the lane mask would pass. Instead:

  • derived_from(spv, cond) walks the definition chain of a value and answers whether it reaches an OpLoad %bool %active. defs_of(spv) builds the id-to-operand map.
  • find_guarded_texel_block accepts a condition when it is the folded %true (still only for a module with no OpStore %active) or when derived_from reaches a load. Everything else is still rejected, so the forged-%true assertion b3eaa3d7b added keeps working.
  • texel_guard_condition(spv) returns the condition of the selection entering the block that holds the OpImageTexelPointer, so a test can assert on it.
  • test_a_shader_that_writes_exec_guards_on_the_load_not_the_folded_constant: the fixture above, asserting OpStore %active is present, the condition is not %true, derived_from(spv, condition) is true, derived_from(spv, "%true") is false, and the guarded block still holds OpAccessChain, OpImageTexelPointer and OpAtomicIAdd.

Verified

  • python -m unittest discover -s tests/semantic -p test_image_atomics_guard.py — Ran 5 tests ... OK (4 on main; the new one fails there with the assertion above).
  • python -I scripts/run_semantic_tests.py tests/semantic — 465 files, 6105 tests, 2 files failed in 485 s with 16 jobs: test_sopc_validation and test_unary_f16_validation, both AssertionError: spirv-as / spirv-val not found on PATH inside their own validate_spirv. This machine has no SPIR-V tools, so those two cannot run here; nothing else failed and test_image_atomics_guard passed inside that run.
  • python -I scripts/check_no_game_data.py tests/semantic/test_image_atomics_guard.py — exit 0.
  • One file, +101/−6, LF preserved.

No translator change, so the translated and spirv-val-valid counts are unchanged by construction. The fixture is hand-written; no game file was read and no GPU was involved.

Note on the coordination issue

TEST-ATOMIC-GUARD's reported gap was closed at 04:20 UTC, six minutes before the finding was posted at 04:26 — so the board entry is stale rather than pending. I have said so in the coordination issue; this PR should be read as "the computed-EXEC path #24 left without a test", not as that item.

Depends on: none. AI-assisted (OpenCode) on Windows 11, Python 3.12, RX 5700 XT (used for nothing here).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/460 **Author:** [@Len1k](https://github.com/Len1k) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `test/atomic-guard-writes-exec` --- ### 📝 Commits (1) - [`891fb8f`](https://github.com/ubiquitarianism/leonida/commit/891fb8f4e276b6905d19dd8b3a0b5e74e2d95c64) tests: exercise the real active-lane guard when a shader writes EXEC ### 📊 Changes **1 file changed** (+101 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `tests/semantic/test_image_atomics_guard.py` (+101 -6) </details> ### 📄 Description Claimed in the coordination issue as: `TEST-ATOMIC-GUARD` — see the note at the end, this turned out to be a follow-up rather than that item. ## What this actually adds `b3eaa3d7b` ("tests: image atomics guard keeps a dynamic EXEC case", 04:20 UTC) already restored the case @Okamizs asked for in the coordination issue, so the folded-constant gap is closed on `main` before this PR. That commit's own comment names what it left out: > Both EXEC writes come from a per-lane compare (VCC), not from a computed SGPR value, which is SHADER-1264's path. SHADER-1264 is fixed — #24, "a computed value written to EXEC sets the lanes of its bits" — and that PR changed `tools/rdna2spirv.py` and `docs/design.md` with **no test**. So the lowering #24 introduced is the one shape the guard suite cannot express today, and nothing would catch a regression in it. This PR adds that case, and the helper change needed to write it. ## Why the helper has to change With a computed mask, the branch condition is a value derived from the load, not the load: ```asm s_mov_b32 s4, 1 s_and_b32 exec_lo, exec_lo, s4 image_atomic_add v0, v[1:2], s[4:11] dmask:0x1 dim:SQ_RSRC_IMG_2D unorm ``` lowers to (trimmed): ```text %t6 = OpLoad %bool %active %t5 = OpSelect %uint %t6 %cffffffff %c0 ... %t20 = OpSelect %uint %t21 %cffffffff %c0 %t4 = OpBitwiseAnd %uint %t5 %t20 %t23 = OpShiftRightLogical %uint %t4 %t22 %t24 = OpBitwiseAnd %uint %t23 %c1 %t34 = OpINotEqual %bool %t24 %c0 OpStore %active %t34 OpBranchConditional %t34 %t123_do %t124_end ``` `%t34` is the lane's bit of the new mask, which is the correct guard, but `find_guarded_texel_block` accepted only ids produced by `OpLoad %bool %active` (plus the folded `%true`). Against `main` the new fixture fails with `AssertionError: OpImageTexelPointer in unguarded block %t123_do`. Widening the helper to accept any condition would have been worse — a guard that never consults the lane mask would pass. Instead: - `derived_from(spv, cond)` walks the definition chain of a value and answers whether it reaches an `OpLoad %bool %active`. `defs_of(spv)` builds the id-to-operand map. - `find_guarded_texel_block` accepts a condition when it is the folded `%true` (still only for a module with no `OpStore %active`) **or** when `derived_from` reaches a load. Everything else is still rejected, so the forged-`%true` assertion `b3eaa3d7b` added keeps working. - `texel_guard_condition(spv)` returns the condition of the selection entering the block that holds the `OpImageTexelPointer`, so a test can assert on it. - `test_a_shader_that_writes_exec_guards_on_the_load_not_the_folded_constant`: the fixture above, asserting `OpStore %active` is present, the condition is not `%true`, `derived_from(spv, condition)` is true, `derived_from(spv, "%true")` is false, and the guarded block still holds `OpAccessChain`, `OpImageTexelPointer` and `OpAtomicIAdd`. ## Verified - `python -m unittest discover -s tests/semantic -p test_image_atomics_guard.py` — `Ran 5 tests ... OK` (4 on `main`; the new one fails there with the assertion above). - `python -I scripts/run_semantic_tests.py tests/semantic` — 465 files, 6105 tests, 2 files failed in 485 s with 16 jobs: `test_sopc_validation` and `test_unary_f16_validation`, both `AssertionError: spirv-as / spirv-val not found on PATH` inside their own `validate_spirv`. This machine has no SPIR-V tools, so those two cannot run here; nothing else failed and `test_image_atomics_guard` passed inside that run. - `python -I scripts/check_no_game_data.py tests/semantic/test_image_atomics_guard.py` — exit 0. - One file, +101/−6, LF preserved. No translator change, so the translated and spirv-val-valid counts are unchanged by construction. The fixture is hand-written; no game file was read and no GPU was involved. ## Note on the coordination issue `TEST-ATOMIC-GUARD`'s reported gap was closed at 04:20 UTC, six minutes before the finding was posted at 04:26 — so the board entry is stale rather than pending. I have said so in the coordination issue; this PR should be read as "the computed-EXEC path #24 left without a test", not as that item. `Depends on:` none. AI-assisted (OpenCode) on Windows 11, Python 3.12, RX 5700 XT (used for nothing here). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:07 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#511
No description provided.