shader: lower v_readlane_b32 and v_permlanex16_b32 in gfx2hlsl (Part of #1723) #2025

Closed
tedin7 wants to merge 2 commits from upstream-pr/2032 into main
tedin7 commented 2026-11-24 23:30:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T23:30:47Z.


Part of #1723

What this unblocks: Run 20 census #17 (40/39 pairs), v_readlane_b32 and v_permlanex16_b32.

Branch: x2w-r20-readlane-perm (local, not pushed).

Changes in tools/startup/gfx2hlsl.py:

  • v_readlane_b32 sD, vS, sel: sD = vS, only when vS is a proven uniform VGPR (same rule as v_readfirstlane_b32). The model runs one lane, so any lane gives the same word. The lane select may be an SGPR or inline constant.
  • v_permlanex16_b32 vD, vS, s0, s1: vD = vS for a proven uniform vS; vD stays uniform.
  • Refused: non-uniform source, branches or unknown exec, VGPR lane select, non-SGPR destination, and any modifier (the fetch-inactive and bound_ctrl flags change inactive-lane results the one-lane model cannot see).

Verification:

  • python3 -I tests/startup_gfx2hlsl_readlane_perm_check.py -> PASS (new test, registered in CMakeLists.txt as startup_gfx2hlsl_readlane_perm).
  • Same test with origin/main tools -> fails with Unsupported: v_readlane_b32.
  • python3 -I tests/startup_uniform_lane_check.py -> PASS
  • python3 -I tests/startup_gfx2hlsl_op_refusals_check.py -> PASS
  • Not run: Win2025 build and CTest (this host is Linux, Python tests only).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593543015 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2032). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T23:30:47Z. --- Part of #1723 What this unblocks: Run 20 census #17 (40/39 pairs), `v_readlane_b32` and `v_permlanex16_b32`. Branch: `x2w-r20-readlane-perm` (local, not pushed). Changes in `tools/startup/gfx2hlsl.py`: - `v_readlane_b32 sD, vS, sel`: `sD = vS`, only when `vS` is a proven uniform VGPR (same rule as `v_readfirstlane_b32`). The model runs one lane, so any lane gives the same word. The lane select may be an SGPR or inline constant. - `v_permlanex16_b32 vD, vS, s0, s1`: `vD = vS` for a proven uniform `vS`; `vD` stays uniform. - Refused: non-uniform source, branches or unknown exec, VGPR lane select, non-SGPR destination, and any modifier (the fetch-inactive and bound_ctrl flags change inactive-lane results the one-lane model cannot see). Verification: - `python3 -I tests/startup_gfx2hlsl_readlane_perm_check.py` -> PASS (new test, registered in CMakeLists.txt as `startup_gfx2hlsl_readlane_perm`). - Same test with `origin/main` tools -> fails with `Unsupported: v_readlane_b32`. - `python3 -I tests/startup_uniform_lane_check.py` -> PASS - `python3 -I tests/startup_gfx2hlsl_op_refusals_check.py` -> PASS - Not run: Win2025 build and CTest (this host is Linux, Python tests only). AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-25 00:05:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:37:38Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5d64e8bcc5

ℹ️ 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:6049161717 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2032#pullrequestreview-6049161717). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:37:38Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `5d64e8bcc5` <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-25 01:01:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:56:46Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049906147 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2032#pullrequestreview-6049906147). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:56:46Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-25 01:01:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:31:00Z.


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-24T23:37:40.839920Z 5d64e8b PR opened
ℹ️ 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:7147487395 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2032#issuecomment-7147487395). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:31:00Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5d64e8bcc5058f90b2c39f124b5590186c4343ff","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-24T23:37:40.839920Z">2026-11-24T23:37:40.839920Z</relative-time> | `5d64e8b` | PR opened | <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>
denn0x commented 2026-11-25 01:02:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-25T00:55:03Z.


Thanks. One question on the uniform rule, and some numbers.

Inactive lanes. uniform_v is set when a VGPR is written from a uniform SGPR while exec still equals the entry mask. Lanes outside that mask never receive the word. v_readlane_b32 reads the named lane whatever EXEC says, so take a partly filled wave and a lane select that names a lane outside the entry mask. As I read the ISA, the hardware returns whatever that lane's VGPR still holds, but the translation returns the uniform word.

v_permlanex16_b32 without FI likewise depends on whether the source lane is active. I have not built a hardware case for either. Is the uniform proof meant to cover lanes that are not in the entry mask? If not, the restriction would need either a source written for every lane (whole-wave or v_writelane), or a note that the result is only proven for active lane selects.

Coverage on real programs (a private executable's ordinary pixel/vertex requests, decode and translate only, aggregate counts):

  • 503 requests use v_readlane_b32 in the pixel stage.
  • Their first refusal is the same with and without this PR. Most stop earlier, at v_readfirstlane_b32 requires a proven uniform source.
  • None of the uses I see have a uniform source:
    • v_readlane_b32 sN, vM, 31 (852) and v_permlanex16_b32 ..., 0, 0 (1,085) appear together with row_mirror / row_half_mirror DPP. That looks like a wave reduction.
    • v_writelane_b32 / v_readlane_b32 pairs with lane constants 0, 1, 2, ... (hundreds per lane index) look like SGPR values spilled into the lanes of one VGPR.

The spill shape can be lowered exactly without a cross-lane model: each lane index of that VGPR becomes a separate scalar slot, written by v_writelane and read by v_readlane with the same constant. That could be a separate item if someone wants it.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149021486 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2032#issuecomment-7149021486). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-25T00:55:03Z. --- Thanks. One question on the uniform rule, and some numbers. **Inactive lanes.** `uniform_v` is set when a VGPR is written from a uniform SGPR while exec still equals the entry mask. Lanes outside that mask never receive the word. `v_readlane_b32` reads the named lane whatever EXEC says, so take a partly filled wave and a lane select that names a lane outside the entry mask. As I read the ISA, the hardware returns whatever that lane's VGPR still holds, but the translation returns the uniform word. `v_permlanex16_b32` without FI likewise depends on whether the source lane is active. I have not built a hardware case for either. Is the uniform proof meant to cover lanes that are not in the entry mask? If not, the restriction would need either a source written for every lane (whole-wave or `v_writelane`), or a note that the result is only proven for active lane selects. **Coverage on real programs** (a private executable's ordinary pixel/vertex requests, decode and translate only, aggregate counts): - 503 requests use `v_readlane_b32` in the pixel stage. - Their first refusal is the same with and without this PR. Most stop earlier, at `v_readfirstlane_b32 requires a proven uniform source`. - None of the uses I see have a uniform source: - `v_readlane_b32 sN, vM, 31` (852) and `v_permlanex16_b32 ..., 0, 0` (1,085) appear together with `row_mirror` / `row_half_mirror` DPP. That looks like a wave reduction. - `v_writelane_b32` / `v_readlane_b32` pairs with lane constants 0, 1, 2, ... (hundreds per lane index) look like SGPR values spilled into the lanes of one VGPR. The spill shape can be lowered exactly without a cross-lane model: each lane index of that VGPR becomes a separate scalar slot, written by `v_writelane` and read by `v_readlane` with the same constant. That could be a separate item if someone wants it.
chatgpt-codex-connector[bot commented 2026-11-25 01:02:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:37:38Z.

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

@@ -1330,6 +1330,44 @@ def op_v_readfirstlane_b32(self, ops, mods):
             raise Unsupported('v_readfirstlane_b32 requires a proven uniform source')
         self.set_s(reg_range(ops[0])[1], self.u(ops[1]))
 
+    def uniform_vgpr(self, name, tok):
+        """VGPR number of tok when every lane holds the same proven value, else Unsupported."""
+        src = reg_range(tok)
+        if (self.has_branches or not self.exec_known or not src or src[0] != 'v' or src[1] != src[2]
+                or src[1] not in self.uniform_v):
+            raise Unsupported('%s requires a proven uniform source' % name)
+        return src[1]
+
+    def op_v_readlane_b32(self, ops, mods):
+        # The model runs one lane of unknown index, so reading any lane equals reading this one only when
+        # the VGPR is proven uniform. The lane select (SGPR or inline constant) then does not change the value.
+        if mods or len(ops) != 3:
+            raise Unsupported('v_readlane_b32 with %d operands and modifiers %s' % (len(ops), mods))
+        dst, sel = reg_range(ops[0]), reg_range(ops[2])
+        if not dst or dst[0] != 's' or dst[1] != dst[2] or (sel and (sel[0] != 's' or sel[1] != sel[2])):
+            raise Unsupported('v_readlane_b32 operands %s, %s: expected a single SGPR and a scalar lane select' % (ops[0], ops[2]))
+        src = self.uniform_vgpr('v_readlane_b32', ops[1])
+        self.u(ops[2])
+        self.set_s(dst[1], 'v%d' % src)
+
+    def op_v_permlanex16_b32(self, ops, mods):
+        # Lane i reads lane sel of the other row of 16. For a proven uniform VGPR every lane holds the
+        # same word, so the result is that word. The fetch-inactive and bound_ctrl flags change what an
+        # inactive source lane yields, which the one-lane model cannot see: they are refused.
+        if mods or len(ops) != 4:
+            raise Unsupported('v_permlanex16_b32 with %d operands and modifiers %s' % (len(ops), mods))
+        dst = reg_range(ops[0])
+        if not dst or dst[0] != 'v' or dst[1] != dst[2] or dst[1] > 255:
+            raise Unsupported('v_permlanex16_b32 destination %s: expected a single VGPR' % ops[0])
+        for tok in ops[2:]:
+            sel = reg_range(tok)
+            if sel and (sel[0] != 's' or sel[1] != sel[2]):
+                raise Unsupported('v_permlanex16_b32 lane select %s: expected a scalar register' % tok)
+            self.u(tok)
+        src = self.uniform_vgpr('v_permlanex16_b32', ops[1])
+        self.set_v(dst[1], 'v%d' % src)
+        self.uniform_v.add(dst[1])

P1 Badge Prove source-lane activity before collapsing cross-row permutes

On a pixel wave with a sparse entry EXEC mask, exec_known only means EXEC still equals its entry value, and uniform_v is populated by a conversion that writes active lanes only. Consequently, an accepted v_permlanex16_b32 v5, v4, 0, 0 in lane 0 can select inactive lane 16: with default FI=0/BOUND_CTRL=0, it retains the old v5, whereas this path emits v5 = v4 and marks the result uniform. For example, initializing v5 to 9 and converting a scalar-buffer value of 1.0 into v4 produces 9 on the guest but 1 in the translation. Require proof that selected source lanes are active, or model/refuse the inactive-source case before applying this identity.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688059217 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2032#discussion_r4688059217). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:37:38Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1369 ~~~~diff @@ -1330,6 +1330,44 @@ def op_v_readfirstlane_b32(self, ops, mods): raise Unsupported('v_readfirstlane_b32 requires a proven uniform source') self.set_s(reg_range(ops[0])[1], self.u(ops[1])) + def uniform_vgpr(self, name, tok): + """VGPR number of tok when every lane holds the same proven value, else Unsupported.""" + src = reg_range(tok) + if (self.has_branches or not self.exec_known or not src or src[0] != 'v' or src[1] != src[2] + or src[1] not in self.uniform_v): + raise Unsupported('%s requires a proven uniform source' % name) + return src[1] + + def op_v_readlane_b32(self, ops, mods): + # The model runs one lane of unknown index, so reading any lane equals reading this one only when + # the VGPR is proven uniform. The lane select (SGPR or inline constant) then does not change the value. + if mods or len(ops) != 3: + raise Unsupported('v_readlane_b32 with %d operands and modifiers %s' % (len(ops), mods)) + dst, sel = reg_range(ops[0]), reg_range(ops[2]) + if not dst or dst[0] != 's' or dst[1] != dst[2] or (sel and (sel[0] != 's' or sel[1] != sel[2])): + raise Unsupported('v_readlane_b32 operands %s, %s: expected a single SGPR and a scalar lane select' % (ops[0], ops[2])) + src = self.uniform_vgpr('v_readlane_b32', ops[1]) + self.u(ops[2]) + self.set_s(dst[1], 'v%d' % src) + + def op_v_permlanex16_b32(self, ops, mods): + # Lane i reads lane sel of the other row of 16. For a proven uniform VGPR every lane holds the + # same word, so the result is that word. The fetch-inactive and bound_ctrl flags change what an + # inactive source lane yields, which the one-lane model cannot see: they are refused. + if mods or len(ops) != 4: + raise Unsupported('v_permlanex16_b32 with %d operands and modifiers %s' % (len(ops), mods)) + dst = reg_range(ops[0]) + if not dst or dst[0] != 'v' or dst[1] != dst[2] or dst[1] > 255: + raise Unsupported('v_permlanex16_b32 destination %s: expected a single VGPR' % ops[0]) + for tok in ops[2:]: + sel = reg_range(tok) + if sel and (sel[0] != 's' or sel[1] != sel[2]): + raise Unsupported('v_permlanex16_b32 lane select %s: expected a scalar register' % tok) + self.u(tok) + src = self.uniform_vgpr('v_permlanex16_b32', ops[1]) + self.set_v(dst[1], 'v%d' % src) + self.uniform_v.add(dst[1]) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Prove source-lane activity before collapsing cross-row permutes** On a pixel wave with a sparse entry EXEC mask, `exec_known` only means EXEC still equals its entry value, and `uniform_v` is populated by a conversion that writes active lanes only. Consequently, an accepted `v_permlanex16_b32 v5, v4, 0, 0` in lane 0 can select inactive lane 16: with default FI=0/BOUND_CTRL=0, it retains the old `v5`, whereas this path emits `v5 = v4` and marks the result uniform. For example, initializing `v5` to 9 and converting a scalar-buffer value of 1.0 into `v4` produces 9 on the guest but 1 in the translation. Require proof that selected source lanes are active, or model/refuse the inactive-source case before applying this identity. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-25 01:02:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:56:46Z.

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

@@ -1330,6 +1330,44 @@ def op_v_readfirstlane_b32(self, ops, mods):
             raise Unsupported('v_readfirstlane_b32 requires a proven uniform source')
         self.set_s(reg_range(ops[0])[1], self.u(ops[1]))
 
+    def uniform_vgpr(self, name, tok):
+        """VGPR number of tok when every lane holds the same proven value, else Unsupported."""
+        src = reg_range(tok)
+        if (self.has_branches or not self.exec_known or not src or src[0] != 'v' or src[1] != src[2]
+                or src[1] not in self.uniform_v):
+            raise Unsupported('%s requires a proven uniform source' % name)
+        return src[1]
+
+    def op_v_readlane_b32(self, ops, mods):
+        # The model runs one lane of unknown index, so reading any lane equals reading this one only when
+        # the VGPR is proven uniform. The lane select (SGPR or inline constant) then does not change the value.
+        if mods or len(ops) != 3:
+            raise Unsupported('v_readlane_b32 with %d operands and modifiers %s' % (len(ops), mods))
+        dst, sel = reg_range(ops[0]), reg_range(ops[2])
+        if not dst or dst[0] != 's' or dst[1] != dst[2] or (sel and (sel[0] != 's' or sel[1] != sel[2])):
+            raise Unsupported('v_readlane_b32 operands %s, %s: expected a single SGPR and a scalar lane select' % (ops[0], ops[2]))
+        src = self.uniform_vgpr('v_readlane_b32', ops[1])
+        self.u(ops[2])
+        self.set_s(dst[1], 'v%d' % src)
+
+    def op_v_permlanex16_b32(self, ops, mods):
+        # Lane i reads lane sel of the other row of 16. For a proven uniform VGPR every lane holds the
+        # same word, so the result is that word. The fetch-inactive and bound_ctrl flags change what an
+        # inactive source lane yields, which the one-lane model cannot see: they are refused.
+        if mods or len(ops) != 4:
+            raise Unsupported('v_permlanex16_b32 with %d operands and modifiers %s' % (len(ops), mods))
+        dst = reg_range(ops[0])
+        if not dst or dst[0] != 'v' or dst[1] != dst[2] or dst[1] > 255:
+            raise Unsupported('v_permlanex16_b32 destination %s: expected a single VGPR' % ops[0])
+        for tok in ops[2:]:
+            sel = reg_range(tok)
+            if sel and (sel[0] != 's' or sel[1] != sel[2]):
+                raise Unsupported('v_permlanex16_b32 lane select %s: expected a scalar register' % tok)
+            self.u(tok)
+        src = self.uniform_vgpr('v_permlanex16_b32', ops[1])
+        self.set_v(dst[1], 'v%d' % src)
+        self.uniform_v.add(dst[1])

Fixed in f2a28b42 (rebased on main, push pending). Agreed: uniformity is only proven over active lanes, so the selected source lane can be inactive. The same hole exists in v_readlane_b32. Both ops now refuse with "requires every selected source lane to be proven active", and the test asserts the refusals. Ran locally: python3 -B tests/startup_gfx2hlsl_readlane_perm_check.py and every tests/startup_gfx2hlsl_*check.py (all pass).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688725886 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2032#discussion_r4688725886). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:56:46Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 1369 ~~~~diff @@ -1330,6 +1330,44 @@ def op_v_readfirstlane_b32(self, ops, mods): raise Unsupported('v_readfirstlane_b32 requires a proven uniform source') self.set_s(reg_range(ops[0])[1], self.u(ops[1])) + def uniform_vgpr(self, name, tok): + """VGPR number of tok when every lane holds the same proven value, else Unsupported.""" + src = reg_range(tok) + if (self.has_branches or not self.exec_known or not src or src[0] != 'v' or src[1] != src[2] + or src[1] not in self.uniform_v): + raise Unsupported('%s requires a proven uniform source' % name) + return src[1] + + def op_v_readlane_b32(self, ops, mods): + # The model runs one lane of unknown index, so reading any lane equals reading this one only when + # the VGPR is proven uniform. The lane select (SGPR or inline constant) then does not change the value. + if mods or len(ops) != 3: + raise Unsupported('v_readlane_b32 with %d operands and modifiers %s' % (len(ops), mods)) + dst, sel = reg_range(ops[0]), reg_range(ops[2]) + if not dst or dst[0] != 's' or dst[1] != dst[2] or (sel and (sel[0] != 's' or sel[1] != sel[2])): + raise Unsupported('v_readlane_b32 operands %s, %s: expected a single SGPR and a scalar lane select' % (ops[0], ops[2])) + src = self.uniform_vgpr('v_readlane_b32', ops[1]) + self.u(ops[2]) + self.set_s(dst[1], 'v%d' % src) + + def op_v_permlanex16_b32(self, ops, mods): + # Lane i reads lane sel of the other row of 16. For a proven uniform VGPR every lane holds the + # same word, so the result is that word. The fetch-inactive and bound_ctrl flags change what an + # inactive source lane yields, which the one-lane model cannot see: they are refused. + if mods or len(ops) != 4: + raise Unsupported('v_permlanex16_b32 with %d operands and modifiers %s' % (len(ops), mods)) + dst = reg_range(ops[0]) + if not dst or dst[0] != 'v' or dst[1] != dst[2] or dst[1] > 255: + raise Unsupported('v_permlanex16_b32 destination %s: expected a single VGPR' % ops[0]) + for tok in ops[2:]: + sel = reg_range(tok) + if sel and (sel[0] != 's' or sel[1] != sel[2]): + raise Unsupported('v_permlanex16_b32 lane select %s: expected a scalar register' % tok) + self.u(tok) + src = self.uniform_vgpr('v_permlanex16_b32', ops[1]) + self.set_v(dst[1], 'v%d' % src) + self.uniform_v.add(dst[1]) ~~~~ --- Fixed in f2a28b42 (rebased on main, push pending). Agreed: uniformity is only proven over active lanes, so the selected source lane can be inactive. The same hole exists in v_readlane_b32. Both ops now refuse with "requires every selected source lane to be proven active", and the test asserts the refusals. Ran locally: python3 -B tests/startup_gfx2hlsl_readlane_perm_check.py and every tests/startup_gfx2hlsl_*check.py (all pass). AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 11:02:04 +00:00
tedin7 commented 2026-11-25 11:02:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:46:46Z.


@denn0x thanks, you are right: the uniform proof only covers lanes in the entry mask, so it cannot vouch for a lane select outside it.

Fixed in f2a28b42: v_readlane_b32 and v_permlanex16_b32 are now refused, because the selected source lane may be inactive and its VGPR content is not provable. The check is tests/startup_gfx2hlsl_readlane_perm_check.py (see the comment near line 36, which covers the sparse-EXEC permlanex16 case).

Thank you for the coverage numbers. The lane-spill shape (v_writelane_b32 / v_readlane_b32 with matching constants) can be lowered exactly as separate scalar slots, so it can be a separate item.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7160161594 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2032#issuecomment-7160161594). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T10:46:46Z. --- @denn0x thanks, you are right: the uniform proof only covers lanes in the entry mask, so it cannot vouch for a lane select outside it. Fixed in f2a28b42: `v_readlane_b32` and `v_permlanex16_b32` are now refused, because the selected source lane may be inactive and its VGPR content is not provable. The check is `tests/startup_gfx2hlsl_readlane_perm_check.py` (see the comment near line 36, which covers the sparse-EXEC permlanex16 case). Thank you for the coverage numbers. The lane-spill shape (`v_writelane_b32` / `v_readlane_b32` with matching constants) can be lowered exactly as separate scalar slots, so it can be a separate item. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 11:02:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:59:10Z.


Closing: main already lowers v_readlane_b32 for SGPR spill slots (so this PR's refusal definition shadows it and would break startup_gfx2hlsl_sgpr_spill_check.py), and v_permlanex16_b32 is already refused by default.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7160434128 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2032#issuecomment-7160434128). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T10:59:10Z. --- Closing: `main` already lowers `v_readlane_b32` for SGPR spill slots (so this PR's refusal definition shadows it and would break `startup_gfx2hlsl_sgpr_spill_check.py`), and `v_permlanex16_b32` is already refused by default.

Pull request closed

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!2025
No description provided.