Skip to content

lane_masks: handle slist scalar register lists in kind() - #4545

Open
JavierBlanco23 wants to merge 2 commits into
ItsNotRexed:mainfrom
JavierBlanco23:lane-masks-slist-kind
Open

JavierBlanco23 wants to merge 2 commits into
ItsNotRexed:mainfrom
JavierBlanco23:lane-masks-slist-kind

Conversation

@JavierBlanco23

Copy link
Copy Markdown
Contributor

Resolves new SHADER item claimed in #4421 (#4421 (comment)).

Summary

tools/lane_masks.py:put() already handles k == "slist" (LLVM VCCTuple scalar register lists such as [s105,vcc_lo] or [vcc_lo,vcc_hi]), but kind() omitted k == "slist" and always returned None. As a result, reading a lane mask through an slist operand dropped lane-mask tracking on copies/bitwise operations (s_mov_b64, s_and_b64, etc.) and wave64_halves.is_mask().

Changes

  • tools/lane_masks.py: handle k == "slist" in kind(), resolving integer entries against state and vcc_lo/vcc_hi/exec_lo/exec_hi with the same rules as special and sgpr pairs (None if empty or any element is plain data; MASK for a 2-element list when at least one element is a mask and none is plain data; otherwise the common kind when all elements match).
  • tests/test_lane_masks.py: added test_slist_kind() covering slist copy/bitwise propagation ([s105, vcc_lo], [vcc_lo, vcc_hi]), EITHER + mask pairs, negative controls (plain data mixed with mask, data in vcc, 4-dword descriptor with data, empty slist), and exec_lo/exec_hi.

Testing

  • python -B -m compileall -q tools/lane_masks.py tests/test_lane_masks.py
  • python -B -I tests/test_lane_masks.py: ok (fails before fix on 03b09a08, passes after)
  • python -B -I tests/semantic/test_wave64_halves.py: all tests OK
  • git diff --check: clean
  • Environment: Windows 11, Python 3.12, NVIDIA GeForce RTX 5080, driver 616.56 (CPU-only synthetic inputs, no game files).

AI-assisted.

@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 2b0d3dc0 on Windows 11: python -I tests/test_lane_masks.py -> ok; git diff --check clean.

lane_masks.kind() now handles slist scalar register lists, with the new cases covering the list forms. No blocking issue.

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 2b0d3dc0a3 on Linux, Python 3.10, CPU only, synthetic fixtures, no game files: pass.

  • python -I tests/test_lane_masks.py → all 9 checks ok (script-style suite).
  • Negative control on main's tools/lane_masks.py: test_slist_kind raises KeyError, so the slist scalar-register-list handling discriminates.
  • git diff --check and check_no_game_data.py clean.

AI-assisted (Devin).

@CaravelaLabs

Copy link
Copy Markdown
Contributor

Automated test: 2b0d3dc0 merged onto main d0835dd9 on AMD Radeon 8060S (RADV GFX1151, RDNA 3.5), Mesa 25.2.8, Ubuntu 24.04, runtime rebuilt from this branch in a clean sandbox. Result: pass.

Same machine and setup as my earlier manual reports. AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 2b0d3dc merged with main d0835dd (merge 1dc54f5d7, no conflicts) on Linux (WSL2) Python 3.12.16 and native Windows 11 Python 3.13.1: pass, with a coverage gap.

  • tests/test_lane_masks.py (plain-assert file, prints ok): OK on both.
  • Negative control: tools/lane_masks.py from main, same test: KeyError: 6 in the new test_slist_kind on Linux.
  • Mutations of the new slist branch (Linux): two are caught (exec_lo giving no mask; the two-element mask rule changed to three) and two survive: vcc_hi mapped to MASK_LO instead of MASK_HI, and vcc_hi taking the data kind of vcc instead of None. The tests use vcc_lo, vcc_hi only in cases where the outcome does not depend on which half is which, so the high-half handling of a VCC pair is unpinned.

@JavierBlanco23

Copy link
Copy Markdown
Contributor Author

Thanks @kapitche for the mutation check! Pinned both cases in 4b20b27e ( ests/test_lane_masks.py):

  • �cc_hi half identity: kind({"vcc": MASK}, sl("vcc_hi")) == MASK_HI (plus 3-element slist matching MASK_HI vs mismatching �cc_lo).
  • Non-mask �cc (EITHER): �cc_lo returns EITHER while �cc_hi returns None, both alone and paired in sl(105, "vcc_hi").

Re-verified python -B -I tests/test_lane_masks.py (ok) and git diff --check clean on Windows 11, Python 3.12. AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 4b20b27 merged with main 98fa503 on Linux (Python 3.12.16): pass - tests/test_lane_masks.py prints ok (new test_slist_kind included); negative control: upstream/main tools/lane_masks.py with the new test: fails with KeyError: 6 (slist copy not seen as a mask). No issue found in the diff.

@memorypressure

Copy link
Copy Markdown

The scalar-list classification test and 57 nearby semantic tests pass after merging current main (3faac55, re-run). Confirmed the non-supersession: main's bda1775 added scalar-list handling to put(), not kind(). Heads-up for the queue: #2956 edits the same two files for the parked-mask lane aliasing — different behavior, but someone will land second. Four checks pending. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@hcampbell98

Copy link
Copy Markdown

Tested 0fbe57310 merged with main 5cf3dafe3 on Linux (WSL2, Python 3.14.4, CPU only, no game files): pass.

  • git diff --check, compileall, and python3 -I scripts/check_no_game_data.py: clean; touched files have zero violations in test_text_write_line_endings.py.
  • python3 -I tests/test_lane_masks.py: ok.
  • python3 -I -m unittest discover -s tests/semantic -p "test_wave64_halves*.py": 160/160 OK.
  • python3 -I -m unittest discover -s tests/semantic -p "test_lane_masks*.py": 10/10 OK.
  • Negative control (origin/main tools/lane_masks.py): tests/test_lane_masks.py fails with KeyError: 6 in test_slist_kind.
  • Mutation checks (tools/lane_masks.py): mapping vcc_hi to MASK_LO fails at assert L.kind({"vcc": L.MASK}, sl("vcc_hi")) == L.MASK_HI; returning non-mask vk for vcc_hi fails at assert L.kind({"vcc": L.EITHER}, sl("vcc_hi")) is None.

AI-assisted.

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.

7 participants