Skip to content

wave64_halves: a VGPR write under a narrowed EXEC keeps the old taint of the lanes that are off (SHADER-819) - #4778

Closed
sh1shu1 wants to merge 3 commits into
ItsNotRexed:mainfrom
sh1shu1:shader-819-masked-write-taint
Closed

sh1shu1 wants to merge 3 commits into
ItsNotRexed:mainfrom
sh1shu1:shader-819-masked-write-taint

Conversation

@sh1shu1

@sh1shu1 sh1shu1 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claimed as SHADER-819 in the coordination issue (shdann's finding).

put() replaced a register's taint on every write, so a VGPR written while EXEC is narrowed lost the partition dependence of the lanes the write skipped, and the four listings of the finding were tier A: a lane id, a v_readlane and an s_bcnt1 of EXEC written before a s_and_saveexec region that overwrites the register for one lane, exported after the join. The wave interpreter gives lane 32 a 32 in the wave and a 0 in its half.

The rule now: when EXEC is not the launch mask, a VGPR destination keeps its old taint (old | new), is not uniform and takes no lane-id tag. Writes carrying an idiom tag (elect, cnt, rank, waterfall, mask, vote) are unchanged: those describe a value read from one lane or inside the narrowed region, and the aggregated-atomic and waterfall tests still pass as tier B.

Tests (tests/semantic/test_wave64_halves.py): the lane-id, v_readlane and s_bcnt1 listings are tier C with lane-id / lane-count reasons; an execution test runs the lane-id listing as 64 lanes and as two halves on the interpreter and checks lane 32 differs (32 against 0); a masked write of a clean value stays tier A. The three tier tests and the execution test fail on main.

Not done: the corpus census (python tools/wave64_halves.py --census <spirv>/index.json before and after), which needs a copy of the game; this can move shaders from tier A to tier C, so a census from someone with a work folder is welcome. The fourth listing of the finding (a ds_bpermute address rewritten under EXEC = lanes 0..31) is covered by the same rule but I could not reproduce its 31-lane difference with a listing of my own, so it has no test here. Conflicts with #4373 (partial-write taint, same function); whichever lands first, the other rebases.

Tested: tests/semantic/test_wave64_halves.py 78 OK at 3417222 and 4 failures at 00841e0 (the tests without the fix), on macOS and on Windows 11 (Python 3.12.10); the rest of the semantic suite fails exactly as on main. No game files.

AI-assisted (Claude Code, Claude Fable 5.1).

🤖 Generated with Claude Code

https://claude.ai/code/session_01GDgoLQVYG7p8mvxkwBroVz

sh1shu1 and others added 2 commits November 23, 2026 04:26
…int of the lanes that are off (SHADER-819)

Three tier tests and one interpreter test from the finding: a lane id, a v_readlane and an s_bcnt1 of EXEC are
written to a VGPR, then an s_and_saveexec region overwrites the register for one lane and the register is exported
after the join. The analysis must say tier C; on the interpreter the lane-id listing gives lane 32 a 32 in the
64-lane wave and a 0 in its half. A masked write of a clean value stays tier A. The three tier tests and the
execution test fail on main.

AI-assisted (Claude Code, Claude Fable 5.1).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GDgoLQVYG7p8mvxkwBroVz
… of the lanes that are off (SHADER-819)

put() replaced a register's taint on every write, so a VGPR written while EXEC was narrowed lost the partition
dependence of the lanes the write skipped: a lane id, a readlane or a lane count written before a saveexec region
and overwritten there for one lane was exported as tier A. When EXEC is not the launch mask, a VGPR destination
now keeps its old taint (old | new), is not uniform and takes no lane-id tag. Writes carrying an idiom tag (elect,
cnt, rank, waterfall, mask, vote) are unchanged: they describe a value read from one lane or inside the region,
and the aggregated-atomic and waterfall idioms keep their tier B. test_wave64_halves: 78 OK; the whole semantic
suite has the same 38 failures as main (unrelated modules). The corpus census is not run here (no game files).

AI-assisted (Claude Code, Claude Fable 5.1).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GDgoLQVYG7p8mvxkwBroVz

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this at 3417222d9 on Windows 11: tests/semantic/test_wave64_halves.py -> 78 tests, OK; test_wave64_halves_soundness.py -> 30 tests, OK; git diff --check clean.

The change keeps a VGPR's old taint when a write happens under a narrowed EXEC, and clears the uniform/lane-id tags for that write; the added cases cover the masked write and the unchanged idiom tags.

Overlap/duplicate: #4619 (fearkov, opened 03:16, before this at 05:06) fixes the same SHADER-819 false tier A with a st["p"] pre-narrowing taint re-applied on widening (a stricter reconstruction of the off-lane value) plus the rewritten-vote-mask fix. The two branches conflict in tools/wave64_halves.py (git merge-tree refs/remotes/pr/4778 refs/remotes/pr/4619 -> exit 1). #4619 was verified at 38 tests; one of the two should close or drop the overlapping hunk.

@Kev-Ball

Copy link
Copy Markdown

I reproduced the fourth case from the finding. The low-half count needs to execute at the launch mask. Narrow EXEC only for the high-half count, then restore it before building the byte address. This hand-written body drops directly into Execution.run_both("vs_bperm_masked", vs([...])) in tests/semantic/test_wave64_halves.py:

v_mbcnt_lo_u32_b32 v10, -1, 0
v_cmp_gt_u32_e32 vcc, 32, v0
s_and_saveexec_b64 s[12:13], vcc
v_mbcnt_hi_u32_b32 v10, -1, v10
s_or_b64 exec, exec, s[12:13]
v_lshlrev_b32_e32 v11, 2, v10
ds_bpermute_b32 v6, v11, v0
s_waitcnt lgkmcnt(0)

For export component 0, exactly lanes 33–63 differ. Lane 33 returns 32 in the full wave and 33 in the paired halves. The classifier at 00841e0a says A and 3417222d says C on the same input. As a control, removing the compare, save-EXEC and restore-EXEC instructions gives tier A on both revisions and all 64 lanes match. This covers the missing lane-address case using the existing interpreter harness. AI-assisted, synthetic fixture.

…ER-819)

Kev-Ball's rebuild of the fourth listing: v_mbcnt_lo at the launch mask, v_mbcnt_hi for lanes 0..31 only, the
count as a ds_bpermute address. Classifier: tier C. Interpreter: lanes 33..63 read lane 32's v0 in the wave and
their own in the halves (lane 33: 32 against 33). Tier A on main.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GDgoLQVYG7p8mvxkwBroVz
@sh1shu1

sh1shu1 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@Kev-Ball thanks, your listing is in at 0aef525 as a classifier test (tier C) and an interpreter test (lanes 33..63 differ, lane 33 = 32 against 33); tier A on main.

@Kam471 agreed: #4619 was claimed and opened first, and its rule passes all 6 cases here (the 3 listings, the clean-value control and the ds_bpermute one) at e81227b, where main 98fa503 fails 5. Closing this as a duplicate; the tests go in a tests-only PR once #4619 merges.
AI-assisted (Claude Code, Claude Fable 5.1).

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 0aef525 on Windows Server 2022, CPython 3.13.12: pass

  • python -I -m unittest discover -s tests/semantic -p "test_wave64_halves.py" -> OK

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants