startup: refuse a lane mask read as numeric data by the remaining ALU forms in gfx2hlsl (Part of #1723) #2694

Merged
tedin7 merged 30 commits from upstream-pr/2702 into main 2026-11-26 08:01:52 +00:00
tedin7 commented 2026-11-26 02:39:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:39:36Z.


Part of #1723

What this unblocks: stops silently wrong shader output when a wave lane mask is read as a number (the llvm.amdgcn.ballot word and anything derived from it).

What changed

gfx2hlsl.py keeps one lane's bit of every wave mask (vcc, exec, SGPRs that hold a compare or ballot result). On RDNA 2 a mask register is the whole wave's bit set, so any instruction that reads it as a number sees the other lanes' bits too. The one-lane model has only its own bit, so the lowered word was wrong and nothing refused it. #2623 covers v_mov_b32 and v_cndmask_b32 data sources; this PR covers the rest:

  • A vector ALU instruction with a lane-mask source (vcc, exec, or an SGPR tracked as a mask, including results of bitwise ops on a mask) is refused: <op> reads lane mask <reg> as numeric data. A vector compare's sources count as data, its destination does not.
  • A scalar ALU instruction outside the mask-aware set (mov/and/or/xor/andn2/orn2/nand/nor/xnor/not/cselect/wqm, the *saveexec forms, branches, ff1, bitset) that reads a mask is refused the same way (this commit is the scalar half).
  • The high word of a wave64 mask pair (for example s_xor_b64 s[0:1], vcc, s[0:1] then v_mov_b32 v0, s1) is modelled as 0 but is the other lanes' bits on hardware: a v_mov_b32 of it is refused.
  • v_shift64 with vcc_lo or exec_lo as the shift count is no longer accepted (a mask as a count).

Why it is correct

The hardware rule: a mask SGPR/vcc/exec holds one bit per lane of the wave (64 in wave64). A numeric read returns that word; the model returns 0 or 1. So the only reads the model can honour are the per-lane ones: the select of v_cndmask, the carry of v_addc/v_subb/*_co, v_readlane/v_writelane, bitwise mask algebra and saveexec. Those stay allowed.

What stays refused / translating

Mask-only uses (select, carry, bitwise mask algebra, saveexec, branches on vcc/scc) translate as before. v_mov_b32 of a non-mask SGPR translates as before.

Tests

tests/startup_gfx2hlsl_compute_check.py: check_lane_mask_data (vector ALU reading vcc_lo; select still translates), check_lane_mask_high_word (move of the high word refused; move of a non-mask SGPR translates), check_lane_mask_derived_word (s_and_b32 s6, vcc_lo, 0xff then a vector compare or add reading s6 is refused). Each fails on main without the lowering change and passes with it. Existing suites updated for the earlier, more specific refusal message: readfirstlane_uniform, readfirstlane_recompute, shift64.

Verification

  • python3 -B tests/startup_gfx2hlsl_compute_check.py: PASS (fails before the change, see above)
  • python3 -B tests/startup_gfx2hlsl_readfirstlane_uniform_check.py, ..._readfirstlane_recompute_check.py, ..._shift64_check.py, ..._sdwa_check.py, ..._sdwa_cndmask_check.py, ..._mask_data_check.py, ..._float_alu_check.py: PASS
  • All 107 tests/startup_gfx2hlsl_*_check.py run with no arguments on this branch and on origin/main: identical result per script (105 PASS; export_null_draw and mul24_align_draw need a compiler and renderer and exit 1 on both).
  • Win2025 (Windows Server 2025, MSVC 14.44.35207, D3D12 WARP) on head bf138972a56b7ec0c40036206cbc30ec432592ad: x2w_pipe.py win2025 2702 --host aws-1 --no-skip-build --py-checks tests/startup_gfx2hlsl_compute_check.py --targets offscreen_check --regex 'startup_gfx2hlsl_(compute|mask|lane|vcc|cndmask|join|readfirstlane|cmp)': dev 56/56 passed, release 56/56 passed (includes startup_gfx2hlsl_compute_warp and _hardware). Build and run: cmake --build --preset dev --target offscreen_check then ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_(compute|mask|lane|vcc|cndmask|join|readfirstlane|cmp)' -V.
  • Linux, independent review: all 111 tests/startup_gfx2hlsl_* scripts give the same result on the merge of this branch with current main as on main (only export_null_draw and mul24_align_draw, which need a compiler and renderer, exit 1 on both). Every case of CASES in startup_gfx2hlsl_compute_check.py translates (23 of 23). The one-thread boundary was probed both ways: group (1,1,1) translates; (2,1,1), (1,2,1), (1,1,2), (3,1,1), (4,1,1), (32,1,1), (64,1,1) are refused. Three mutations of lane_mask_exact (always false, always true, at most two threads) and of the tag propagation each make startup_gfx2hlsl_compute_check.py fail.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6618312549 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T02:39:36Z. --- Part of #1723 What this unblocks: stops silently wrong shader output when a wave lane mask is read as a number (the `llvm.amdgcn.ballot` word and anything derived from it). ## What changed `gfx2hlsl.py` keeps one lane's bit of every wave mask (`vcc`, `exec`, SGPRs that hold a compare or ballot result). On RDNA 2 a mask register is the whole wave's bit set, so any instruction that reads it as a number sees the other lanes' bits too. The one-lane model has only its own bit, so the lowered word was wrong and nothing refused it. #2623 covers `v_mov_b32` and `v_cndmask_b32` data sources; this PR covers the rest: - A vector ALU instruction with a lane-mask source (`vcc`, `exec`, or an SGPR tracked as a mask, including results of bitwise ops on a mask) is refused: `<op> reads lane mask <reg> as numeric data`. A vector compare's sources count as data, its destination does not. - A scalar ALU instruction outside the mask-aware set (`mov/and/or/xor/andn2/orn2/nand/nor/xnor/not/cselect/wqm`, the `*saveexec` forms, branches, `ff1`, `bitset`) that reads a mask is refused the same way (this commit is the scalar half). - The high word of a wave64 mask pair (for example `s_xor_b64 s[0:1], vcc, s[0:1]` then `v_mov_b32 v0, s1`) is modelled as 0 but is the other lanes' bits on hardware: a `v_mov_b32` of it is refused. - `v_shift64` with `vcc_lo` or `exec_lo` as the shift count is no longer accepted (a mask as a count). ## Why it is correct The hardware rule: a mask SGPR/`vcc`/`exec` holds one bit per lane of the wave (64 in wave64). A numeric read returns that word; the model returns 0 or 1. So the only reads the model can honour are the per-lane ones: the select of `v_cndmask`, the carry of `v_addc`/`v_subb`/`*_co`, `v_readlane`/`v_writelane`, bitwise mask algebra and `saveexec`. Those stay allowed. ## What stays refused / translating Mask-only uses (select, carry, bitwise mask algebra, `saveexec`, branches on `vcc`/`scc`) translate as before. `v_mov_b32` of a non-mask SGPR translates as before. ## Tests `tests/startup_gfx2hlsl_compute_check.py`: `check_lane_mask_data` (vector ALU reading `vcc_lo`; select still translates), `check_lane_mask_high_word` (move of the high word refused; move of a non-mask SGPR translates), `check_lane_mask_derived_word` (`s_and_b32 s6, vcc_lo, 0xff` then a vector compare or add reading `s6` is refused). Each fails on main without the lowering change and passes with it. Existing suites updated for the earlier, more specific refusal message: `readfirstlane_uniform`, `readfirstlane_recompute`, `shift64`. ## Verification - `python3 -B tests/startup_gfx2hlsl_compute_check.py`: PASS (fails before the change, see above) - `python3 -B tests/startup_gfx2hlsl_readfirstlane_uniform_check.py`, `..._readfirstlane_recompute_check.py`, `..._shift64_check.py`, `..._sdwa_check.py`, `..._sdwa_cndmask_check.py`, `..._mask_data_check.py`, `..._float_alu_check.py`: PASS - All 107 `tests/startup_gfx2hlsl_*_check.py` run with no arguments on this branch and on `origin/main`: identical result per script (105 PASS; `export_null_draw` and `mul24_align_draw` need a compiler and renderer and exit 1 on both). - Win2025 (Windows Server 2025, MSVC 14.44.35207, D3D12 WARP) on head `bf138972a56b7ec0c40036206cbc30ec432592ad`: `x2w_pipe.py win2025 2702 --host aws-1 --no-skip-build --py-checks tests/startup_gfx2hlsl_compute_check.py --targets offscreen_check --regex 'startup_gfx2hlsl_(compute|mask|lane|vcc|cndmask|join|readfirstlane|cmp)'`: dev 56/56 passed, release 56/56 passed (includes `startup_gfx2hlsl_compute_warp` and `_hardware`). Build and run: `cmake --build --preset dev --target offscreen_check` then `ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_(compute|mask|lane|vcc|cndmask|join|readfirstlane|cmp)' -V`. - Linux, independent review: all 111 `tests/startup_gfx2hlsl_*` scripts give the same result on the merge of this branch with current `main` as on `main` (only `export_null_draw` and `mul24_align_draw`, which need a compiler and renderer, exit 1 on both). Every case of `CASES` in `startup_gfx2hlsl_compute_check.py` translates (23 of 23). The one-thread boundary was probed both ways: group (1,1,1) translates; (2,1,1), (1,2,1), (1,1,2), (3,1,1), (4,1,1), (32,1,1), (64,1,1) are refused. Three mutations of `lane_mask_exact` (always false, always true, at most two threads) and of the tag propagation each make `startup_gfx2hlsl_compute_check.py` fail. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 04:04:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:26:53Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d7eb2e3118

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068155756 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#pullrequestreview-6068155756). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T03:26:53Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `d7eb2e3118` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-26 04:04:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:46:20Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068276201 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#pullrequestreview-6068276201). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:46:20Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 04:04:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:46:22Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068276389 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#pullrequestreview-6068276389). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:46:22Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 04:04:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:46:24Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068276602 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#pullrequestreview-6068276602). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:46:24Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 04:04:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:16:51Z.


@MasterDomino this is ready for review at head d7eb2e311.

Independent gate review plus Windows run, four rounds. What it caught and the author fixed, so you know what was checked:

  • a numeric read of the high word of a wave64 mask pair was refused only for v_mov_b32; now every single-register read and every copy or combination of a mask pair carries the tag (one place, propagate_mask_tags), with a refusal test per kind;
  • merging current main made startup_gfx2hlsl_readfirstlane_uniform_check fail on a case whose expected message changed; updated;
  • the new refusal broke dispatch case E of startup_gfx2hlsl_compute_check (a saveexec result read as a number in a one-thread group, where the one-lane model is exact), visible only on Windows (compute_warp/compute_hardware); now a numeric mask read stays lowered in a compute group of one thread and is refused in every other group size.

Verification is in the PR body (commands, dev 36/36 and release 36/36 on WARP on this exact head, 111 Linux scripts identical to main, boundary probed both ways, mutations fail the tests).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7181566069 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#issuecomment-7181566069). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:16:51Z. --- @MasterDomino this is ready for review at head `d7eb2e311`. Independent gate review plus Windows run, four rounds. What it caught and the author fixed, so you know what was checked: - a numeric read of the high word of a wave64 mask pair was refused only for `v_mov_b32`; now every single-register read and every copy or combination of a mask pair carries the tag (one place, `propagate_mask_tags`), with a refusal test per kind; - merging current `main` made `startup_gfx2hlsl_readfirstlane_uniform_check` fail on a case whose expected message changed; updated; - the new refusal broke dispatch case E of `startup_gfx2hlsl_compute_check` (a saveexec result read as a number in a one-thread group, where the one-lane model is exact), visible only on Windows (`compute_warp`/`compute_hardware`); now a numeric mask read stays lowered in a compute group of one thread and is refused in every other group size. Verification is in the PR body (commands, dev 36/36 and release 36/36 on WARP on this exact head, 111 Linux scripts identical to `main`, boundary probed both ways, mutations fail the tests). AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 04:04:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:16:52Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T05:44:28.112543Z bf13897 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7181566468 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#issuecomment-7181566468). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T03:16:52Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"bf138972a56b7ec0c40036206cbc30ec432592ad","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T05:44:28.112543Z">2026-11-26T05:44:28.112543Z</relative-time> | `bf13897` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
tedin7 commented 2026-11-26 04:04:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:48:49Z.


Independent re-check of the fix pushed after Ready (f837dc298: high-word tag stays a high word, ends on overwrite, resets per pass), head 07003864c.

  • Counter-shapes (compute, s_mov_b64 s[20:21], exec first): copy of the low word then a numeric use is refused in a 2-thread group and translates in a 1-thread group; copy of the high word is refused in a 2-thread group; a wide write (s_mov_b64 s[20:21], 0) ends the tag, so the next read of s21 is not falsely refused.
  • tests/startup_gfx2hlsl_compute_check.py fails on the parent of the fix and passes with it.
  • Win2025 (dev + release) was already run on this exact head (36/36); not repeated.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182045740 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#issuecomment-7182045740). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:48:49Z. --- Independent re-check of the fix pushed after Ready (f837dc298: high-word tag stays a high word, ends on overwrite, resets per pass), head 07003864c. - Counter-shapes (compute, `s_mov_b64 s[20:21], exec` first): copy of the low word then a numeric use is refused in a 2-thread group and translates in a 1-thread group; copy of the high word is refused in a 2-thread group; a wide write (`s_mov_b64 s[20:21], 0`) ends the tag, so the next read of s21 is not falsely refused. - `tests/startup_gfx2hlsl_compute_check.py` fails on the parent of the fix and passes with it. - Win2025 (dev + release) was already run on this exact head (36/36); not repeated. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 04:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:26:54Z.

Code review location: tools/startup/gfx2hlsl.py; line 3558

@@ -3504,7 +3516,88 @@ def forget_writes(self, name, ops, drop_since=True):
             del self.uniform_expr[v]
         return regs
 
+    MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo')
+    MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi')
+
+    def mask_source_tags(self, base, ops):
+        """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word
+        (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi,
+        exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite
+        its own source."""
+        dests = destinations(base, ops)
+        srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops)
+        masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ())
+        low = high = False
+        for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs):
+            low |= tok in self.MASK_NAMES_LOW
+            high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo')
+            r = reg_range(tok)
+            if r and r[0] == 's':
+                start_tagged = r[1] in masks
+                low |= start_tagged
+                high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1])
+        return low, high
+
+    def propagate_mask_tags(self, base, ops, tags):
+        """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one
+        place the tag moves. A compare or carry writes its single-word mask itself (the decoder
+        names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec)
+        copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag
+        already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of
+        either is lowered (lower())."""
+        low, high = tags
+        saveexec = base.startswith('s_') and 'saveexec' in base
+        scalar = bool(MASK_COPY_SALU_RE.match(base)) and (low or high)
+        pair_select = base.startswith('s_cselect') and base.endswith('b64')
+        if not (saveexec or scalar or pair_select):
+            return
+        for tok in destinations(base, ops):
+            r = reg_range(tok)
+            if not r or r[0] != 's':
+                continue
+            self.masks.add(r[1])

P1 Badge Preserve numeric high-word copies in one-thread compute groups

For a one-thread compute group, s_mov_b64 s[20:21], exec; s_mov_b32 s22, s21; s_or_b32 s23, s22, 2 should produce numeric s23 == 2, since the high EXEC word is zero. Here the high-word tag causes the scalar copy to add s22 to self.masks, so the next OR is emitted as (s22 | 2) & 1. A following conversion and buffer store remain accepted because of lane_mask_exact(), causing the generated shader to store 0.0f rather than 2.0f; the parent emits the correct full-word OR. Preserve the high-word classification instead of treating this numeric copy as a low-word lane bit.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703555491 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#discussion_r4703555491). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T03:26:54Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3558 ~~~~diff @@ -3504,7 +3516,88 @@ def forget_writes(self, name, ops, drop_since=True): del self.uniform_expr[v] return regs + MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo') + MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi') + + def mask_source_tags(self, base, ops): + """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word + (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi, + exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite + its own source.""" + dests = destinations(base, ops) + srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops) + masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ()) + low = high = False + for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs): + low |= tok in self.MASK_NAMES_LOW + high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo') + r = reg_range(tok) + if r and r[0] == 's': + start_tagged = r[1] in masks + low |= start_tagged + high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1]) + return low, high + + def propagate_mask_tags(self, base, ops, tags): + """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one + place the tag moves. A compare or carry writes its single-word mask itself (the decoder + names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec) + copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag + already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of + either is lowered (lower()).""" + low, high = tags + saveexec = base.startswith('s_') and 'saveexec' in base + scalar = bool(MASK_COPY_SALU_RE.match(base)) and (low or high) + pair_select = base.startswith('s_cselect') and base.endswith('b64') + if not (saveexec or scalar or pair_select): + return + for tok in destinations(base, ops): + r = reg_range(tok) + if not r or r[0] != 's': + continue + self.masks.add(r[1]) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Preserve numeric high-word copies in one-thread compute groups** For a one-thread compute group, `s_mov_b64 s[20:21], exec; s_mov_b32 s22, s21; s_or_b32 s23, s22, 2` should produce numeric `s23 == 2`, since the high EXEC word is zero. Here the high-word tag causes the scalar copy to add `s22` to `self.masks`, so the next OR is emitted as `(s22 | 2) & 1`. A following conversion and buffer store remain accepted because of `lane_mask_exact()`, causing the generated shader to store `0.0f` rather than `2.0f`; the parent emits the correct full-word OR. Preserve the high-word classification instead of treating this numeric copy as a low-word lane bit. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-26 04:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:26:54Z.

Code review location: tools/startup/gfx2hlsl.py; line 2437

@@ -2423,6 +2434,7 @@ def set_s(self, n, expr, sym=None, scc=None, uniform=None):
             if getattr(self, 'since_join', None) is not None:
                 (self.since_join.add if uniform else self.since_join.discard)(n)
         getattr(self, 'masks', set()).discard(n)  # unit probes build a Stage without __init__
+        getattr(self, 'mask_high', set()).discard(n)

P2 Badge Clear high-word tags for scalar writes that bypass set_s

When a tagged pair is overwritten by a runtime scalar_wide_op(), that handler clears self.masks and writes both HLSL words directly, but never clears mask_high. Consequently, s_mov_b64 s[20:21], exec; s_lshl_b64 s[20:21], s[4:5], s7; v_mov_b32 v5, s21 now fails as a numeric mask read in a multi-thread compute group even though s21 holds an ordinary shift result. Symbol-only scalar moves also retain stale high tags because they bypass this cleanup. Invalidate high-word tags on those overwrite paths as well as in set_s() so ordinary register reuse does not cause false refusals.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703555495 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#discussion_r4703555495). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T03:26:54Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 2437 ~~~~diff @@ -2423,6 +2434,7 @@ def set_s(self, n, expr, sym=None, scc=None, uniform=None): if getattr(self, 'since_join', None) is not None: (self.since_join.add if uniform else self.since_join.discard)(n) getattr(self, 'masks', set()).discard(n) # unit probes build a Stage without __init__ + getattr(self, 'mask_high', set()).discard(n) ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Clear high-word tags for scalar writes that bypass set_s** When a tagged pair is overwritten by a runtime `scalar_wide_op()`, that handler clears `self.masks` and writes both HLSL words directly, but never clears `mask_high`. Consequently, `s_mov_b64 s[20:21], exec; s_lshl_b64 s[20:21], s[4:5], s7; v_mov_b32 v5, s21` now fails as a numeric mask read in a multi-thread compute group even though `s21` holds an ordinary shift result. Symbol-only scalar moves also retain stale high tags because they bypass this cleanup. Invalidate high-word tags on those overwrite paths as well as in `set_s()` so ordinary register reuse does not cause false refusals. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-26 04:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:26:54Z.

Code review location: tools/startup/gfx2hlsl.py; line 3560

@@ -3504,7 +3516,88 @@ def forget_writes(self, name, ops, drop_since=True):
             del self.uniform_expr[v]
         return regs
 
+    MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo')
+    MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi')
+
+    def mask_source_tags(self, base, ops):
+        """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word
+        (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi,
+        exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite
+        its own source."""
+        dests = destinations(base, ops)
+        srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops)
+        masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ())
+        low = high = False
+        for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs):
+            low |= tok in self.MASK_NAMES_LOW
+            high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo')
+            r = reg_range(tok)
+            if r and r[0] == 's':
+                start_tagged = r[1] in masks
+                low |= start_tagged
+                high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1])
+        return low, high
+
+    def propagate_mask_tags(self, base, ops, tags):
+        """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one
+        place the tag moves. A compare or carry writes its single-word mask itself (the decoder
+        names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec)
+        copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag
+        already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of
+        either is lowered (lower())."""
+        low, high = tags
+        saveexec = base.startswith('s_') and 'saveexec' in base
+        scalar = bool(MASK_COPY_SALU_RE.match(base)) and (low or high)
+        pair_select = base.startswith('s_cselect') and base.endswith('b64')
+        if not (saveexec or scalar or pair_select):
+            return
+        for tok in destinations(base, ops):
+            r = reg_range(tok)
+            if not r or r[0] != 's':
+                continue
+            self.masks.add(r[1])
+            if r[2] > r[1]:
+                self.mask_high = getattr(self, 'mask_high', set()) | {r[1] + 1}

P2 Badge Reset high-word tags for each translation proof pass

When translate() repeats its uniformity proof, it restores self.masks from the entry snapshot but retains this mask_high set from the end of the previous pass; the outer retry in Stage.__init__() retains it as well. A multi-thread compute shader that first converts entry group-ID s9 and later saves exec into s[8:9] in a loop succeeds on the first pass, but the second pass refuses the earlier conversion as a numeric mask read. Reset or snapshot mask_high alongside the other per-pass register state so later writes cannot poison entry operands on retranslations.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703555498 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#discussion_r4703555498). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T03:26:54Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3560 ~~~~diff @@ -3504,7 +3516,88 @@ def forget_writes(self, name, ops, drop_since=True): del self.uniform_expr[v] return regs + MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo') + MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi') + + def mask_source_tags(self, base, ops): + """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word + (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi, + exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite + its own source.""" + dests = destinations(base, ops) + srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops) + masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ()) + low = high = False + for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs): + low |= tok in self.MASK_NAMES_LOW + high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo') + r = reg_range(tok) + if r and r[0] == 's': + start_tagged = r[1] in masks + low |= start_tagged + high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1]) + return low, high + + def propagate_mask_tags(self, base, ops, tags): + """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one + place the tag moves. A compare or carry writes its single-word mask itself (the decoder + names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec) + copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag + already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of + either is lowered (lower()).""" + low, high = tags + saveexec = base.startswith('s_') and 'saveexec' in base + scalar = bool(MASK_COPY_SALU_RE.match(base)) and (low or high) + pair_select = base.startswith('s_cselect') and base.endswith('b64') + if not (saveexec or scalar or pair_select): + return + for tok in destinations(base, ops): + r = reg_range(tok) + if not r or r[0] != 's': + continue + self.masks.add(r[1]) + if r[2] > r[1]: + self.mask_high = getattr(self, 'mask_high', set()) | {r[1] + 1} ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Reset high-word tags for each translation proof pass** When `translate()` repeats its uniformity proof, it restores `self.masks` from the entry snapshot but retains this `mask_high` set from the end of the previous pass; the outer retry in `Stage.__init__()` retains it as well. A multi-thread compute shader that first converts entry group-ID `s9` and later saves `exec` into `s[8:9]` in a loop succeeds on the first pass, but the second pass refuses the earlier conversion as a numeric mask read. Reset or snapshot `mask_high` alongside the other per-pass register state so later writes cannot poison entry operands on retranslations. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-26 04:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:46:20Z.

Code review location: tools/startup/gfx2hlsl.py; line 3558

@@ -3504,7 +3516,88 @@ def forget_writes(self, name, ops, drop_since=True):
             del self.uniform_expr[v]
         return regs
 
+    MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo')
+    MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi')
+
+    def mask_source_tags(self, base, ops):
+        """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word
+        (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi,
+        exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite
+        its own source."""
+        dests = destinations(base, ops)
+        srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops)
+        masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ())
+        low = high = False
+        for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs):
+            low |= tok in self.MASK_NAMES_LOW
+            high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo')
+            r = reg_range(tok)
+            if r and r[0] == 's':
+                start_tagged = r[1] in masks
+                low |= start_tagged
+                high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1])
+        return low, high
+
+    def propagate_mask_tags(self, base, ops, tags):
+        """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one
+        place the tag moves. A compare or carry writes its single-word mask itself (the decoder
+        names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec)
+        copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag
+        already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of
+        either is lowered (lower())."""
+        low, high = tags
+        saveexec = base.startswith('s_') and 'saveexec' in base
+        scalar = bool(MASK_COPY_SALU_RE.match(base)) and (low or high)
+        pair_select = base.startswith('s_cselect') and base.endswith('b64')
+        if not (saveexec or scalar or pair_select):
+            return
+        for tok in destinations(base, ops):
+            r = reg_range(tok)
+            if not r or r[0] != 's':
+                continue
+            self.masks.add(r[1])

Confirmed and fixed in 07003864c. A one-thread group that copied the high word of a saved exec (s_mov_b64 s[20:21], exec; s_mov_b32 s22, s21; s_or_b32 s23, s22, 2) emitted s23 = (s22 | 0x2u) & 1;. A copy of a high word now carries only the high-word tag (propagate_mask_tags), so the numeric use stays s23 = s22 | 0x00000002u;.

Test: check_lane_mask_high_word_copy_and_overwrite in tests/startup_gfx2hlsl_compute_check.py (fails on the previous head, passes now; the same program with a 2-thread group is still refused).

Commands run:

  • python3 tests/startup_gfx2hlsl_compute_check.py
  • all tests/startup_gfx2hlsl_* scripts (same exit codes as before; the two *_draw_check scripts need a renderer argument)
  • Windows (WARP) on 07003864c: ctest --preset dev|release -R 'startup_gfx2hlsl_(compute|readfirstlane_uniform|readfirstlane_recompute|shift64)' 36/36 on both presets

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703660662 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#discussion_r4703660662). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:46:20Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3558 ~~~~diff @@ -3504,7 +3516,88 @@ def forget_writes(self, name, ops, drop_since=True): del self.uniform_expr[v] return regs + MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo') + MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi') + + def mask_source_tags(self, base, ops): + """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word + (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi, + exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite + its own source.""" + dests = destinations(base, ops) + srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops) + masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ()) + low = high = False + for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs): + low |= tok in self.MASK_NAMES_LOW + high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo') + r = reg_range(tok) + if r and r[0] == 's': + start_tagged = r[1] in masks + low |= start_tagged + high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1]) + return low, high + + def propagate_mask_tags(self, base, ops, tags): + """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one + place the tag moves. A compare or carry writes its single-word mask itself (the decoder + names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec) + copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag + already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of + either is lowered (lower()).""" + low, high = tags + saveexec = base.startswith('s_') and 'saveexec' in base + scalar = bool(MASK_COPY_SALU_RE.match(base)) and (low or high) + pair_select = base.startswith('s_cselect') and base.endswith('b64') + if not (saveexec or scalar or pair_select): + return + for tok in destinations(base, ops): + r = reg_range(tok) + if not r or r[0] != 's': + continue + self.masks.add(r[1]) ~~~~ --- Confirmed and fixed in `07003864c`. A one-thread group that copied the high word of a saved `exec` (`s_mov_b64 s[20:21], exec; s_mov_b32 s22, s21; s_or_b32 s23, s22, 2`) emitted `s23 = (s22 | 0x2u) & 1;`. A copy of a high word now carries only the high-word tag (`propagate_mask_tags`), so the numeric use stays `s23 = s22 | 0x00000002u;`. Test: `check_lane_mask_high_word_copy_and_overwrite` in `tests/startup_gfx2hlsl_compute_check.py` (fails on the previous head, passes now; the same program with a 2-thread group is still refused). Commands run: - `python3 tests/startup_gfx2hlsl_compute_check.py` - all `tests/startup_gfx2hlsl_*` scripts (same exit codes as before; the two `*_draw_check` scripts need a renderer argument) - Windows (WARP) on `07003864c`: `ctest --preset dev|release -R 'startup_gfx2hlsl_(compute|readfirstlane_uniform|readfirstlane_recompute|shift64)'` 36/36 on both presets AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 04:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:46:22Z.

Code review location: tools/startup/gfx2hlsl.py; line 2437

@@ -2423,6 +2434,7 @@ def set_s(self, n, expr, sym=None, scc=None, uniform=None):
             if getattr(self, 'since_join', None) is not None:
                 (self.since_join.add if uniform else self.since_join.discard)(n)
         getattr(self, 'masks', set()).discard(n)  # unit probes build a Stage without __init__
+        getattr(self, 'mask_high', set()).discard(n)

Confirmed and fixed in 07003864c. s_mov_b64 s[20:21], exec; s_lshl_b64 s[20:21], s[4:5], s7; v_mov_b32 v5, s21 in a 4-thread group was refused as "reads lane mask s21 as numeric data" because the wide write left the high-word tag on s21. lower() now drops the high-word tag of every SGPR the instruction wrote, before the tags of its sources are propagated.

Test: check_lane_mask_high_word_copy_and_overwrite (the shifted pair now translates; fails on the previous head).

Commands run: same as the first thread on this PR (compute check, all startup_gfx2hlsl_* scripts, Windows dev+release 36/36 on 07003864c).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703660826 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#discussion_r4703660826). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:46:22Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 2437 ~~~~diff @@ -2423,6 +2434,7 @@ def set_s(self, n, expr, sym=None, scc=None, uniform=None): if getattr(self, 'since_join', None) is not None: (self.since_join.add if uniform else self.since_join.discard)(n) getattr(self, 'masks', set()).discard(n) # unit probes build a Stage without __init__ + getattr(self, 'mask_high', set()).discard(n) ~~~~ --- Confirmed and fixed in `07003864c`. `s_mov_b64 s[20:21], exec; s_lshl_b64 s[20:21], s[4:5], s7; v_mov_b32 v5, s21` in a 4-thread group was refused as "reads lane mask s21 as numeric data" because the wide write left the high-word tag on s21. `lower()` now drops the high-word tag of every SGPR the instruction wrote, before the tags of its sources are propagated. Test: `check_lane_mask_high_word_copy_and_overwrite` (the shifted pair now translates; fails on the previous head). Commands run: same as the first thread on this PR (compute check, all `startup_gfx2hlsl_*` scripts, Windows dev+release 36/36 on `07003864c`). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 04:04:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:46:24Z.

Code review location: tools/startup/gfx2hlsl.py; line 3560

@@ -3504,7 +3516,88 @@ def forget_writes(self, name, ops, drop_since=True):
             del self.uniform_expr[v]
         return regs
 
+    MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo')
+    MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi')
+
+    def mask_source_tags(self, base, ops):
+        """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word
+        (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi,
+        exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite
+        its own source."""
+        dests = destinations(base, ops)
+        srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops)
+        masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ())
+        low = high = False
+        for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs):
+            low |= tok in self.MASK_NAMES_LOW
+            high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo')
+            r = reg_range(tok)
+            if r and r[0] == 's':
+                start_tagged = r[1] in masks
+                low |= start_tagged
+                high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1])
+        return low, high
+
+    def propagate_mask_tags(self, base, ops, tags):
+        """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one
+        place the tag moves. A compare or carry writes its single-word mask itself (the decoder
+        names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec)
+        copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag
+        already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of
+        either is lowered (lower())."""
+        low, high = tags
+        saveexec = base.startswith('s_') and 'saveexec' in base
+        scalar = bool(MASK_COPY_SALU_RE.match(base)) and (low or high)
+        pair_select = base.startswith('s_cselect') and base.endswith('b64')
+        if not (saveexec or scalar or pair_select):
+            return
+        for tok in destinations(base, ops):
+            r = reg_range(tok)
+            if not r or r[0] != 's':
+                continue
+            self.masks.add(r[1])
+            if r[2] > r[1]:
+                self.mask_high = getattr(self, 'mask_high', set()) | {r[1] + 1}

Real by code reading, fixed in 07003864c: self.mask_high was not reset where self.masks = set(init_masks) starts each translation pass, so a tag set in a first pass leaked into the retry. The two sets are now reset together.

I could not build a program that shows it through the public translate path: every loop I tried hit an unrelated refusal first, or the tags were rebuilt before the read. So there is no separate failing test for this one; the reset is covered by the existing retry fixtures staying green (compute check and all startup_gfx2hlsl_* scripts, Windows dev+release 36/36 on 07003864c).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4703660983 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#discussion_r4703660983). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T03:46:24Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3560 ~~~~diff @@ -3504,7 +3516,88 @@ def forget_writes(self, name, ops, drop_since=True): del self.uniform_expr[v] return regs + MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo') + MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi') + + def mask_source_tags(self, base, ops): + """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word + (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi, + exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite + its own source.""" + dests = destinations(base, ops) + srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops) + masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ()) + low = high = False + for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs): + low |= tok in self.MASK_NAMES_LOW + high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo') + r = reg_range(tok) + if r and r[0] == 's': + start_tagged = r[1] in masks + low |= start_tagged + high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1]) + return low, high + + def propagate_mask_tags(self, base, ops, tags): + """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one + place the tag moves. A compare or carry writes its single-word mask itself (the decoder + names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec) + copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag + already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of + either is lowered (lower()).""" + low, high = tags + saveexec = base.startswith('s_') and 'saveexec' in base + scalar = bool(MASK_COPY_SALU_RE.match(base)) and (low or high) + pair_select = base.startswith('s_cselect') and base.endswith('b64') + if not (saveexec or scalar or pair_select): + return + for tok in destinations(base, ops): + r = reg_range(tok) + if not r or r[0] != 's': + continue + self.masks.add(r[1]) + if r[2] > r[1]: + self.mask_high = getattr(self, 'mask_high', set()) | {r[1] + 1} ~~~~ --- Real by code reading, fixed in `07003864c`: `self.mask_high` was not reset where `self.masks = set(init_masks)` starts each translation pass, so a tag set in a first pass leaked into the retry. The two sets are now reset together. I could not build a program that shows it through the public translate path: every loop I tried hit an unrelated refusal first, or the tags were rebuilt before the read. So there is no separate failing test for this one; the reset is covered by the existing retry fixtures staying green (compute check and all `startup_gfx2hlsl_*` scripts, Windows dev+release 36/36 on `07003864c`). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 05:02:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:13:34Z.


Moving this back to Draft for now: an extra round of generated test shapes found a few more ways a wave64 mask high word can still be read as a number (for example a copy to another register pair, then a scalar add). Fixing them with tests; it goes back to Ready once they pass.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182406941 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#issuecomment-7182406941). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T04:13:34Z. --- Moving this back to Draft for now: an extra round of generated test shapes found a few more ways a wave64 mask high word can still be read as a number (for example a copy to another register pair, then a scalar add). Fixing them with tests; it goes back to Ready once they pass. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 06:01:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T05:16:19Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ee0deadadc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6068902518 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#pullrequestreview-6068902518). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T05:16:19Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `ee0deadadc` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-26 06:01:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T05:36:44Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069051637 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#pullrequestreview-6069051637). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T05:36:44Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-26 06:01:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T05:44:25Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf138972a5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069114778 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#pullrequestreview-6069114778). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T05:44:25Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `bf138972a5` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-26 06:02:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T05:11:08Z.


@MasterDomino Ready for review on head bf138972a (re-gate after the CI fix and a review-thread fix).

History: marked Ready on ee0deadad, put back to Draft because the Linux CI check startup_gfx2hlsl_bfm_b64 failed there; c7 fixed that test. While re-gating I also confirmed the open review thread (a 64-bit copy of plain data cleared the mask tag, so its truncated low word could be read as a number) and fixed it in 745d2c34c with a check that fails on the previous head; thread replied and resolved.

Re-gate on bf138972a: fresh_gate GO (CI green, no open threads). Break-it sweep of 141 generated variants plus 173 corpus shapes: no FAIL, no unproven gain. The oracle result of the earlier run (32 translated, 32 MATCH, 0 MISMATCH, 346 refused) is unchanged for the translated HLSL. Sweep of all tests/startup_gfx2hlsl_*_check.py with no arguments: only the two draw-only checks that need adapter arguments exit 1.

Win2025 (dev + release) on the exact head: x2w_pipe.py win2025 2702 --host aws-1 --no-skip-build --py-checks tests/startup_gfx2hlsl_compute_check.py --targets offscreen_check --regex "startup_gfx2hlsl_(compute|mask|lane|vcc|cndmask|join|readfirstlane|cmp)": 56/56 dev, 56/56 release.

Open note, not new in this PR: a mask copy on one branch arm with a plain overwrite on the other, read as a number after the join, is not refused (the tag follows program order); llc does not emit it for an i1 value.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7183256432 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#issuecomment-7183256432). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T05:11:08Z. --- @MasterDomino Ready for review on head bf138972a (re-gate after the CI fix and a review-thread fix). History: marked Ready on ee0deadad, put back to Draft because the Linux CI check startup_gfx2hlsl_bfm_b64 failed there; c7 fixed that test. While re-gating I also confirmed the open review thread (a 64-bit copy of plain data cleared the mask tag, so its truncated low word could be read as a number) and fixed it in 745d2c34c with a check that fails on the previous head; thread replied and resolved. Re-gate on bf138972a: fresh_gate GO (CI green, no open threads). Break-it sweep of 141 generated variants plus 173 corpus shapes: no FAIL, no unproven gain. The oracle result of the earlier run (32 translated, 32 MATCH, 0 MISMATCH, 346 refused) is unchanged for the translated HLSL. Sweep of all `tests/startup_gfx2hlsl_*_check.py` with no arguments: only the two draw-only checks that need adapter arguments exit 1. Win2025 (dev + release) on the exact head: `x2w_pipe.py win2025 2702 --host aws-1 --no-skip-build --py-checks tests/startup_gfx2hlsl_compute_check.py --targets offscreen_check --regex "startup_gfx2hlsl_(compute|mask|lane|vcc|cndmask|join|readfirstlane|cmp)"`: 56/56 dev, 56/56 release. Open note, not new in this PR: a mask copy on one branch arm with a plain overwrite on the other, read as a number after the join, is not refused (the tag follows program order); llc does not emit it for an i1 value. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 06:02:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T05:16:19Z.

Code review location: tools/startup/gfx2hlsl.py; line 3707

@@ -3654,7 +3667,120 @@ def forget_writes(self, name, ops, drop_since=True):
             del self.uniform_expr[v]
         return regs
 
+    MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo')
+    MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi')
+
+    def mask_source_tags(self, base, ops):
+        """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word
+        (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi,
+        exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite
+        its own source."""
+        dests = destinations(base, ops)
+        srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops)
+        masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ())
+        low = high = False
+        for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs):
+            low |= tok in self.MASK_NAMES_LOW
+            high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo')
+            r = reg_range(tok)
+            if r and r[0] == 's':
+                start_tagged = r[1] in masks
+                low |= start_tagged
+                high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1])
+        return low, high
+
+    def propagate_mask_tags(self, base, ops, tags):
+        """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one
+        place the tag moves. A compare or carry writes its single-word mask itself (the decoder
+        names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec)
+        copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag
+        already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of
+        either is lowered (lower())."""
+        low, high = tags
+        self.tag_compare_pair(base, ops)
+        saveexec = base.startswith('s_') and 'saveexec' in base
+        if MASK_COPY_SALU_RE.match(base) and not (low or high):
+            # a copy of plain data: the destination no longer holds a lane mask, whatever an earlier path or join left
+            for tok in destinations(base, ops):
+                r = reg_range(tok)
+                if r and r[0] == 's':
+                    self.masks.difference_update(range(r[1], r[2] + 1))

P1 Badge Keep truncated b64 copies tagged as masks

In a multi-thread compute shader, s_mov_b64 s[20:21], s[4:5]; v_mov_b32 v5, s20 is now accepted even though scalar() still treats the runtime s_mov_b64 as a mask copy and emits s20 = (ud0) & 1. Clearing self.masks here makes v_mov_b32 accept that truncated value, so a subsequent store writes 1 rather than the original root constant, such as case A's 0x01234567; the parent refuses this read. Preserve the mask tag until a full-word numeric copy is actually emitted, or update the b64 lowering before clearing it.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4704176178 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#discussion_r4704176178). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T05:16:19Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3707 ~~~~diff @@ -3654,7 +3667,120 @@ def forget_writes(self, name, ops, drop_since=True): del self.uniform_expr[v] return regs + MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo') + MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi') + + def mask_source_tags(self, base, ops): + """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word + (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi, + exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite + its own source.""" + dests = destinations(base, ops) + srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops) + masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ()) + low = high = False + for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs): + low |= tok in self.MASK_NAMES_LOW + high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo') + r = reg_range(tok) + if r and r[0] == 's': + start_tagged = r[1] in masks + low |= start_tagged + high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1]) + return low, high + + def propagate_mask_tags(self, base, ops, tags): + """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one + place the tag moves. A compare or carry writes its single-word mask itself (the decoder + names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec) + copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag + already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of + either is lowered (lower()).""" + low, high = tags + self.tag_compare_pair(base, ops) + saveexec = base.startswith('s_') and 'saveexec' in base + if MASK_COPY_SALU_RE.match(base) and not (low or high): + # a copy of plain data: the destination no longer holds a lane mask, whatever an earlier path or join left + for tok in destinations(base, ops): + r = reg_range(tok) + if r and r[0] == 's': + self.masks.difference_update(range(r[1], r[2] + 1)) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Keep truncated b64 copies tagged as masks** In a multi-thread compute shader, `s_mov_b64 s[20:21], s[4:5]; v_mov_b32 v5, s20` is now accepted even though `scalar()` still treats the runtime `s_mov_b64` as a mask copy and emits `s20 = (ud0) & 1`. Clearing `self.masks` here makes `v_mov_b32` accept that truncated value, so a subsequent store writes `1` rather than the original root constant, such as case A's `0x01234567`; the parent refuses this read. Preserve the mask tag until a full-word numeric copy is actually emitted, or update the b64 lowering before clearing it. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-26 06:02:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T05:36:44Z.

Code review location: tools/startup/gfx2hlsl.py; line 3707

@@ -3654,7 +3667,120 @@ def forget_writes(self, name, ops, drop_since=True):
             del self.uniform_expr[v]
         return regs
 
+    MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo')
+    MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi')
+
+    def mask_source_tags(self, base, ops):
+        """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word
+        (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi,
+        exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite
+        its own source."""
+        dests = destinations(base, ops)
+        srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops)
+        masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ())
+        low = high = False
+        for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs):
+            low |= tok in self.MASK_NAMES_LOW
+            high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo')
+            r = reg_range(tok)
+            if r and r[0] == 's':
+                start_tagged = r[1] in masks
+                low |= start_tagged
+                high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1])
+        return low, high
+
+    def propagate_mask_tags(self, base, ops, tags):
+        """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one
+        place the tag moves. A compare or carry writes its single-word mask itself (the decoder
+        names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec)
+        copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag
+        already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of
+        either is lowered (lower())."""
+        low, high = tags
+        self.tag_compare_pair(base, ops)
+        saveexec = base.startswith('s_') and 'saveexec' in base
+        if MASK_COPY_SALU_RE.match(base) and not (low or high):
+            # a copy of plain data: the destination no longer holds a lane mask, whatever an earlier path or join left
+            for tok in destinations(base, ops):
+                r = reg_range(tok)
+                if r and r[0] == 's':
+                    self.masks.difference_update(range(r[1], r[2] + 1))

Confirmed and fixed in 745d2c34c (merged on bf138972a). scalar() lowers every b64 move as a mask copy (lane bit only), so clearing the tag on a pair copy of plain data let the truncated low word be read as a number. Now only a 32-bit copy of plain data clears the tag; a 64-bit pair copy keeps it. New check check_lane_mask_pair_copy_of_data_stays_refused in tests/startup_gfx2hlsl_compute_check.py (s_mov_b64 s[20:21], s[4:5]; v_mov_b32 v5, s20 in a 2-thread group is refused; the 32-bit copy of the same word still translates); it fails on the previous head. Win2025 on aws-1, dev + release: 56/56 each.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4704299789 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#discussion_r4704299789). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T05:36:44Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3707 ~~~~diff @@ -3654,7 +3667,120 @@ def forget_writes(self, name, ops, drop_since=True): del self.uniform_expr[v] return regs + MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo') + MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi') + + def mask_source_tags(self, base, ops): + """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word + (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi, + exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite + its own source.""" + dests = destinations(base, ops) + srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops) + masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ()) + low = high = False + for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs): + low |= tok in self.MASK_NAMES_LOW + high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo') + r = reg_range(tok) + if r and r[0] == 's': + start_tagged = r[1] in masks + low |= start_tagged + high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1]) + return low, high + + def propagate_mask_tags(self, base, ops, tags): + """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one + place the tag moves. A compare or carry writes its single-word mask itself (the decoder + names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec) + copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag + already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of + either is lowered (lower()).""" + low, high = tags + self.tag_compare_pair(base, ops) + saveexec = base.startswith('s_') and 'saveexec' in base + if MASK_COPY_SALU_RE.match(base) and not (low or high): + # a copy of plain data: the destination no longer holds a lane mask, whatever an earlier path or join left + for tok in destinations(base, ops): + r = reg_range(tok) + if r and r[0] == 's': + self.masks.difference_update(range(r[1], r[2] + 1)) ~~~~ --- Confirmed and fixed in 745d2c34c (merged on bf138972a). `scalar()` lowers every b64 move as a mask copy (lane bit only), so clearing the tag on a pair copy of plain data let the truncated low word be read as a number. Now only a 32-bit copy of plain data clears the tag; a 64-bit pair copy keeps it. New check `check_lane_mask_pair_copy_of_data_stays_refused` in `tests/startup_gfx2hlsl_compute_check.py` (`s_mov_b64 s[20:21], s[4:5]; v_mov_b32 v5, s20` in a 2-thread group is refused; the 32-bit copy of the same word still translates); it fails on the previous head. Win2025 on aws-1, dev + release: 56/56 each. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 06:02:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T05:44:25Z.

Code review location: tools/startup/gfx2hlsl.py; line 3753

@@ -3698,7 +3711,122 @@ def forget_writes(self, name, ops, drop_since=True):
             del self.uniform_expr[v]
         return regs
 
+    MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo')
+    MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi')
+
+    def mask_source_tags(self, base, ops):
+        """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word
+        (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi,
+        exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite
+        its own source."""
+        dests = destinations(base, ops)
+        srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops)
+        masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ())
+        low = high = False
+        for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs):
+            low |= tok in self.MASK_NAMES_LOW
+            high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo')
+            r = reg_range(tok)
+            if r and r[0] == 's':
+                start_tagged = r[1] in masks
+                low |= start_tagged
+                high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1])
+        return low, high
+
+    def propagate_mask_tags(self, base, ops, tags):
+        """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one
+        place the tag moves. A compare or carry writes its single-word mask itself (the decoder
+        names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec)
+        copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag
+        already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of
+        either is lowered (lower())."""
+        low, high = tags
+        self.tag_compare_pair(base, ops)
+        saveexec = base.startswith('s_') and 'saveexec' in base
+        if MASK_COPY_SALU_RE.match(base) and not (low or high):
+            # a 32-bit copy of plain data: the destination no longer holds a lane mask, whatever an earlier path or join
+            # left. A 64-bit pair copy keeps its tag: scalar() lowers every b64 move as a mask copy (the lane bit only),
+            # so the truncated word must stay refused as numeric data.
+            for tok in destinations(base, ops):
+                r = reg_range(tok)
+                if r and r[0] == 's' and r[2] == r[1]:
+                    self.masks.discard(r[1])

P1 Badge Retain WQM mask tags until the destination is actually written

In a four-thread compute group, inserting v_cmp_gt_i32_e64 s20, 17, v0; s_wqm_b32 s20, 0; v_mov_b32 v5, s20 before case A's store now translates, whereas the parent refuses the final move. MASK_COPY_SALU_RE includes WQM, but _lower() treats s_wqm_b32 as a no-op, so this cleanup removes the mask tag without replacing the old per-lane compare value. The generated shader consequently stores 1 for these lanes instead of the WQM result 0. Preserve the tag for this no-op lowering, or implement the actual register write before clearing it.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4704346839 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#discussion_r4704346839). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T05:44:25Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3753 ~~~~diff @@ -3698,7 +3711,122 @@ def forget_writes(self, name, ops, drop_since=True): del self.uniform_expr[v] return regs + MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo') + MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi') + + def mask_source_tags(self, base, ops): + """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word + (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi, + exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite + its own source.""" + dests = destinations(base, ops) + srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops) + masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ()) + low = high = False + for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs): + low |= tok in self.MASK_NAMES_LOW + high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo') + r = reg_range(tok) + if r and r[0] == 's': + start_tagged = r[1] in masks + low |= start_tagged + high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1]) + return low, high + + def propagate_mask_tags(self, base, ops, tags): + """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one + place the tag moves. A compare or carry writes its single-word mask itself (the decoder + names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec) + copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag + already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of + either is lowered (lower()).""" + low, high = tags + self.tag_compare_pair(base, ops) + saveexec = base.startswith('s_') and 'saveexec' in base + if MASK_COPY_SALU_RE.match(base) and not (low or high): + # a 32-bit copy of plain data: the destination no longer holds a lane mask, whatever an earlier path or join + # left. A 64-bit pair copy keeps its tag: scalar() lowers every b64 move as a mask copy (the lane bit only), + # so the truncated word must stay refused as numeric data. + for tok in destinations(base, ops): + r = reg_range(tok) + if r and r[0] == 's' and r[2] == r[1]: + self.masks.discard(r[1]) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Retain WQM mask tags until the destination is actually written** In a four-thread compute group, inserting `v_cmp_gt_i32_e64 s20, 17, v0; s_wqm_b32 s20, 0; v_mov_b32 v5, s20` before case A's store now translates, whereas the parent refuses the final move. `MASK_COPY_SALU_RE` includes WQM, but `_lower()` treats `s_wqm_b32` as a no-op, so this cleanup removes the mask tag without replacing the old per-lane compare value. The generated shader consequently stores `1` for these lanes instead of the WQM result `0`. Preserve the tag for this no-op lowering, or implement the actual register write before clearing it. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-26 07:00:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T06:23:37Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069464170 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#pullrequestreview-6069464170). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T06:23:37Z. **Review:** COMMENTED --- _No description provided._
MasterDomino commented 2026-11-26 07:00:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T06:50:13Z.

Review: CHANGES_REQUESTED


Reviewed 7d3472d8. It fixes the WQM thread, and its merge with current main (e3cf6a91) passes the gfx2hlsl group here: 287/289 on WARP and an AMD Radeon RX 9070 XT (driver 32.0.32029.2010, Windows 11 build 26300). The two failures are already on main:

  • fma_mix_dispatch_hardware (#2746);
  • f16_alu_draw_hardware, where -0 products read back as +0.

Seven one-line mutations of the new tag and refusal logic each fail startup_gfx2hlsl_compute_check.py: the vector and scalar numeric checks off, no derived-word tag, no compare-pair high tag, the high tag not cleared on overwrite, the WQM fix reverted, and "exact" widened to 64 threads. Legitimate mask uses emit identical HLSL before and after: v_cndmask with VCC or an SGPR, s_and / s_or / s_andn2 on masks, saveexec, and carry-in.

One change is needed: a cache revision bump. main translates programs that this PR now refuses.

  • Examples: in a 64-thread compute group, v_cmp_lt_i32 vcc_lo, 5, v0 followed by any of v_cvt_f32_u32 v5, vcc_lo, s_add_u32 s6, vcc_lo, 1, or s_and_b32 s6, vcc_lo, 0xff; v_add_nc_u32 v5, s6, v5 translates on main and is refused here. About 15 more stage-level forms flip the same way.
  • Why it matters: their cached HLSL is wrong and would still be loaded under the same key.
  • What to change: advance x2w-startup-shader-19 / 19cs to 20 / 20cs, or one past whatever lands first; #2006 just took 20, so check main. That's pipeline_key / compute_key, d3d12_draw.inl, and the tests and docs that spell the revision.

Non-blocking, and also wrong on main:

  • Complemented masks: in a one-thread group, s_not_b32 s7, s6; s_add_i32 s1, s7, 1 is lowered as (~s6) & 1, while hardware holds 0xFFFFFFFE or 0xFFFFFFFF. The high word of s_not_b64 s[6:7], exec is modelled as 0 but is 0xFFFFFFFF. So the exactness argument holds only for masks that aren't complemented.
  • Carry forms: a mask as a data source of a _co_ form (v_add_co_u32_e64 v1, s8, s6, v2) is still accepted.
  • s_cselect_b32: a mask through it doesn't carry the tag; only the b64 form does.

Commands: ctest --preset dev --no-tests=error -j 8 -R '^(startup_gfx2hlsl|startup_compute_readfirstlane)' on the PR head and on its merge with main; python -B tests/startup_gfx2hlsl_{compute,mask_overwrite,readfirstlane_uniform,readfirstlane_recompute,shift64,bfm_b64,vcc_hi}_check.py.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069689581 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#pullrequestreview-6069689581). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T06:50:13Z. **Review:** CHANGES_REQUESTED --- Reviewed `7d3472d8`. It fixes the WQM thread, and its merge with current `main` (`e3cf6a91`) passes the gfx2hlsl group here: 287/289 on WARP and an AMD Radeon RX 9070 XT (driver 32.0.32029.2010, Windows 11 build 26300). The two failures are already on `main`: - `fma_mix_dispatch_hardware` (#2746); - `f16_alu_draw_hardware`, where -0 products read back as +0. Seven one-line mutations of the new tag and refusal logic each fail `startup_gfx2hlsl_compute_check.py`: the vector and scalar numeric checks off, no derived-word tag, no compare-pair high tag, the high tag not cleared on overwrite, the WQM fix reverted, and "exact" widened to 64 threads. Legitimate mask uses emit identical HLSL before and after: `v_cndmask` with VCC or an SGPR, `s_and` / `s_or` / `s_andn2` on masks, saveexec, and carry-in. **One change is needed: a cache revision bump.** `main` translates programs that this PR now refuses. - **Examples:** in a 64-thread compute group, `v_cmp_lt_i32 vcc_lo, 5, v0` followed by any of `v_cvt_f32_u32 v5, vcc_lo`, `s_add_u32 s6, vcc_lo, 1`, or `s_and_b32 s6, vcc_lo, 0xff; v_add_nc_u32 v5, s6, v5` translates on `main` and is refused here. About 15 more stage-level forms flip the same way. - **Why it matters:** their cached HLSL is wrong and would still be loaded under the same key. - **What to change:** advance `x2w-startup-shader-19` / `19cs` to `20` / `20cs`, or one past whatever lands first; #2006 just took `20`, so check `main`. That's `pipeline_key` / `compute_key`, `d3d12_draw.inl`, and the tests and docs that spell the revision. **Non-blocking, and also wrong on `main`:** - **Complemented masks:** in a one-thread group, `s_not_b32 s7, s6; s_add_i32 s1, s7, 1` is lowered as `(~s6) & 1`, while hardware holds 0xFFFFFFFE or 0xFFFFFFFF. The high word of `s_not_b64 s[6:7], exec` is modelled as 0 but is 0xFFFFFFFF. So the exactness argument holds only for masks that aren't complemented. - **Carry forms:** a mask as a data source of a `_co_` form (`v_add_co_u32_e64 v1, s8, s6, v2`) is still accepted. - **`s_cselect_b32`:** a mask through it doesn't carry the tag; only the b64 form does. Commands: `ctest --preset dev --no-tests=error -j 8 -R '^(startup_gfx2hlsl|startup_compute_readfirstlane)'` on the PR head and on its merge with `main`; `python -B tests/startup_gfx2hlsl_{compute,mask_overwrite,readfirstlane_uniform,readfirstlane_recompute,shift64,bfm_b64,vcc_hi}_check.py`. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 07:00:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T06:23:37Z.

Code review location: tools/startup/gfx2hlsl.py; line 3753

@@ -3698,7 +3711,122 @@ def forget_writes(self, name, ops, drop_since=True):
             del self.uniform_expr[v]
         return regs
 
+    MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo')
+    MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi')
+
+    def mask_source_tags(self, base, ops):
+        """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word
+        (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi,
+        exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite
+        its own source."""
+        dests = destinations(base, ops)
+        srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops)
+        masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ())
+        low = high = False
+        for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs):
+            low |= tok in self.MASK_NAMES_LOW
+            high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo')
+            r = reg_range(tok)
+            if r and r[0] == 's':
+                start_tagged = r[1] in masks
+                low |= start_tagged
+                high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1])
+        return low, high
+
+    def propagate_mask_tags(self, base, ops, tags):
+        """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one
+        place the tag moves. A compare or carry writes its single-word mask itself (the decoder
+        names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec)
+        copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag
+        already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of
+        either is lowered (lower())."""
+        low, high = tags
+        self.tag_compare_pair(base, ops)
+        saveexec = base.startswith('s_') and 'saveexec' in base
+        if MASK_COPY_SALU_RE.match(base) and not (low or high):
+            # a 32-bit copy of plain data: the destination no longer holds a lane mask, whatever an earlier path or join
+            # left. A 64-bit pair copy keeps its tag: scalar() lowers every b64 move as a mask copy (the lane bit only),
+            # so the truncated word must stay refused as numeric data.
+            for tok in destinations(base, ops):
+                r = reg_range(tok)
+                if r and r[0] == 's' and r[2] == r[1]:
+                    self.masks.discard(r[1])

Confirmed (repro: v_cmp_gt_i32_e64 s20, 17, v0; s_wqm_b32 s20, 0; v_mov_b32 v5, s20 translated in a 4-thread group) and fixed in 7d3472d8d: s_wqm is a no-op in the lowering, so it is excluded from the plain-data tag cleanup and a mask it nominally rewrites keeps its tag. New check check_lane_mask_wqm_keeps_tag in tests/startup_gfx2hlsl_compute_check.py (fails on the previous head). Win2025 on aws-1, dev + release: 59/59 each.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4704617055 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#discussion_r4704617055). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T06:23:37Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3753 ~~~~diff @@ -3698,7 +3711,122 @@ def forget_writes(self, name, ops, drop_since=True): del self.uniform_expr[v] return regs + MASK_NAMES_LOW = ('vcc', 'vcc_lo', 'exec', 'exec_lo') + MASK_NAMES_HIGH = ('vcc', 'vcc_hi', 'exec', 'exec_hi') + + def mask_source_tags(self, base, ops): + """(low, high): whether a source operand of the instruction carries a lane-mask word. low = a mask's low word + (vcc/exec, an SGPR in self.masks, a pair that starts in one); high = the high word of a wave64 mask (vcc_hi, + exec_hi, a pair holding one, an SGPR in self.mask_high). Read before the instruction runs: it may overwrite + its own source.""" + dests = destinations(base, ops) + srcs = ops[len(dests):] if dests and ops[:len(dests)] == dests else list(ops) + masks, high_regs = getattr(self, 'masks', ()), getattr(self, 'mask_high', ()) + low = high = False + for tok in (t.strip().lstrip('-|').rstrip('|') for t in srcs): + low |= tok in self.MASK_NAMES_LOW + high |= tok in self.MASK_NAMES_HIGH and tok not in ('vcc_lo', 'exec_lo') + r = reg_range(tok) + if r and r[0] == 's': + start_tagged = r[1] in masks + low |= start_tagged + high |= any(n in high_regs for n in range(r[1], r[2] + 1)) or (start_tagged and r[2] > r[1]) + return low, high + + def propagate_mask_tags(self, base, ops, tags): + """After an instruction ran: the SGPRs it wrote carry the lane-mask tag of what they were made from. This is the one + place the tag moves. A compare or carry writes its single-word mask itself (the decoder + names a wave64 compare destination s0, not s[0:1]); a mask-only scalar op (mov, bitwise, cselect, saveexec) + copies the tag of its sources to its destination, both words of a b64 pair; any other write cleared the tag + already (set_s). self.masks holds the low word, self.mask_high the high word of a wave64 pair: no numeric read of + either is lowered (lower()).""" + low, high = tags + self.tag_compare_pair(base, ops) + saveexec = base.startswith('s_') and 'saveexec' in base + if MASK_COPY_SALU_RE.match(base) and not (low or high): + # a 32-bit copy of plain data: the destination no longer holds a lane mask, whatever an earlier path or join + # left. A 64-bit pair copy keeps its tag: scalar() lowers every b64 move as a mask copy (the lane bit only), + # so the truncated word must stay refused as numeric data. + for tok in destinations(base, ops): + r = reg_range(tok) + if r and r[0] == 's' and r[2] == r[1]: + self.masks.discard(r[1]) ~~~~ --- Confirmed (repro: `v_cmp_gt_i32_e64 s20, 17, v0; s_wqm_b32 s20, 0; v_mov_b32 v5, s20` translated in a 4-thread group) and fixed in 7d3472d8d: `s_wqm` is a no-op in the lowering, so it is excluded from the plain-data tag cleanup and a mask it nominally rewrites keeps its tag. New check `check_lane_mask_wqm_keeps_tag` in `tests/startup_gfx2hlsl_compute_check.py` (fails on the previous head). Win2025 on aws-1, dev + release: 59/59 each. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 08:01:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T07:56:06Z.


Thanks for the review and the mutation runs.

Cache revision: done. The startup shader cache revision advances from 22 / 22cs to 23 / 23cs: pipeline_key and compute_key in tools/startup/gfx2hlsl.py, revision / compute_revision in src/startup_stubs/d3d12_draw.inl, the two runtime tests that spell it (startup_indirect_draw_indexed.cpp, startup_resource_retire_title.cpp), docs/startup-runtime.md, and the Python checks that pin it. The two known-answer keys (startup_shader_cache_key_check.py, startup_compute_request_offline_check.py) are recomputed with the independent hash loops those tests already carry. Main moved to revision 22 while this was open, so this is one past it.

Also in this push: main merged again, and two controls that main added (#2769) now meet the lane-mask rule before the uniformity rule (predicate as OR source accepts either refusal).

Your non-blocking notes, left for a follow-up (all three are wrong on main today and none is made worse here; they widen the rule rather than fix this PR's):

  • complemented masks (s_not_b32 / s_not_b64 s[6:7], exec): the tag survives a complement, but the value modelled for it is not the hardware's;
  • a mask as a data source of a _co_ carry form (v_add_co_u32_e64 v1, s8, s6, v2);
  • s_cselect_b32 carrying the mask tag like the b64 form.

I can take them as a separate PR with their own WARP readback if you want them.

Commands run on the new head: the full Linux Python check list from the workflow (same 15 environment failures as origin/main, nothing new); python -B tests/startup_gfx2hlsl_{compute,mask_overwrite,readfirstlane_uniform,readfirstlane_recompute,shift64,bfm_b64}_check.py, startup_shader_cache_key_check.py, startup_compute_request_offline_check.py; the mask-tag fuzz variants over four llc seeds: 0 holes.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7185996536 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#issuecomment-7185996536). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T07:56:06Z. --- Thanks for the review and the mutation runs. **Cache revision: done.** The startup shader cache revision advances from 22 / 22cs to 23 / 23cs: `pipeline_key` and `compute_key` in `tools/startup/gfx2hlsl.py`, `revision` / `compute_revision` in `src/startup_stubs/d3d12_draw.inl`, the two runtime tests that spell it (`startup_indirect_draw_indexed.cpp`, `startup_resource_retire_title.cpp`), `docs/startup-runtime.md`, and the Python checks that pin it. The two known-answer keys (`startup_shader_cache_key_check.py`, `startup_compute_request_offline_check.py`) are recomputed with the independent hash loops those tests already carry. Main moved to revision 22 while this was open, so this is one past it. Also in this push: main merged again, and two controls that main added (#2769) now meet the lane-mask rule before the uniformity rule (`predicate as OR source` accepts either refusal). **Your non-blocking notes, left for a follow-up** (all three are wrong on `main` today and none is made worse here; they widen the rule rather than fix this PR's): - complemented masks (`s_not_b32` / `s_not_b64 s[6:7], exec`): the tag survives a complement, but the value modelled for it is not the hardware's; - a mask as a data source of a `_co_` carry form (`v_add_co_u32_e64 v1, s8, s6, v2`); - `s_cselect_b32` carrying the mask tag like the b64 form. I can take them as a separate PR with their own WARP readback if you want them. Commands run on the new head: the full Linux Python check list from the workflow (same 15 environment failures as `origin/main`, nothing new); `python -B tests/startup_gfx2hlsl_{compute,mask_overwrite,readfirstlane_uniform,readfirstlane_recompute,shift64,bfm_b64}_check.py`, `startup_shader_cache_key_check.py`, `startup_compute_request_offline_check.py`; the mask-tag fuzz variants over four llc seeds: 0 holes. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-26 09:04:38 +00:00
MasterDomino commented 2026-11-26 09:04:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T08:01:48Z.

Review: APPROVED


Approving fcfd9f1c. The cache revision moves to x2w-startup-shader-23 / 23cs, one past current main (22).

Since 7d3472d8, which I reviewed with mutants:

  • Translator: apart from the revision line, the PR's own gfx2hlsl.py diff is identical.
  • Tests: the only test change I checked for semantics is narrow. predicate as OR source also accepts the mask-rule refusal (v_and_or_b32 reads lane mask s2 as numeric data), so the case stays refused under either rule.
  • Merge and CI: it merges cleanly onto main 624f5927, and CI is green at the head.

Commands, on Windows 11 build 26300, at fcfd9f1c; all exit 0:

  • python -B tests/startup_gfx2hlsl_{compute,mask_overwrite,readfirstlane_uniform,readfirstlane_recompute,readfirstlane_load_recompute,shift64,bfm_b64,vcc_hi,mask_data}_check.py;
  • startup_shader_cache_rekey_check.py, startup_shader_cache_key_check.py, startup_compute_request_offline_check.py;
  • startup_gfx2hlsl_compute_check.py binary <llvm-mc 15>: "fixture words match llvm-mc".

@tedin7, yes please: a separate PR for the three follow-ups (complemented masks, _co_ carry data sources, s_cselect_b32), each with its readback, would be welcome.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6070387307 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2702#pullrequestreview-6070387307). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T08:01:48Z. **Review:** APPROVED --- Approving `fcfd9f1c`. The cache revision moves to `x2w-startup-shader-23` / `23cs`, one past current `main` (`22`). **Since `7d3472d8`, which I reviewed with mutants:** - **Translator:** apart from the revision line, the PR's own `gfx2hlsl.py` diff is identical. - **Tests:** the only test change I checked for semantics is narrow. `predicate as OR source` also accepts the mask-rule refusal (`v_and_or_b32 reads lane mask s2 as numeric data`), so the case stays refused under either rule. - **Merge and CI:** it merges cleanly onto `main` `624f5927`, and CI is green at the head. Commands, on Windows 11 build 26300, at `fcfd9f1c`; all exit 0: - `python -B tests/startup_gfx2hlsl_{compute,mask_overwrite,readfirstlane_uniform,readfirstlane_recompute,readfirstlane_load_recompute,shift64,bfm_b64,vcc_hi,mask_data}_check.py`; - `startup_shader_cache_rekey_check.py`, `startup_shader_cache_key_check.py`, `startup_compute_request_offline_check.py`; - `startup_gfx2hlsl_compute_check.py binary <llvm-mc 15>`: "fixture words match llvm-mc". @tedin7, yes please: a separate PR for the three follow-ups (complemented masks, `_co_` carry data sources, `s_cselect_b32`), each with its readback, would be welcome. AI-assisted; commands listed were executed locally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
R0Y00/Xbox2Windows!2694
No description provided.